Class Annotations

java.lang.Object
com.android.dx.util.MutabilityControl
com.android.dx.rop.annotation.Annotations
All Implemented Interfaces:
Comparable<Annotations>

public final class Annotations extends MutabilityControl implements Comparable<Annotations>
List of Annotation instances.
  • Field Details

    • EMPTY

      public static final Annotations EMPTY
      non-null; immutable empty instance
  • Constructor Details

    • Annotations

      public Annotations()
      Constructs an empty instance.
  • Method Details

    • combine

      public static Annotations combine(Annotations a1, Annotations a2)
      Constructs an immutable instance which is the combination of the two given instances. The two instances must contain disjoint sets of types.
      Parameters:
      a1 - non-null; an instance
      a2 - non-null; the other instance
      Returns:
      non-null; the combination
      Throws:
      IllegalArgumentException - thrown if there is a duplicate type
    • combine

      public static Annotations combine(Annotations annotations, Annotation annotation)
      Constructs an immutable instance which is the combination of the given instance with the given additional annotation. The latter's type must not already appear in the former.
      Parameters:
      annotations - non-null; the instance to augment
      annotation - non-null; the additional annotation
      Returns:
      non-null; the combination
      Throws:
      IllegalArgumentException - thrown if there is a duplicate type
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • compareTo

      public int compareTo(Annotations other)
      Specified by:
      compareTo in interface Comparable<Annotations>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • size

      public int size()
      Gets the number of elements in this instance.
      Returns:
      >= 0; the size
    • add

      public void add(Annotation annotation)
      Adds an element to this instance. There must not already be an element of the same type.
      Parameters:
      annotation - non-null; the element to add
      Throws:
      IllegalArgumentException - thrown if there is a duplicate type
    • addAll

      public void addAll(Annotations toAdd)
      Adds all of the elements of the given instance to this one. The instances must not have any duplicate types.
      Parameters:
      toAdd - non-null; the annotations to add
      Throws:
      IllegalArgumentException - thrown if there is a duplicate type
    • getAnnotations

      public Collection<Annotation> getAnnotations()
      Gets the set of annotations contained in this instance. The result is always unmodifiable.
      Returns:
      non-null; the set of annotations