10
10
11
11
public class BetterReflectionClass {
12
12
13
+ /**
14
+ * @since 0.6
15
+ */
16
+ private final String name ;
17
+ /**
18
+ * @since 0.6
19
+ */
20
+ private final String simpleName ;
21
+ /**
22
+ * @since 0.6
23
+ */
24
+ private final String canonicalName ;
25
+ /**
26
+ * @since 0.6
27
+ */
28
+ private final String typeName ;
29
+
13
30
private Class <?> clasz ;
14
31
15
- private Field [] declaredFields ;
16
- private Field [] fields ;
17
- private Constructor <?>[] declaredConstructors ;
18
- private Constructor <?>[] constructors ;
19
- private Method [] declaredMethods ;
20
- private Method [] methods ;
32
+ private final Field [] declaredFields ;
33
+ private final Field [] fields ;
34
+ private final Constructor <?>[] declaredConstructors ;
35
+ private final Constructor <?>[] constructors ;
36
+ private final Method [] declaredMethods ;
37
+ private final Method [] methods ;
21
38
22
- private Class <?> superClass ;
39
+ /**
40
+ * @since 0.6
41
+ */
42
+ private final Class <?> superClass ;
23
43
24
44
public BetterReflectionClass (String className ) throws ClassNotFoundException {
25
45
this (Class .forName (className ));
@@ -28,12 +48,18 @@ public BetterReflectionClass(String className) throws ClassNotFoundException {
28
48
public BetterReflectionClass (Class <?> clasz ) {
29
49
this .clasz = clasz ;
30
50
51
+ this .name = clasz .getName ();
52
+ this .simpleName = clasz .getSimpleName ();
53
+ this .canonicalName = clasz .getCanonicalName ();
54
+ this .typeName = clasz .getTypeName ();
55
+
31
56
this .declaredFields = clasz .getDeclaredFields ();
32
57
this .fields = clasz .getFields ();
33
58
this .declaredConstructors = clasz .getDeclaredConstructors ();
34
59
this .constructors = clasz .getConstructors ();
35
60
this .declaredMethods = clasz .getDeclaredMethods ();
36
61
this .methods = clasz .getMethods ();
62
+ this .superClass = clasz .getSuperclass ();
37
63
}
38
64
39
65
/**
@@ -57,28 +83,28 @@ public Class<?> getClasz() {
57
83
* @since 0.4
58
84
*/
59
85
public String getName () {
60
- return clasz . getName () ;
86
+ return name ;
61
87
}
62
88
63
89
/**
64
90
* @since 0.4
65
91
*/
66
92
public String getSimpleName () {
67
- return clasz . getSimpleName () ;
93
+ return simpleName ;
68
94
}
69
95
70
96
/**
71
97
* @since 0.4
72
98
*/
73
99
public String getCanonicalName () {
74
- return clasz . getCanonicalName () ;
100
+ return canonicalName ;
75
101
}
76
102
77
103
/**
78
104
* @since 0.4
79
105
*/
80
106
public String getTypeName () {
81
- return clasz . getTypeName () ;
107
+ return typeName ;
82
108
}
83
109
84
110
public Field getDeclaredField (String name ) {
@@ -230,6 +256,9 @@ public Object invokeMethod(Object instance, String methodName, Object... paramet
230
256
return getMethod (methodName , BetterReflectionUtils .getTypes (parameters )).invoke (instance , parameters );
231
257
}
232
258
259
+ /**
260
+ * @since 0.6
261
+ */
233
262
public Class <?> getSuperclass () {
234
263
return superClass ;
235
264
}
0 commit comments