public class AnnotatedTypeBuilder<X> extends Object
AnnotatedType
for use in CDI life cycle events.
Using the builder is typically done by reading the annotations from a Class
or an
AnnotatedType
. Once the starting class or type has been added all of annotations
can be modified: constructor, parameter, class, method and fields.
The AnnotatedTypeBuilder is not thread safe and shall not be used concurrently!Constructor and Description |
---|
AnnotatedTypeBuilder()
Create a new builder.
|
Modifier and Type | Method and Description |
---|---|
AnnotatedTypeBuilder<X> |
addToClass(Annotation annotation)
Add an annotation to the type declaration.
|
AnnotatedTypeBuilder<X> |
addToConstructor(javax.enterprise.inject.spi.AnnotatedConstructor<X> constructor,
Annotation annotation)
Add an annotation to the specified constructor.
|
AnnotatedTypeBuilder<X> |
addToConstructor(Constructor<X> constructor,
Annotation annotation)
Add an annotation to the specified constructor.
|
AnnotatedTypeBuilder<X> |
addToConstructorParameter(Constructor<X> constructor,
int position,
Annotation annotation)
Add an annotation to the specified constructor parameter.
|
AnnotatedTypeBuilder<X> |
addToField(javax.enterprise.inject.spi.AnnotatedField<? super X> field,
Annotation annotation)
Add an annotation to the specified field.
|
AnnotatedTypeBuilder<X> |
addToField(Field field,
Annotation annotation)
Add an annotation to the specified field.
|
AnnotatedTypeBuilder<X> |
addToMethod(javax.enterprise.inject.spi.AnnotatedMethod<? super X> method,
Annotation annotation)
Add an annotation to the specified method.
|
AnnotatedTypeBuilder<X> |
addToMethod(Method method,
Annotation annotation)
Add an annotation to the specified method.
|
AnnotatedTypeBuilder<X> |
addToMethodParameter(Method method,
int position,
Annotation annotation)
Add an annotation to the specified method parameter.
|
AnnotatedTypeBuilder<X> |
addToParameter(javax.enterprise.inject.spi.AnnotatedParameter<? super X> parameter,
Annotation annotation)
Add an annotation to the specified parameter.
|
javax.enterprise.inject.spi.AnnotatedType<X> |
create()
Create an
AnnotatedType . |
Class<X> |
getJavaClass()
getter for the class
|
protected void |
mergeAnnotationsOnElement(javax.enterprise.inject.spi.Annotated annotated,
boolean overwriteExisting,
org.apache.deltaspike.core.util.metadata.builder.AnnotationBuilder typeAnnotations) |
AnnotatedTypeBuilder<X> |
overrideConstructorParameterType(Constructor<X> constructor,
int position,
Type type)
Override the declared type of a constructor parameter
|
void |
overrideFieldType(javax.enterprise.inject.spi.AnnotatedField<? super X> field,
Type type)
Override the declared type of a field
|
void |
overrideFieldType(Field field,
Type type)
Override the declared type of a field
|
AnnotatedTypeBuilder<X> |
overrideMethodParameterType(Method method,
int position,
Type type)
Override the declared type of a method parameter
|
AnnotatedTypeBuilder<X> |
overrideParameterType(javax.enterprise.inject.spi.AnnotatedParameter<? super X> parameter,
Type type)
Override the declared type of a parameter.
|
AnnotatedTypeBuilder<X> |
readFromType(javax.enterprise.inject.spi.AnnotatedType<X> type)
Reads in from an existing AnnotatedType.
|
AnnotatedTypeBuilder<X> |
readFromType(javax.enterprise.inject.spi.AnnotatedType<X> type,
boolean overwrite)
Reads in from an existing AnnotatedType.
|
AnnotatedTypeBuilder<X> |
readFromType(Class<X> type)
Reads the annotations from an existing java type.
|
AnnotatedTypeBuilder<X> |
readFromType(Class<X> type,
boolean overwrite)
Reads the annotations from an existing java type.
|
AnnotatedTypeBuilder<X> |
removeFromAll(Class<? extends Annotation> annotationType)
Remove annotations from the type, and all of it's members.
|
AnnotatedTypeBuilder<X> |
removeFromClass(Class<? extends Annotation> annotationType)
Remove an annotation from the type
|
AnnotatedTypeBuilder<X> |
removeFromConstructor(javax.enterprise.inject.spi.AnnotatedConstructor<X> constructor,
Class<? extends Annotation> annotationType)
Remove an annotation from the specified constructor.
|
AnnotatedTypeBuilder<X> |
removeFromConstructor(Constructor<X> constructor,
Class<? extends Annotation> annotationType)
Remove an annotation from the specified constructor.
|
AnnotatedTypeBuilder<X> |
removeFromConstructorParameter(Constructor<X> constructor,
int position,
Class<? extends Annotation> annotationType)
Remove an annotation from the specified constructor parameter.
|
AnnotatedTypeBuilder<X> |
removeFromField(javax.enterprise.inject.spi.AnnotatedField<? super X> field,
Class<? extends Annotation> annotationType)
Remove an annotation from the specified field.
|
AnnotatedTypeBuilder<X> |
removeFromField(Field field,
Class<? extends Annotation> annotationType)
Remove an annotation from the specified field.
|
AnnotatedTypeBuilder<X> |
removeFromMethod(javax.enterprise.inject.spi.AnnotatedMethod<? super X> method,
Class<? extends Annotation> annotationType)
Remove an annotation from the specified method.
|
AnnotatedTypeBuilder<X> |
removeFromMethod(Method method,
Class<? extends Annotation> annotationType)
Remove an annotation from the specified method.
|
AnnotatedTypeBuilder<X> |
removeFromMethodParameter(Method method,
int position,
Class<? extends Annotation> annotationType)
Remove an annotation from the specified method parameter.
|
AnnotatedTypeBuilder<X> |
removeFromParameter(javax.enterprise.inject.spi.AnnotatedParameter<? super X> parameter,
Class<? extends Annotation> annotationType)
Remove an annotation from the specified parameter.
|
AnnotatedTypeBuilder<X> |
setJavaClass(Class<X> javaClass)
setter for the class
|
public AnnotatedTypeBuilder()
public AnnotatedTypeBuilder<X> addToClass(Annotation annotation)
annotation
- the annotation instance to addIllegalArgumentException
- if the annotation is nullpublic AnnotatedTypeBuilder<X> removeFromClass(Class<? extends Annotation> annotationType)
annotationType
- the annotation type to removeIllegalArgumentException
- if the annotationTypepublic AnnotatedTypeBuilder<X> addToField(Field field, Annotation annotation)
field
- the field to add the annotation toannotation
- the annotation to addIllegalArgumentException
- if the annotation is nullpublic AnnotatedTypeBuilder<X> addToField(javax.enterprise.inject.spi.AnnotatedField<? super X> field, Annotation annotation)
field
- the field to add the annotation toannotation
- the annotation to addIllegalArgumentException
- if the annotation is nullpublic AnnotatedTypeBuilder<X> removeFromField(Field field, Class<? extends Annotation> annotationType)
field
- the field to remove the annotation fromannotationType
- the annotation type to removeIllegalArgumentException
- if the annotationType is null or if the
field is not currently declared on the typepublic AnnotatedTypeBuilder<X> removeFromField(javax.enterprise.inject.spi.AnnotatedField<? super X> field, Class<? extends Annotation> annotationType)
field
- the field to remove the annotation fromannotationType
- the annotation type to removeIllegalArgumentException
- if the annotationType is null or if the
field is not currently declared on the typepublic AnnotatedTypeBuilder<X> addToMethod(Method method, Annotation annotation)
method
- the method to add the annotation toannotation
- the annotation to addIllegalArgumentException
- if the annotation is nullpublic AnnotatedTypeBuilder<X> addToMethod(javax.enterprise.inject.spi.AnnotatedMethod<? super X> method, Annotation annotation)
method
- the method to add the annotation toannotation
- the annotation to addIllegalArgumentException
- if the annotation is nullpublic AnnotatedTypeBuilder<X> removeFromMethod(Method method, Class<? extends Annotation> annotationType)
method
- the method to remove the annotation fromannotationType
- the annotation type to removeIllegalArgumentException
- if the annotationType is null or if the
method is not currently declared on the typepublic AnnotatedTypeBuilder<X> removeFromMethod(javax.enterprise.inject.spi.AnnotatedMethod<? super X> method, Class<? extends Annotation> annotationType)
method
- the method to remove the annotation fromannotationType
- the annotation type to removeIllegalArgumentException
- if the annotationType is null or if the
method is not currently declared on the typepublic AnnotatedTypeBuilder<X> addToMethodParameter(Method method, int position, Annotation annotation)
method
- the method to add the annotation toposition
- the position of the parameter to addannotation
- the annotation to addIllegalArgumentException
- if the annotation is nullpublic AnnotatedTypeBuilder<X> removeFromMethodParameter(Method method, int position, Class<? extends Annotation> annotationType)
method
- the method to remove the annotation fromposition
- the position of the parameter to removeannotationType
- the annotation type to removeIllegalArgumentException
- if the annotationType is null, if the
method is not currently declared on the type or if the
parameter is not declared on the methodpublic AnnotatedTypeBuilder<X> addToConstructor(Constructor<X> constructor, Annotation annotation)
constructor
- the constructor to add the annotation toannotation
- the annotation to addIllegalArgumentException
- if the annotation is nullpublic AnnotatedTypeBuilder<X> addToConstructor(javax.enterprise.inject.spi.AnnotatedConstructor<X> constructor, Annotation annotation)
constructor
- the constructor to add the annotation toannotation
- the annotation to addIllegalArgumentException
- if the annotation is nullpublic AnnotatedTypeBuilder<X> removeFromConstructor(Constructor<X> constructor, Class<? extends Annotation> annotationType)
constructor
- the constructor to add the annotation toannotationType
- the annotation to addIllegalArgumentException
- if the annotationType is null or if the
constructor is not currently declared on the typepublic AnnotatedTypeBuilder<X> removeFromConstructor(javax.enterprise.inject.spi.AnnotatedConstructor<X> constructor, Class<? extends Annotation> annotationType)
constructor
- the constructor to add the annotation toannotationType
- the annotation to addIllegalArgumentException
- if the annotationType is null, if the
annotation does not exist on the type or if the constructor is
not currently declared on the typepublic AnnotatedTypeBuilder<X> addToConstructorParameter(Constructor<X> constructor, int position, Annotation annotation)
constructor
- the constructor to add the annotation toposition
- the position of the parameter to addannotation
- the annotation to addIllegalArgumentException
- if the annotation is nullpublic AnnotatedTypeBuilder<X> removeFromConstructorParameter(Constructor<X> constructor, int position, Class<? extends Annotation> annotationType)
constructor
- the constructor to remove the annotation fromposition
- the position of the parameter to removeannotationType
- the annotation type to removeIllegalArgumentException
- if the annotationType is null, if the
constructor is not currently declared on the type or if the
parameter is not declared on the constructorpublic AnnotatedTypeBuilder<X> removeFromParameter(javax.enterprise.inject.spi.AnnotatedParameter<? super X> parameter, Class<? extends Annotation> annotationType)
parameter
- the parameter to remove the annotation fromannotationType
- the annotation type to removeIllegalArgumentException
- if the annotationType is null, if the
callable which declares the parameter is not currently declared
on the type or if the parameter is not declared on either a
constructor or a methodpublic AnnotatedTypeBuilder<X> addToParameter(javax.enterprise.inject.spi.AnnotatedParameter<? super X> parameter, Annotation annotation)
parameter
- the parameter to add the annotation toannotation
- the annotation to addIllegalArgumentException
- if the annotation is null or if the
parameter is not declared on either a constructor or a methodpublic AnnotatedTypeBuilder<X> removeFromAll(Class<? extends Annotation> annotationType)
annotationType
- the type of annotation to removeIllegalArgumentException
- if the annotationType is nullpublic AnnotatedTypeBuilder<X> readFromType(javax.enterprise.inject.spi.AnnotatedType<X> type)
type
- the type to read fromIllegalArgumentException
- if type is nullpublic AnnotatedTypeBuilder<X> readFromType(javax.enterprise.inject.spi.AnnotatedType<X> type, boolean overwrite)
type
- the type to read fromoverwrite
- if true, the read annotation will replace any existing
annotationIllegalArgumentException
- if type is nullpublic AnnotatedTypeBuilder<X> readFromType(Class<X> type)
type
- the type to read fromIllegalArgumentException
- if type is nullpublic AnnotatedTypeBuilder<X> readFromType(Class<X> type, boolean overwrite)
type
- the type to read fromoverwrite
- if true, the read annotation will replace any existing
annotationprotected void mergeAnnotationsOnElement(javax.enterprise.inject.spi.Annotated annotated, boolean overwriteExisting, org.apache.deltaspike.core.util.metadata.builder.AnnotationBuilder typeAnnotations)
public javax.enterprise.inject.spi.AnnotatedType<X> create()
AnnotatedType
. Any public members present on the
underlying class and not overridden by the builder will be automatically
added.public void overrideFieldType(Field field, Type type)
field
- the field to override the type ontype
- the new type of the fieldIllegalArgumentException
- if field or type is nullpublic void overrideFieldType(javax.enterprise.inject.spi.AnnotatedField<? super X> field, Type type)
field
- the field to override the type ontype
- the new type of the fieldIllegalArgumentException
- if field or type is nullpublic AnnotatedTypeBuilder<X> overrideMethodParameterType(Method method, int position, Type type)
method
- the method to override the parameter type onposition
- the position of the parameter to override the type ontype
- the new type of the parameterIllegalArgumentException
- if parameter or type is nullpublic AnnotatedTypeBuilder<X> overrideConstructorParameterType(Constructor<X> constructor, int position, Type type)
constructor
- the constructor to override the parameter type onposition
- the position of the parameter to override the type ontype
- the new type of the parameterIllegalArgumentException
- if parameter or type is nullpublic AnnotatedTypeBuilder<X> overrideParameterType(javax.enterprise.inject.spi.AnnotatedParameter<? super X> parameter, Type type)
parameter
- the parameter to override the type ontype
- the new type of the parameterIllegalArgumentException
- if parameter or type is nullpublic AnnotatedTypeBuilder<X> setJavaClass(Class<X> javaClass)
Copyright © 2016 The Apache Software Foundation. All rights reserved.