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