1 package net.florianschoppmann.java.reflect;
2
3 import javax.annotation.Nullable;
4 import javax.lang.model.type.TypeKind;
5 import javax.lang.model.type.TypeVisitor;
6 import javax.lang.model.type.WildcardType;
7 import java.util.Objects;
8
9 final class WildcardTypeImpl extends AnnotatedConstructImpl implements ReflectionTypeMirror, WildcardType {
10
11
12
13 @Nullable private final ReflectionTypeMirror extendsBound;
14
15
16
17
18 @Nullable private final ReflectionTypeMirror superBound;
19
20 WildcardTypeImpl(@Nullable ReflectionTypeMirror extendsBound, @Nullable ReflectionTypeMirror superBound) {
21 this.extendsBound = extendsBound;
22 this.superBound = superBound;
23 }
24
25 @Override
26 public boolean equals(@Nullable Object otherObject) {
27 if (this == otherObject) {
28 return true;
29 } else if (otherObject == null || getClass() != otherObject.getClass()) {
30 return false;
31 }
32
33 WildcardTypeImpl other = (WildcardTypeImpl) otherObject;
34 return Objects.equals(extendsBound, other.extendsBound)
35 && Objects.equals(superBound, other.superBound);
36 }
37
38 @Override
39 public int hashCode() {
40 return Objects.hash(extendsBound, superBound);
41 }
42
43 @Override
44 public String toString() {
45 return ReflectionTypes.getInstance().toString(this);
46 }
47
48 @Override
49 public <R, P> R accept(TypeVisitor<R, P> visitor, @Nullable P parameter) {
50 return visitor.visitWildcard(this, parameter);
51 }
52
53 @Override
54 @Nullable
55 public ReflectionTypeMirror getExtendsBound() {
56 return extendsBound;
57 }
58
59 @Override
60 @Nullable
61 public ReflectionTypeMirror getSuperBound() {
62 return superBound;
63 }
64
65 @Override
66 public TypeKind getKind() {
67 return TypeKind.WILDCARD;
68 }
69 }