package nl.tudelft.simulation.introspection.beans; import java.beans.PropertyDescriptor; /** * Utility class for bean tests. *

* (c) copyright 2002-2014 Delft University of Technology.
* BSD-style license. See DSOL License.
* @author Peter Jacobs. * @author Alexander Verbraeck. * @author Niels Lang. * @since 1.5 */ public class BeanUtils extends Object { /** * resolves whether the bean is null * @param bean A bean instance. * @param pd A PropertyDescriptor for the property to be examined. * @return True, if the value of the property described by 'pd' for the instance 'bean' is null indeed. Returns * false otherwise. */ public static boolean isNull(final Object bean, final PropertyDescriptor pd) { Object result = null; try { result = pd.getReadMethod().invoke(bean, new Object[0]); } catch (Exception e) { return true; } return (result == null); } }