Class AnnotatedTypeBuilder<X>

java.lang.Object
org.infinispan.cdi.common.util.annotatedtypebuilder.AnnotatedTypeBuilder<X>

public class AnnotatedTypeBuilder<X> extends Object

Class for constructing a new AnnotatedType. A new instance of builder should be used for each annotated type.

AnnotatedTypeBuilder is not thread-safe.

Author:
Stuart Douglas, Pete Muir
See Also:
  • AnnotatedType
  • Constructor Details

  • Method Details

    • addToClass

      public AnnotatedTypeBuilder<X> addToClass(Annotation annotation)
      Add an annotation to the type declaration.
      Parameters:
      annotation - the annotation instance to add
      Throws:
      IllegalArgumentException - if the annotation is null
    • readFromType

      public AnnotatedTypeBuilder<X> readFromType(javax.enterprise.inject.spi.AnnotatedType<X> type)
      Reads in from an existing AnnotatedType. Any elements not present are added. The javaClass will be read in. If the annotation already exists on that element in the builder the read annotation will be used.
      Parameters:
      type - the type to read from
      Throws:
      IllegalArgumentException - if type is null
    • readFromType

      public AnnotatedTypeBuilder<X> readFromType(javax.enterprise.inject.spi.AnnotatedType<X> type, boolean overwrite)
      Reads in from an existing AnnotatedType. Any elements not present are added. The javaClass will be read in if overwrite is true. If the annotation already exists on that element in the builder, overwrite determines whether the original or read annotation will be used.
      Parameters:
      type - the type to read from
      overwrite - if true, the read annotation will replace any existing annotation
      Throws:
      IllegalArgumentException - if type is null
    • readFromType

      public AnnotatedTypeBuilder<X> readFromType(Class<X> type)
      Reads the annotations from an existing java type. Annotations already present will be overwritten
      Parameters:
      type - the type to read from
      Throws:
      IllegalArgumentException - if type is null
    • readFromType

      public AnnotatedTypeBuilder<X> readFromType(Class<X> type, boolean overwrite)
      Reads the annotations from an existing java type. If overwrite is true then existing annotations will be overwritten
      Parameters:
      type - the type to read from
      overwrite - if true, the read annotation will replace any existing annotation
    • mergeAnnotationsOnElement

      protected void mergeAnnotationsOnElement(javax.enterprise.inject.spi.Annotated annotated, boolean overwriteExisting, AnnotationBuilder typeAnnotations)
    • create

      public javax.enterprise.inject.spi.AnnotatedType<X> create()
      Create an AnnotatedType. Any public members present on the underlying class and not overridden by the builder will be automatically added.
    • removeFromClass

      public AnnotatedTypeBuilder<X> removeFromClass(Class<? extends Annotation> annotationType)
      Remove an annotation from the type
      Parameters:
      annotationType - the annotation type to remove
      Throws:
      IllegalArgumentException - if the annotationType
    • removeFromMethod

      public AnnotatedTypeBuilder<X> removeFromMethod(Method method, Class<? extends Annotation> annotationType)
      Remove an annotation from the specified method.
      Parameters:
      method - the method to remove the annotation from
      annotationType - the annotation type to remove
      Throws:
      IllegalArgumentException - if the annotationType is null or if the method is not currently declared on the type
    • removeFromMethod

      public AnnotatedTypeBuilder<X> removeFromMethod(javax.enterprise.inject.spi.AnnotatedMethod<? super X> method, Class<? extends Annotation> annotationType)
      Remove an annotation from the specified method.
      Parameters:
      method - the method to remove the annotation from
      annotationType - the annotation type to remove
      Throws:
      IllegalArgumentException - if the annotationType is null or if the method is not currently declared on the type
    • addToMethod

      public AnnotatedTypeBuilder<X> addToMethod(Method method, Annotation annotation)
      Add an annotation to the specified method. If the method is not already present, it will be added.
      Parameters:
      method - the method to add the annotation to
      annotation - the annotation to add
      Throws:
      IllegalArgumentException - if the annotation is null
    • addToMethod

      public AnnotatedTypeBuilder<X> addToMethod(javax.enterprise.inject.spi.AnnotatedMethod<? super X> method, Annotation annotation)
      Add an annotation to the specified method. If the method is not already present, it will be added.
      Parameters:
      method - the method to add the annotation to
      annotation - the annotation to add
      Throws:
      IllegalArgumentException - if the annotation is null
    • addToMethodParameter

      public AnnotatedTypeBuilder<X> addToMethodParameter(Method method, int position, Annotation annotation)
      Add an annotation to the specified method parameter. If the method is not already present, it will be added. If the method parameter is not already present, it will be added.
      Parameters:
      method - the method to add the annotation to
      position - the position of the parameter to add
      annotation - the annotation to add
      Throws:
      IllegalArgumentException - if the annotation is null
    • removeFromMethodParameter

      public AnnotatedTypeBuilder<X> removeFromMethodParameter(Method method, int position, Class<? extends Annotation> annotationType)
      Remove an annotation from the specified method parameter.
      Parameters:
      method - the method to remove the annotation from
      position - the position of the parameter to remove
      annotationType - the annotation type to remove
      Throws:
      IllegalArgumentException - if the annotationType is null, if the method is not currently declared on the type or if the parameter is not declared on the method
    • addToField

      public AnnotatedTypeBuilder<X> addToField(Field field, Annotation annotation)
      Add an annotation to the specified field. If the field is not already present, it will be added.
      Parameters:
      field - the field to add the annotation to
      annotation - the annotation to add
      Throws:
      IllegalArgumentException - if the annotation is null
    • addToField

      public AnnotatedTypeBuilder<X> addToField(javax.enterprise.inject.spi.AnnotatedField<? super X> field, Annotation annotation)
      Add an annotation to the specified field. If the field is not already present, it will be added.
      Parameters:
      field - the field to add the annotation to
      annotation - the annotation to add
      Throws:
      IllegalArgumentException - if the annotation is null
    • removeFromField

      public AnnotatedTypeBuilder<X> removeFromField(Field field, Class<? extends Annotation> annotationType)
      Remove an annotation from the specified field.
      Parameters:
      field - the field to remove the annotation from
      annotationType - the annotation type to remove
      Throws:
      IllegalArgumentException - if the annotationType is null or if the field is not currently declared on the type
    • removeFromField

      public AnnotatedTypeBuilder<X> removeFromField(javax.enterprise.inject.spi.AnnotatedField<? super X> field, Class<? extends Annotation> annotationType)
      Remove an annotation from the specified field.
      Parameters:
      field - the field to remove the annotation from
      annotationType - the annotation type to remove
      Throws:
      IllegalArgumentException - if the annotationType is null or if the field is not currently declared on the type