forked from json-iterator/java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBinding.java
More file actions
54 lines (46 loc) · 1.45 KB
/
Binding.java
File metadata and controls
54 lines (46 loc) · 1.45 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.jsoniter;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
public class Binding {
// input
public Class clazz;
public String name;
public Type valueType;
public Annotation[] annotations;
// output
public String[] fromNames;
public Decoder decoder;
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
if (annotations == null) {
return null;
}
for (Annotation annotation : annotations) {
if (annotationClass.isAssignableFrom(annotation.getClass())) {
return (T) annotation;
}
}
return null;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Binding binding = (Binding) o;
if (clazz != null ? !clazz.equals(binding.clazz) : binding.clazz != null) return false;
return name != null ? name.equals(binding.name) : binding.name == null;
}
@Override
public int hashCode() {
int result = clazz != null ? clazz.hashCode() : 0;
result = 31 * result + (name != null ? name.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "Binding{" +
"clazz=" + clazz +
", name='" + name + '\'' +
", valueType=" + valueType +
'}';
}
}