Package org.jboss.jandex
Interface MutableAnnotationOverlay
- All Superinterfaces:
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
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classThe builder for a mutable annotation overlay. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAnnotation(Declaration declaration, AnnotationInstance annotation) Adds given annotation instance to givendeclaration.Returns a new builder for a mutable annotation overlay for givenindex.freeze()Freezes this mutable annotation overlay and returns the annotation transformations to create an equivalent immutable annotation overlay.voidremoveAnnotations(Declaration declaration, Predicate<AnnotationInstance> predicate) Removes all annotations matching givenpredicatefrom givendeclaration.Methods inherited from interface org.jboss.jandex.AnnotationOverlay
annotation, annotation, annotations, annotationsWithRepeatable, annotationsWithRepeatable, hasAnnotation, hasAnnotation, hasAnyAnnotation, hasAnyAnnotation, index
-
Method Details
-
builder
Returns a new builder for a mutable annotation overlay for givenindex.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 benull- Returns:
- the mutable annotation overlay builder, never
null
-
addAnnotation
Adds given annotation instance to givendeclaration. 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 benullannotation- the annotation instance to add todeclarationfor, must not benull
-
removeAnnotations
Removes all annotations matching givenpredicatefrom givendeclaration. 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 benullpredicate- the annotation predicate, must not benull
-
freeze
List<AnnotationTransformation> freeze()Freezes this mutable annotation overlay and returns the annotation transformations to create an equivalent immutable annotation overlay. After freezing, theaddAnnotation(Declaration, AnnotationInstance)andremoveAnnotations(Declaration, Predicate)methods will throw an exception.- Returns:
- immutable list of annotation transformations equivalent to mutations performed on this annotation overlay,
never
null
-