-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathReflection.java
More file actions
30 lines (26 loc) · 839 Bytes
/
Copy pathReflection.java
File metadata and controls
30 lines (26 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package chapter19.four;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.Set;
import java.util.TreeSet;
public class Reflection {
public static Set<String> analyze(Class<?> enumClass){
System.out.println("--------Analyzing--"+enumClass+"");
System.out.println("Interfaces");
for(Type t:enumClass.getGenericInterfaces()){
System.out.println(t);
}
System.out.println("Methods");
Set<String> methods=new TreeSet<String>();
for(Method m:enumClass.getMethods()){
methods.add(m.getName());
}
System.out.println(methods);
return methods;
}
public static void main(String[] args) {
Set<String> exploreMethods=analyze(Explore.class);
Set<String> EnumMethods=analyze(Enum.class);
System.out.println("Explore.containsAll(Enum)?" + exploreMethods.containsAll(EnumMethods));
}
}