1 package nl.tudelft.simulation.introspection;
2
3 import java.util.ArrayList;
4 import java.util.List;
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 public abstract class AbstractSuppressIntrospector implements Introspector
21 {
22
23 protected Introspector parent;
24
25
26
27
28
29 public AbstractSuppressIntrospector(final Introspector parent)
30 {
31 super();
32 this.parent = parent;
33 }
34
35
36 @Override
37 public Property[] getProperties(final Object arg0)
38 {
39 Property[] original = this.parent.getProperties(arg0);
40 List<Property> result = new ArrayList<Property>();
41 for (int i = 0; i < original.length; i++)
42 {
43 if (!this.suppress(original[i].getType()) && !this.suppress(original[i].getName()))
44 {
45 result.add(original[i]);
46 }
47 }
48 return result.toArray(new Property[0]);
49 }
50
51
52 @Override
53 public String[] getPropertyNames(final Object arg0)
54 {
55 Property[] properties = this.getProperties(arg0);
56 String[] result = new String[properties.length];
57 for (int i = 0; i < properties.length; i++)
58 {
59 result[i] = properties[i].getName();
60 }
61 return result;
62 }
63
64
65 @Override
66 public Property getProperty(final Object arg0, final String arg1)
67 {
68 Property[] properties = this.getProperties(arg0);
69 for (int i = 0; i < properties.length; i++)
70 {
71 if (properties[i].getName().equals(arg1))
72 {
73 return properties[i];
74 }
75 }
76 return null;
77 }
78
79
80
81
82
83
84 protected boolean suppress(final Class<?> type)
85 {
86 if (type.equals(Class.class))
87 {
88 return true;
89 }
90 return false;
91 }
92
93
94
95
96
97
98 protected abstract boolean suppress(final String propertyName);
99 }