blob: 67f86d43b5ed9aa17be57e8b1164a52186ae3476 (
plain)
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
|
package io.dico.dicore.command.parameter.type;
import java.lang.annotation.Annotation;
import java.util.Objects;
/**
* More appropriate name: ParameterTypeKey
*/
public class ParameterKey {
private final Class<?> returnType;
private final Class<? extends Annotation> annotationClass;
public ParameterKey(Class<?> returnType) {
this(returnType, null);
}
public ParameterKey(Class<?> returnType, Class<? extends Annotation> annotationClass) {
this.returnType = Objects.requireNonNull(returnType);
this.annotationClass = annotationClass;
}
public Class<?> getReturnType() {
return returnType;
}
public Class<? extends Annotation> getAnnotationClass() {
return annotationClass;
}
@Override
public boolean equals(Object o) {
return this == o || (o instanceof ParameterKey && equals((ParameterKey) o));
}
public boolean equals(ParameterKey that) {
return returnType == that.returnType && annotationClass == that.annotationClass;
}
@Override
public int hashCode() {
int result = returnType.hashCode();
result = 31 * result + (annotationClass != null ? annotationClass.hashCode() : 0);
return result;
}
}
|