diff options
author | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2012-11-27 04:08:20 +0000 |
---|---|---|
committer | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2012-11-27 04:08:20 +0000 |
commit | 449a0b97ab63a4bff26ae281322fc3afaab16569 (patch) | |
tree | 0eec62720551c4a9709c8f961be12c2466fa3543 /javax/lang/model/util/Elements.java | |
parent | 75fab280b83e1d86b396276da8e1e5b1ec6c0169 (diff) | |
download | classpath-449a0b97ab63a4bff26ae281322fc3afaab16569.tar.gz |
Add annotation elements and start of type hierarchy.
2012-11-26 Andrew John Hughes <gnu_andrew@member.fsf.org>
* javax/lang/model/element/AnnotationMirror.java:
Added.
(getAnnotationType()): Added.
(getElementValues()): Likewise.
* javax/lang/model/element/AnnotationValue.java:
Added.
(accept(AnnotationValueVisitor,P)): Added.
(getValue()): Likewise.
(toString()): Likewise.
* javax/lang/model/element/AnnotationValueVisitor.java:
Added.
(visit(AnnotationValue)): Added.
(visit(AnnotationValue, P)): Likewise.
(visitAnnotation(AnnotationMirror, P)): Likewise.
(visitArray(List, P)): Likewise.
(visitBoolean(boolean, P)): Likewise.
(visitByte(byte, P)): Likewise.
(visitChar(char, P)): Likewise.
(visitDouble(double, P)): Likewise.
(visitEnumConstant(VariableElement, P)): Likewise.
(visitFloat(float, P)): Likewise.
(visitInt(float, P)): Likewise.
(visitLong(long, P)): Likewise.
(visitShort(short, P)): Likewise.
(visitString(String, P)): Likewise.
(visitType(TypeMirror, P)): Likewise.
(visitUnknown(AnnotationValue, P)): Likewise.
* javax/lang/model/element/Element.java:
(asType()): Added.
(getAnnotationMirrors()): Likewise.
* javax/lang/model/element/ElementVisitor.java:
(visitExecutable(ExecutableElement, P)): Added.
(visitTypeParameter(TypeParameterElement, P)): Likewise.
(visitVariable(VariableElement, P)): Likewise.
* javax/lang/model/element/ExecutableElement.java:
Added.
(getDefaultValue()): Added.
(getParameters()): Likewise.
(getReturnType()): Likewise.
(getThrownTypes()): Likewise.
(getTypeParameters()): Likewise.
(isVarArgs()): Likewise.
* javax/lang/model/element/TypeElement.java:
(getInterfaces()): Added.
(getSuperclass()): Likewise.
(getTypeParameters()): Likewise.
* javax/lang/model/element/TypeParameterElement.java:
Added.
(getBounds()): Added.
(getGenericElement()): Likewise.
* javax/lang/model/element/VariableElement.java:
Added.
(getConstantValue()): Added.
* javax/lang/model/type/DeclaredType.java:
Added.
(asElement()): Added.
(getEnclosingType()): Likewise.
(getTypeArguments()): Likewise.
* javax/lang/model/type/ReferenceType.java:
Added.
* javax/lang/model/type/TypeKind.java:
Added.
(ARRAY): Added.
(BOOLEAN): Likewise.
(BYTE): Likewise.
(CHAR): Likewise.
(DECLARED): Likewise.
(DOUBLE): Likewise.
(ERROR): Likewise.
(EXECUTABLE): Likewise.
(FLOAT): Likewise.
(INT): Likewise.
(LONG): Likewise.
(NONE): Likewise.
(NULL): Likewise.
(OTHER): Likewise.
(PACKAGE): Likewise.
(SHORT): Likewise.
(TYPEVAR): Likewise.
(VOID): Likewise.
(WILDCARD): Likewise.
(isPrimitive()): Implemented.
* javax/lang/model/type/TypeMirror.java:
Added.
(accept(TypeVisitor, P)): Added.
(equals(Object)): Likewise.
(getKind()): Likewise.
(hashCode()): Likewise.
(toString()): Likewise.
* javax/lang/model/type/TypeVisitor.java:
Added.
(visit(TypeMirror)): Added.
(visit(TypeMirror, P)): Likewise.
(visitUnknown(TypeMirror, P)): Likewise.
(visitDeclared(DeclaredType, P)): Likewise.
* javax/lang/model/util/Elements.java:
(getAllAnnotationMirrors(Element)): Added.
(getElementValuesWithDefaults(AnnotationMirror)): Likewise.
(overrides(ExecutableElement, ExecutableElement)): Likewise.
* javax/lang/model/util/Types.java:
(asElement(TypeMirror)): Added.
(asMemberOf(DeclaredType, Element)): Likewise.
(capture(TypeMirror)): Likewise.
(contains(TypeMirror, TypeMirror)): Likewise.
(directSupertypes(TypeMirror)): Likewise.
(erasure(TypeMirror)): Likewise.
(getDeclaredType(DeclaredType, TypeElement,
TypeMirror...)): Likewise.
(getDeclaredType(TypeElement, TypeMirror...)):
Likewise.
(isAssignable(TypeMirror, TypeMirror)): Likewise.
(isSameType(TypeMirror, TypeMirror)): Likewise.
(isSubtype(TypeMirror, TypeMirror)): Likewise.
Signed-off-by: Andrew John Hughes <gnu_andrew@member.fsf.org>
Diffstat (limited to 'javax/lang/model/util/Elements.java')
-rw-r--r-- | javax/lang/model/util/Elements.java | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/javax/lang/model/util/Elements.java b/javax/lang/model/util/Elements.java index 67f89ef65..a3f7e2a3b 100644 --- a/javax/lang/model/util/Elements.java +++ b/javax/lang/model/util/Elements.java @@ -40,8 +40,12 @@ package javax.lang.model.util; import java.io.Writer; import java.util.List; +import java.util.Map; +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.AnnotationValue; import javax.lang.model.element.Element; +import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; /** @@ -121,4 +125,57 @@ public interface Elements */ void printElements(Writer w, Element... elements); + /** + * Returns all annotations associated with this element, + * whether present directly or inherited. + * + * @param element the element to examine. + * @return the annotations associated with this element or + * an empty list if there are none. + * @see Element#getAnnotationMirrors() + */ + List<? extends AnnotationMirror> getAllAnnotationMirrors(Element element); + + /** + * Returns a map of elements to their values, including both + * those explicitly specified and default values. + * A marker annotation, by definition, returns an empty map. + * The order of the elements in the map follows that of the + * source code. + * + * @param annotation the annotation whose values should be returned. + * @return the map of elements to values. + */ + Map<? extends ExecutableElement, ? extends AnnotationValue> + getElementValuesWithDefaults(AnnotationMirror annotation); + + /** + * <p>Returns true if the method {@code overrider} overrides + * the method {@code overridden}, when {@code overrider} is + * a member of the given type, according to sections + * 8.4.8 and 9.4.1 of the Java Language Specification.</p> + * <p>In most cases, the specified type will simply be the + * class containing {@code overrider}. For example, when + * checking if {@code String.hashCode()} overrides + * {@code Object.hashCode()}, the type will be {@code String}. + * However, in a more complex situation, the overridden and + * the overrider methods may be members of distinct types, + * {@code A} and {@code B}. If the type refers to {@code B}, + * the result will be {@code false} as {@code B} has no + * relationship to the methods in {@code A}. However, if the + * type refers to a third type {@code C}, which forms the + * intersection of {@code A} and {@code B} (say, it extends + * the class {@code A} and implements the interface {@code B}), + * then the result may be true.</p> + * + * @param overrider the method which may overrider the other. + * @param overridden the method which may be overridden. + * @param type the type of which the overrider is a member. + * @return true if the overrider overriders the overridden + * method in the specified type. + */ + boolean overrides(ExecutableElement overrider, + ExecutableElement overridden, + TypeElement type); + } |