153 } 154 155 156 /** 157 * Returns the name of this type variable, as it occurs in the source code. 158 * 159 * @return the name of this type variable, as it appears in the source code 160 */ 161 public String getName() { return name; } 162 163 public String toString() {return getName();} 164 165 @Override 166 public boolean equals(Object o) { 167 if (o instanceof TypeVariable) { 168 TypeVariable<?> that = (TypeVariable<?>) o; 169 170 GenericDeclaration thatDecl = that.getGenericDeclaration(); 171 String thatName = that.getName(); 172 173 return 174 (genericDeclaration == null ? 175 thatDecl == null : 176 genericDeclaration.equals(thatDecl)) && 177 (name == null ? 178 thatName == null : 179 name.equals(thatName)); 180 181 } else 182 return false; 183 } 184 185 @Override 186 public int hashCode() { 187 return genericDeclaration.hashCode() ^ name.hashCode(); 188 } 189 190 // Implementations of AnnotatedElement methods. 191 @SuppressWarnings("unchecked") 192 public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { 193 Objects.requireNonNull(annotationClass); 194 // T is an Annotation type, the return value of get will be an annotation 195 return (T)mapAnnotations(getAnnotations()).get(annotationClass); 196 } 197 198 public <T extends Annotation> T getDeclaredAnnotation(Class<T> annotationClass) { 199 Objects.requireNonNull(annotationClass); | 153 } 154 155 156 /** 157 * Returns the name of this type variable, as it occurs in the source code. 158 * 159 * @return the name of this type variable, as it appears in the source code 160 */ 161 public String getName() { return name; } 162 163 public String toString() {return getName();} 164 165 @Override 166 public boolean equals(Object o) { 167 if (o instanceof TypeVariable) { 168 TypeVariable<?> that = (TypeVariable<?>) o; 169 170 GenericDeclaration thatDecl = that.getGenericDeclaration(); 171 String thatName = that.getName(); 172 173 return Objects.equals(genericDeclaration, thatDecl) && 174 Objects.equals(name, thatName); 175 176 } else 177 return false; 178 } 179 180 @Override 181 public int hashCode() { 182 return genericDeclaration.hashCode() ^ name.hashCode(); 183 } 184 185 // Implementations of AnnotatedElement methods. 186 @SuppressWarnings("unchecked") 187 public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { 188 Objects.requireNonNull(annotationClass); 189 // T is an Annotation type, the return value of get will be an annotation 190 return (T)mapAnnotations(getAnnotations()).get(annotationClass); 191 } 192 193 public <T extends Annotation> T getDeclaredAnnotation(Class<T> annotationClass) { 194 Objects.requireNonNull(annotationClass); |