1
2
3
4
5
6
7
8
9
10 package nl.tudelft.simulation.introspection.beans;
11
12 import java.beans.PropertyDescriptor;
13
14 /***
15 * Utility class for bean tests.
16 * <p>
17 * (c) copyright 2003-2004 <a href="http://www.simulation.tudelft.nl">Delft
18 * University of Technology </a>, the Netherlands. <br>
19 * See for project information <a
20 * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
21 * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
22 * License (GPL) </a>, no warranty <br>
23 *
24 * @author <a
25 * href="http://web.eur.nl/fbk/dep/dep1/Introduction/Staff/People/Lang">Niels
26 * Lang </a><a
27 * href="http://www.tbm.tudelft.nl/webstaf/peterja/index.htm">Peter
28 * Jacobs </a>
29 * @version 1.1 Apr 15, 2004
30 * @since 1.4
31 */
32
33 public class BeanUtils extends Object
34 {
35 /***
36 * resolves whether the bean is null
37 *
38 * @param bean A bean instance.
39 * @param pd A PropertyDescriptor for the property to be examined.
40 * @return True, if the value of the property described by 'pd' for the
41 * instance 'bean' is null indeed. Returns false otherwise.
42 */
43 public static boolean isNull(final Object bean, final PropertyDescriptor pd)
44 {
45 Object result = null;
46 try
47 {
48 result = pd.getReadMethod().invoke(bean, new Object[0]);
49 } catch (Exception e)
50 {
51 return true;
52 }
53 return (result == null);
54 }
55 }