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 { result.add(original[i]); }
43 }
44 return result.toArray(new Property[0]);
45 }
46
47 @Override
48 public String[] getPropertyNames(final Object arg0)
49 {
50 Property[] properties = this.getProperties(arg0);
51 String[] result = new String[properties.length];
52 for (int i = 0; i < properties.length; i++)
53 {
54 result[i] = properties[i].getName();
55 }
56 return result;
57 }
58
59 @Override
60 public Property getProperty(final Object arg0, final String arg1)
61 {
62 Property[] properties = this.getProperties(arg0);
63 for (int i = 0; i < properties.length; i++)
64 {
65 if (properties[i].getName().equals(arg1))
66 { return properties[i]; }
67 }
68 return null;
69 }
70
71
72
73
74
75
76 protected boolean suppress(final Class<?> type)
77 {
78 if (type.equals(Class.class))
79 { return true; }
80 return false;
81 }
82
83
84
85
86
87
88 protected abstract boolean suppress(final String propertyName);
89 }