Class AnnotatedTypeBuilder<X>
java.lang.Object
org.infinispan.cdi.common.util.annotatedtypebuilder.AnnotatedTypeBuilder<X>
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddToClass(Annotation annotation) Add an annotation to the type declaration.addToField(Field field, Annotation annotation) Add an annotation to the specified field.addToField(javax.enterprise.inject.spi.AnnotatedField<? super X> field, Annotation annotation) Add an annotation to the specified field.addToMethod(Method method, Annotation annotation) Add an annotation to the specified method.addToMethod(javax.enterprise.inject.spi.AnnotatedMethod<? super X> method, Annotation annotation) Add an annotation to the specified method.addToMethodParameter(Method method, int position, Annotation annotation) Add an annotation to the specified method parameter.javax.enterprise.inject.spi.AnnotatedType<X>create()Create anAnnotatedType.protected voidmergeAnnotationsOnElement(javax.enterprise.inject.spi.Annotated annotated, boolean overwriteExisting, AnnotationBuilder typeAnnotations) readFromType(Class<X> type) Reads the annotations from an existing java type.readFromType(Class<X> type, boolean overwrite) Reads the annotations from an existing java type.readFromType(javax.enterprise.inject.spi.AnnotatedType<X> type) Reads in from an existing AnnotatedType.readFromType(javax.enterprise.inject.spi.AnnotatedType<X> type, boolean overwrite) Reads in from an existing AnnotatedType.removeFromClass(Class<? extends Annotation> annotationType) Remove an annotation from the typeremoveFromField(Field field, Class<? extends Annotation> annotationType) Remove an annotation from the specified field.removeFromField(javax.enterprise.inject.spi.AnnotatedField<? super X> field, Class<? extends Annotation> annotationType) Remove an annotation from the specified field.removeFromMethod(Method method, Class<? extends Annotation> annotationType) Remove an annotation from the specified method.removeFromMethod(javax.enterprise.inject.spi.AnnotatedMethod<? super X> method, Class<? extends Annotation> annotationType) Remove an annotation from the specified method.removeFromMethodParameter(Method method, int position, Class<? extends Annotation> annotationType) Remove an annotation from the specified method parameter.
-
Constructor Details
-
AnnotatedTypeBuilder
public AnnotatedTypeBuilder()Create a new builder. A new builder has no annotations and no members.
-
-
Method Details
-
addToClass
Add an annotation to the type declaration.- Parameters:
annotation- the annotation instance to add- Throws:
IllegalArgumentException- if the annotation is null
-
readFromType
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 fromoverwrite- if true, the read annotation will replace any existing annotation- Throws:
IllegalArgumentException- if type is null
-
readFromType
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
Reads the annotations from an existing java type. If overwrite is true then existing annotations will be overwritten- Parameters:
type- the type to read fromoverwrite- 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
Create anAnnotatedType. Any public members present on the underlying class and not overridden by the builder will be automatically added. -
removeFromClass
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 fromannotationType- 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 fromannotationType- the annotation type to remove- Throws:
IllegalArgumentException- if the annotationType is null or if the method is not currently declared on the type
-
addToMethod
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 toannotation- 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 toannotation- 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 toposition- the position of the parameter to addannotation- 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 fromposition- the position of the parameter to removeannotationType- 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
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 toannotation- 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 toannotation- 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 fromannotationType- 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 fromannotationType- the annotation type to remove- Throws:
IllegalArgumentException- if the annotationType is null or if the field is not currently declared on the type
-