Interface MutableAnnotationOverlay

All Superinterfaces:
AnnotationOverlay
All Known Implementing Classes:
MutableAnnotationOverlayImpl

public interface MutableAnnotationOverlay extends AnnotationOverlay
An AnnotationOverlay that can be freely mutated. The freeze() operation returns a list of annotation transformations that can later be used to create an equivalent immutable annotation overlay.
Since:
3.2.0
  • Method Details

    • builder

      Returns a new builder for a mutable annotation overlay for given index.

      Thread safety

      The object returned by the builder is not thread safe and should be confined to a single thread. After calling freeze(), the object becomes immutable and can be shared between threads.

      Parameters:
      index - the Jandex index, must not be null
      Returns:
      the mutable annotation overlay builder, never null
    • addAnnotation

      void addAnnotation(Declaration declaration, AnnotationInstance annotation)
      Adds given annotation instance to given declaration. When asking this annotation overlay about annotation information for given declaration, the results will include given annotation instance.
      Parameters:
      declaration - the declaration to modify, must not be null
      annotation - the annotation instance to add to declaration for, must not be null
    • removeAnnotations

      void removeAnnotations(Declaration declaration, Predicate<AnnotationInstance> predicate)
      Removes all annotations matching given predicate from given declaration. When asking this annotation overlay about annotation information for given declaration, the results will not include matching annotation instances.
      Parameters:
      declaration - the declaration to modify, must not be null
      predicate - the annotation predicate, must not be null
    • freeze

      Freezes this mutable annotation overlay and returns the annotation transformations to create an equivalent immutable annotation overlay. After freezing, the addAnnotation(Declaration, AnnotationInstance) and removeAnnotations(Declaration, Predicate) methods will throw an exception.
      Returns:
      immutable list of annotation transformations equivalent to mutations performed on this annotation overlay, never null