1010
1111public class BetterReflectionClass {
1212
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+
1330 private Class <?> clasz ;
1431
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 ;
2138
22- private Class <?> superClass ;
39+ /**
40+ * @since 0.6
41+ */
42+ private final Class <?> superClass ;
2343
2444 public BetterReflectionClass (String className ) throws ClassNotFoundException {
2545 this (Class .forName (className ));
@@ -28,12 +48,18 @@ public BetterReflectionClass(String className) throws ClassNotFoundException {
2848 public BetterReflectionClass (Class <?> clasz ) {
2949 this .clasz = clasz ;
3050
51+ this .name = clasz .getName ();
52+ this .simpleName = clasz .getSimpleName ();
53+ this .canonicalName = clasz .getCanonicalName ();
54+ this .typeName = clasz .getTypeName ();
55+
3156 this .declaredFields = clasz .getDeclaredFields ();
3257 this .fields = clasz .getFields ();
3358 this .declaredConstructors = clasz .getDeclaredConstructors ();
3459 this .constructors = clasz .getConstructors ();
3560 this .declaredMethods = clasz .getDeclaredMethods ();
3661 this .methods = clasz .getMethods ();
62+ this .superClass = clasz .getSuperclass ();
3763 }
3864
3965 /**
@@ -57,28 +83,28 @@ public Class<?> getClasz() {
5783 * @since 0.4
5884 */
5985 public String getName () {
60- return clasz . getName () ;
86+ return name ;
6187 }
6288
6389 /**
6490 * @since 0.4
6591 */
6692 public String getSimpleName () {
67- return clasz . getSimpleName () ;
93+ return simpleName ;
6894 }
6995
7096 /**
7197 * @since 0.4
7298 */
7399 public String getCanonicalName () {
74- return clasz . getCanonicalName () ;
100+ return canonicalName ;
75101 }
76102
77103 /**
78104 * @since 0.4
79105 */
80106 public String getTypeName () {
81- return clasz . getTypeName () ;
107+ return typeName ;
82108 }
83109
84110 public Field getDeclaredField (String name ) {
@@ -230,6 +256,9 @@ public Object invokeMethod(Object instance, String methodName, Object... paramet
230256 return getMethod (methodName , BetterReflectionUtils .getTypes (parameters )).invoke (instance , parameters );
231257 }
232258
259+ /**
260+ * @since 0.6
261+ */
233262 public Class <?> getSuperclass () {
234263 return superClass ;
235264 }
0 commit comments