1 package nl.tudelft.simulation.introspection.beans;
2
3 import java.beans.PropertyDescriptor;
4
5 /**
6 * Utility class for bean tests.
7 * <p>
8 * Copyright (c) 2002-2025 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See
9 * for project information <a href="https://simulation.tudelft.nl/dsol/manual/" target="_blank">DSOL Manual</a>. The DSOL
10 * project is distributed under a three-clause BSD-style license, which can be found at
11 * <a href="https://simulation.tudelft.nl/dsol/docs/latest/license.html" target="_blank">DSOL License</a>.
12 * </p>
13 * @author <a href="https://www.linkedin.com/in/peterhmjacobs">Peter Jacobs </a>
14 * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
15 * @author Niels Lang.
16 * @since 1.5
17 */
18
19 public class BeanUtils extends Object
20 {
21 /**
22 * resolves whether the bean is null
23 * @param bean A bean instance.
24 * @param pd A PropertyDescriptor for the property to be examined.
25 * @return True, if the value of the property described by 'pd' for the instance 'bean' is null indeed. Returns false
26 * otherwise.
27 */
28 public static boolean isNull(final Object bean, final PropertyDescriptor pd)
29 {
30 Object result = null;
31 try
32 {
33 result = pd.getReadMethod().invoke(bean, new Object[0]);
34 }
35 catch (Exception e)
36 {
37 return true;
38 }
39 return (result == null);
40 }
41 }