MCPcopy Create free account
hub / github.com/VolmitSoftware/Adapt / id

Method id

src/main/java/com/volmit/adapt/util/Violator.java:32–77  ·  view source on GitHub ↗
(Object o, Object h)

Source from the content-addressed store, hash-verified

30 protected static ConcurrentSkipListMap<String, Object> nodes = new ConcurrentSkipListMap<String, Object>();
31
32 private static String id(Object o, Object h) {
33 if (o instanceof Field) {
34 return id(((Field) o).getDeclaringClass(), null) + "." + ((Field) o).getName();
35 }
36
37 if (o instanceof String) {
38 return (String) o;
39 }
40
41 if (o instanceof Class<?>) {
42 return ((Class<?>) o).getCanonicalName();
43 }
44
45 if (o instanceof Constructor<?>) {
46 Constructor<?> co = (Constructor<?>) o;
47
48 String mx = "";
49
50 for (Class<?> i : co.getParameterTypes()) {
51 mx += "," + i.getCanonicalName();
52 }
53
54 mx = mx.length() >= 1 ? mx.substring(1) : mx;
55
56 return id(co.getDeclaringClass(), null) + "(" + mx + ")";
57 }
58
59 if (o instanceof Method) {
60 String mx = "";
61
62 for (Class<?> i : ((Method) o).getParameterTypes()) {
63 mx += "," + i.getCanonicalName();
64 }
65
66 mx = mx.length() >= 1 ? mx.substring(1) : mx;
67
68 return id(((Method) o).getDeclaringClass(), null) + "." + ((Method) o).getName() + "(" + mx + ")";
69 }
70
71 if (o instanceof Annotation) {
72 Annotation a = (Annotation) o;
73 return "@" + a.annotationType().getCanonicalName() + "[" + id(h, null) + "]";
74 }
75
76 return o.hashCode() + o.toString();
77 }
78
79 private static void p(String n, Object o) {
80 nodes.put(n, o);

Callers 15

getConstructorMethod · 0.95
getFieldMethod · 0.95
getDeclaredFieldMethod · 0.95
getMethodMethod · 0.95
getDeclaredMethodMethod · 0.95
getAnnotationMethod · 0.95
getDeclaredAnnotationMethod · 0.95
BrewingAbsorptionMethod · 0.80
BrewingDarknessMethod · 0.80
BrewingResistanceMethod · 0.80
BrewingNauseaMethod · 0.80
BrewingBlindnessMethod · 0.80

Calls 4

getNameMethod · 0.65
lengthMethod · 0.45
hashCodeMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected