Interface Annotation

All Superinterfaces:
BasicAnnotation, Comparable<Annotation>
All Known Implementing Classes:
AnnotationRewriter.RewrittenAnnotation, BaseAnnotation, BuilderAnnotation, DexBackedAnnotation, ImmutableAnnotation

public interface Annotation extends BasicAnnotation, Comparable<Annotation>
This class represents a specific instance of an annotation applied to a class/field/method/parameter
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Compares this Annotation to another Annotation.
    boolean
    Compares this Annotation to another Annotation for equality.
    Gets a set of the name/value elements associated with this annotation.
    Gets the type of this annotation.
    int
    Gets the visibility of this annotation.
    int
    Returns a hashcode for this Annotation.
  • Method Details

    • getVisibility

      int getVisibility()
      Gets the visibility of this annotation. This will be one of the AnnotationVisibility.* constants.
      Returns:
      The visibility of this annotation
    • getType

      @Nonnull String getType()
      Gets the type of this annotation. This will be the type descriptor of the class that defines this annotation.
      Specified by:
      getType in interface BasicAnnotation
      Returns:
      The type of this annotation
    • getElements

      @Nonnull Set<? extends AnnotationElement> getElements()
      Gets a set of the name/value elements associated with this annotation. The elements in the returned set will be unique with respect to the element name.
      Specified by:
      getElements in interface BasicAnnotation
      Returns:
      A set of AnnotationElements
    • hashCode

      int hashCode()
      Returns a hashcode for this Annotation. This hashCode is defined to be the following:
       
       int hashCode = getVisibility();
       hashCode = hashCode*31 + getType().hashCode();
       hashCode = hashCode*31 + getElements().hashCode();
       
      Overrides:
      hashCode in class Object
      Returns:
      The hash code value for this Annotation
    • equals

      boolean equals(@Nullable Object o)
      Compares this Annotation to another Annotation for equality. This Annotation is equal to another Annotation if all of it's "fields" are equal. That is, if the return values of getVisibility(), getType(), and getElements() are all equal.
      Overrides:
      equals in class Object
      Parameters:
      o - The object to be compared for equality with this Annotation
      Returns:
      true if the specified object is equal to this Annotation
    • compareTo

      int compareTo(Annotation o)
      Compares this Annotation to another Annotation. The comparison is based on the value of getVisibility(), getType() and getElements(), in that order. When comparing the set of elements, the comparison is done with the semantics of org.jf.util.CollectionUtils.compareAsSet(), using the natural ordering of AnnotationElement.
      Specified by:
      compareTo in interface Comparable<Annotation>
      Parameters:
      o - The Annotation to compare with this Annotation
      Returns:
      An integer representing the result of the comparison