1 package com.fasterxml.jackson.databind.introspect; 2 3 import java.lang.annotation.Annotation; 4 import java.lang.reflect.AnnotatedElement; 5 import java.lang.reflect.Modifier; 6 7 import com.fasterxml.jackson.databind.JavaType; 8 9 /** 10 * Shared base class used for anything on which annotations (included 11 * within a {@link AnnotationMap}). 12 */ 13 public abstract class Annotated 14 { Annotated()15 protected Annotated() { } 16 getAnnotation(Class<A> acls)17 public abstract <A extends Annotation> A getAnnotation(Class<A> acls); 18 hasAnnotation(Class<?> acls)19 public abstract boolean hasAnnotation(Class<?> acls); 20 21 /** 22 * @since 2.7 23 */ hasOneOf(Class<? extends Annotation>[] annoClasses)24 public abstract boolean hasOneOf(Class<? extends Annotation>[] annoClasses); 25 26 /** 27 * Method that can be used to find actual JDK element that this instance 28 * represents. It is non-null, except for method/constructor parameters 29 * which do not have a JDK counterpart. 30 */ getAnnotated()31 public abstract AnnotatedElement getAnnotated(); 32 getModifiers()33 protected abstract int getModifiers(); 34 isPublic()35 public boolean isPublic() { 36 return Modifier.isPublic(getModifiers()); 37 } 38 getName()39 public abstract String getName(); 40 41 /** 42 * Full generic type of the annotated element; definition 43 * of what exactly this means depends on sub-class. 44 * 45 * @since 2.7 46 */ getType()47 public abstract JavaType getType(); 48 49 /** 50 * "Raw" type (type-erased class) of the annotated element; definition 51 * of what exactly this means depends on sub-class. 52 */ getRawType()53 public abstract Class<?> getRawType(); 54 55 /** 56 * Accessor that can be used to iterate over all the annotations 57 * associated with annotated component. 58 * 59 * @since 2.3 60 * @deprecated Since 2.9 should instead use {@link #getAnnotated()} 61 */ 62 @Deprecated annotations()63 public abstract Iterable<Annotation> annotations(); 64 65 // Also: ensure we can use #equals, #hashCode 66 67 @Override equals(Object o)68 public abstract boolean equals(Object o); 69 70 @Override hashCode()71 public abstract int hashCode(); 72 73 @Override toString()74 public abstract String toString(); 75 } 76