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

* Copyright (c) 2002-2019 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See * for project information https://simulation.tudelft.nl. The DSOL * project is distributed under a three-clause BSD-style license, which can be found at * * https://simulation.tudelft.nl/dsol/3.0/license.html. *

* @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 Object; A bean instance. * @param pd PropertyDescriptor; 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); } }