org.jboss.solder.reflection.annotated
Class AnnotatedTypeBuilder<X>

java.lang.Object
  extended by org.jboss.solder.reflection.annotated.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 Summary
AnnotatedTypeBuilder()
          Create a new builder.
 
Method Summary
 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()
           
protected  void mergeAnnotationsOnElement(javax.enterprise.inject.spi.Annotated annotated, boolean overwriteExisting, 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)
           
 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.
<A extends Annotation>
AnnotatedTypeBuilder<X>
redefine(Class<A> annotationType, AnnotationRedefiner<A> redefinition)
          Redefine any annotations of the specified type.
protected
<A extends Annotation>
void
redefineAnnotationBuilder(Class<A> annotationType, AnnotationRedefiner<A> redefinition, AnnotatedElement annotated, Type baseType, AnnotationBuilder builder, String elementName)
           
 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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotatedTypeBuilder

public AnnotatedTypeBuilder()
Create a new builder. A new builder has no annotations and no members.

See Also:
readFromType(AnnotatedType), readFromType(Class), readFromType(AnnotatedType, boolean), readFromType(Class, boolean)
Method Detail

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

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

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

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

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

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

addToConstructor

public AnnotatedTypeBuilder<X> addToConstructor(Constructor<X> constructor,
                                                Annotation annotation)
Add an annotation to the specified constructor. If the constructor is not already present, it will be added.

Parameters:
constructor - the constructor to add the annotation to
annotation - the annotation to add
Throws:
IllegalArgumentException - if the annotation is null

addToConstructor

public AnnotatedTypeBuilder<X> addToConstructor(javax.enterprise.inject.spi.AnnotatedConstructor<X> constructor,
                                                Annotation annotation)
Add an annotation to the specified constructor. If the constructor is not already present, it will be added.

Parameters:
constructor - the constructor to add the annotation to
annotation - the annotation to add
Throws:
IllegalArgumentException - if the annotation is null

removeFromConstructor

public AnnotatedTypeBuilder<X> removeFromConstructor(Constructor<X> constructor,
                                                     Class<? extends Annotation> annotationType)
Remove an annotation from the specified constructor.

Parameters:
constructor - the constructor to add the annotation to
annotation - the annotation to add
Throws:
IllegalArgumentException - if the annotationType is null or if the constructor is not currently declared on the type

removeFromConstructor

public AnnotatedTypeBuilder<X> removeFromConstructor(javax.enterprise.inject.spi.AnnotatedConstructor<X> constructor,
                                                     Class<? extends Annotation> annotationType)
Remove an annotation from the specified constructor.

Parameters:
constructor - the constructor to add the annotation to
annotation - the annotation to add
Throws:
IllegalArgumentException - if the annotationType is null, if the annotation does not exist on the type or if the constructor is not currently declared on the type

addToConstructorParameter

public AnnotatedTypeBuilder<X> addToConstructorParameter(Constructor<X> constructor,
                                                         int position,
                                                         Annotation annotation)
Add an annotation to the specified constructor parameter. If the constructor is not already present, it will be added. If the constructor parameter is not already present, it will be added.

Parameters:
method - the constructor 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

removeFromConstructorParameter

public AnnotatedTypeBuilder<X> removeFromConstructorParameter(Constructor<X> constructor,
                                                              int position,
                                                              Class<? extends Annotation> annotationType)
Remove an annotation from the specified constructor parameter.

Parameters:
method - the constructor 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 constructor is not currently declared on the type or if the parameter is not declared on the constructor

removeFromParameter

public AnnotatedTypeBuilder<X> removeFromParameter(javax.enterprise.inject.spi.AnnotatedParameter<? super X> parameter,
                                                   Class<? extends Annotation> annotationType)
Remove an annotation from the specified parameter.

Parameters:
parameter - the parameter to remove the annotation from
annotationType - the annotation type to remove
Throws:
IllegalArgumentException - 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 method

addToParameter

public AnnotatedTypeBuilder<X> addToParameter(javax.enterprise.inject.spi.AnnotatedParameter<? super X> parameter,
                                              Annotation annotation)
Add an annotation to the specified parameter. If the callable which declares the parameter is not already present, it will be added. If the parameter is not already present on the callable, it will be added.

Parameters:
parameter - the parameter to add the annotation to
annotation - the annotation to add
Throws:
IllegalArgumentException - if the annotation is null or if the parameter is not declared on either a constructor or a method

removeFromAll

public AnnotatedTypeBuilder<X> removeFromAll(Class<? extends Annotation> annotationType)
Remove annotations from the type, and all of it's members. If an annotation of the specified type appears on the type declaration, or any of it's members it will be removed.

Parameters:
annotationType - the type of annotation to remove
Throws:
IllegalArgumentException - if the annotationType is null

redefine

public <A extends Annotation> AnnotatedTypeBuilder<X> redefine(Class<A> annotationType,
                                                               AnnotationRedefiner<A> redefinition)
Redefine any annotations of the specified type. The redefinition callback will be invoked for any annotation on the type definition or any of it's members.

Parameters:
annotationType - the type of the annotation for which to call the redefinition
redefinition - the redefiniton callback
Throws:
IllegalArgumentException - if the annotationType or redefinition is null

redefineAnnotationBuilder

protected <A extends Annotation> void redefineAnnotationBuilder(Class<A> annotationType,
                                                                AnnotationRedefiner<A> redefinition,
                                                                AnnotatedElement annotated,
                                                                Type baseType,
                                                                AnnotationBuilder builder,
                                                                String elementName)

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.


overrideFieldType

public void overrideFieldType(Field field,
                              Type type)
Override the declared type of a field

Parameters:
field - the field to override the type on
type - the new type of the field
Throws:
IllegalArgumentException - if field or type is null

overrideFieldType

public void overrideFieldType(javax.enterprise.inject.spi.AnnotatedField<? super X> field,
                              Type type)
Override the declared type of a field

Parameters:
field - the field to override the type on
type - the new type of the field
Throws:
IllegalArgumentException - if field or type is null

overrideMethodParameterType

public AnnotatedTypeBuilder<X> overrideMethodParameterType(Method method,
                                                           int position,
                                                           Type type)
Override the declared type of a method parameter

Parameters:
method - the method to override the parameter type on
position - the position of the parameter to override the type on
type - the new type of the parameter
Throws:
IllegalArgumentException - if parameter or type is null

overrideConstructorParameterType

public AnnotatedTypeBuilder<X> overrideConstructorParameterType(Constructor<X> constructor,
                                                                int position,
                                                                Type type)
Override the declared type of a constructor parameter

Parameters:
constructor - the constructor to override the parameter type on
position - the position of the parameter to override the type on
type - the new type of the parameter
Throws:
IllegalArgumentException - if parameter or type is null

overrideParameterType

public AnnotatedTypeBuilder<X> overrideParameterType(javax.enterprise.inject.spi.AnnotatedParameter<? super X> parameter,
                                                     Type type)

getJavaClass

public Class<X> getJavaClass()

setJavaClass

public AnnotatedTypeBuilder<X> setJavaClass(Class<X> javaClass)


Copyright © 2008-2011 Seam Framework. All Rights Reserved.