org.springframework.roo.classpath.details.annotations
Class AnnotationMetadataBuilder

java.lang.Object
  extended by org.springframework.roo.classpath.details.annotations.AnnotationMetadataBuilder
All Implemented Interfaces:
org.springframework.roo.model.Builder<AnnotationMetadata>

public class AnnotationMetadataBuilder
extends Object
implements org.springframework.roo.model.Builder<AnnotationMetadata>

Builder for AnnotationMetadata.

The "add" method will replace any existing annotation attribute with the same name, taking care to preserve its location.

Since:
1.1
Author:
Ben Alex, Andrew Swan

Field Summary
static AnnotationMetadata JPA_COLUMN_ANNOTATION
           
static AnnotationMetadata JPA_EMBEDDED_ANNOTATION
           
static AnnotationMetadata JPA_EMBEDDED_ID_ANNOTATION
           
static AnnotationMetadata JPA_ENUMERATED_ANNOTATION
           
static AnnotationMetadata JPA_ID_ANNOTATION
           
static AnnotationMetadata JPA_LOB_ANNOTATION
           
static AnnotationMetadata JPA_MANY_TO_MANY_ANNOTATION
           
static AnnotationMetadata JPA_MANY_TO_ONE_ANNOTATION
           
static AnnotationMetadata JPA_ONE_TO_MANY_ANNOTATION
           
static AnnotationMetadata JPA_ONE_TO_ONE_ANNOTATION
           
static AnnotationMetadata JPA_TRANSIENT_ANNOTATION
           
static AnnotationMetadata JPA_VERSION_ANNOTATION
           
 
Constructor Summary
AnnotationMetadataBuilder()
          Constructor.
AnnotationMetadataBuilder(AnnotationMetadata existing)
          Constructor for using an existing AnnotationMetadata as a baseline for building a new instance.
AnnotationMetadataBuilder(Class<?> annotationType)
          Constructor for no initial attribute values
AnnotationMetadataBuilder(org.springframework.roo.model.JavaType annotationType)
          Constructor for no initial attribute values
AnnotationMetadataBuilder(org.springframework.roo.model.JavaType annotationType, Collection<AnnotationAttributeValue<?>> attributeValues)
          Constructor that accepts an optional list of values
AnnotationMetadataBuilder(String annotationType)
          Constructor for no initial attribute values
 
Method Summary
 void addAttribute(AnnotationAttributeValue<?> value)
           
 void addBooleanAttribute(String key, boolean value)
           
 void addCharAttribute(String key, char value)
           
 void addClassAttribute(String key, org.springframework.roo.model.JavaType javaType)
          Adds an attribute with the given JavaType as its value
 void addClassAttribute(String key, String fullyQualifiedTypeName)
           
 void addDoubleAttribute(String key, double value, boolean floatingPrecisionOnly)
           
 void addEnumAttribute(String key, org.springframework.roo.model.EnumDetails details)
           
 void addEnumAttribute(String key, org.springframework.roo.model.JavaType javaType, org.springframework.roo.model.JavaSymbolName enumConstant)
           
 void addEnumAttribute(String key, org.springframework.roo.model.JavaType javaType, String enumConstant)
           
 void addEnumAttribute(String key, String fullyQualifiedTypeName, String enumConstant)
           
 void addIntegerAttribute(String key, int value)
           
 void addLongAttribute(String key, long value)
           
 void addStringAttribute(String key, String value)
           
 AnnotationMetadata build()
           
 org.springframework.roo.model.JavaType getAnnotationType()
           
 Map<String,AnnotationAttributeValue<?>> getAttributes()
           
 CommentStructure getCommentStructure()
           
static AnnotationMetadata getInstance(Class<?> annotationType)
          Returns the metadata for the existing annotation, with no attribute values
static AnnotationMetadata getInstance(org.springframework.roo.model.JavaType annotationType)
           
static AnnotationMetadataBuilder getInstance(org.springframework.roo.model.JavaType annotationType, Collection<AnnotationAttributeValue<?>> attributeValues)
           
static AnnotationMetadata getInstance(String annotationType)
          Returns the metadata for the existing annotation, with no attribute values
 void removeAttribute(String key)
           
 void setAnnotationType(org.springframework.roo.model.JavaType annotationType)
           
 void setAttributes(Collection<AnnotationAttributeValue<?>> attributeValues)
          Sets the attribute values
 void setCommentStructure(CommentStructure commentStructure)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JPA_COLUMN_ANNOTATION

public static final AnnotationMetadata JPA_COLUMN_ANNOTATION

JPA_EMBEDDED_ANNOTATION

public static final AnnotationMetadata JPA_EMBEDDED_ANNOTATION

JPA_EMBEDDED_ID_ANNOTATION

public static final AnnotationMetadata JPA_EMBEDDED_ID_ANNOTATION

JPA_ENUMERATED_ANNOTATION

public static final AnnotationMetadata JPA_ENUMERATED_ANNOTATION

JPA_ID_ANNOTATION

public static final AnnotationMetadata JPA_ID_ANNOTATION

JPA_LOB_ANNOTATION

public static final AnnotationMetadata JPA_LOB_ANNOTATION

JPA_MANY_TO_MANY_ANNOTATION

public static final AnnotationMetadata JPA_MANY_TO_MANY_ANNOTATION

JPA_MANY_TO_ONE_ANNOTATION

public static final AnnotationMetadata JPA_MANY_TO_ONE_ANNOTATION

JPA_ONE_TO_MANY_ANNOTATION

public static final AnnotationMetadata JPA_ONE_TO_MANY_ANNOTATION

JPA_ONE_TO_ONE_ANNOTATION

public static final AnnotationMetadata JPA_ONE_TO_ONE_ANNOTATION

JPA_TRANSIENT_ANNOTATION

public static final AnnotationMetadata JPA_TRANSIENT_ANNOTATION

JPA_VERSION_ANNOTATION

public static final AnnotationMetadata JPA_VERSION_ANNOTATION
Constructor Detail

AnnotationMetadataBuilder

public AnnotationMetadataBuilder()
Constructor. The caller must set the annotation type via setAnnotationType(JavaType) before calling build()


AnnotationMetadataBuilder

public AnnotationMetadataBuilder(AnnotationMetadata existing)
Constructor for using an existing AnnotationMetadata as a baseline for building a new instance.

Parameters:
existing - required

AnnotationMetadataBuilder

public AnnotationMetadataBuilder(Class<?> annotationType)
Constructor for no initial attribute values

Parameters:
annotationType - the annotation class (required)
Since:
1.2.0

AnnotationMetadataBuilder

public AnnotationMetadataBuilder(org.springframework.roo.model.JavaType annotationType)
Constructor for no initial attribute values

Parameters:
annotationType -

AnnotationMetadataBuilder

public AnnotationMetadataBuilder(org.springframework.roo.model.JavaType annotationType,
                                 Collection<AnnotationAttributeValue<?>> attributeValues)
Constructor that accepts an optional list of values

Parameters:
annotationType -
attributeValues - can be null

AnnotationMetadataBuilder

public AnnotationMetadataBuilder(String annotationType)
Constructor for no initial attribute values

Parameters:
annotationType - the fully-qualified name of the annotation type (required)
Method Detail

getInstance

public static AnnotationMetadata getInstance(Class<?> annotationType)
Returns the metadata for the existing annotation, with no attribute values

Parameters:
annotationType - the annotation type (required)
Returns:
a non-null instance
Since:
1.2.0

getInstance

public static AnnotationMetadata getInstance(org.springframework.roo.model.JavaType annotationType)

getInstance

public static AnnotationMetadataBuilder getInstance(org.springframework.roo.model.JavaType annotationType,
                                                    Collection<AnnotationAttributeValue<?>> attributeValues)

getInstance

public static AnnotationMetadata getInstance(String annotationType)
Returns the metadata for the existing annotation, with no attribute values

Parameters:
annotationType - the fully-qualified name of the annotation type (required)
Returns:
a non-null instance
Since:
1.2.0

addAttribute

public void addAttribute(AnnotationAttributeValue<?> value)

addBooleanAttribute

public void addBooleanAttribute(String key,
                                boolean value)

addCharAttribute

public void addCharAttribute(String key,
                             char value)

addClassAttribute

public void addClassAttribute(String key,
                              org.springframework.roo.model.JavaType javaType)
Adds an attribute with the given JavaType as its value

Parameters:
key - the attribute name (required)
javaType - the value (required)

addClassAttribute

public void addClassAttribute(String key,
                              String fullyQualifiedTypeName)

addDoubleAttribute

public void addDoubleAttribute(String key,
                               double value,
                               boolean floatingPrecisionOnly)

addEnumAttribute

public void addEnumAttribute(String key,
                             org.springframework.roo.model.EnumDetails details)

addEnumAttribute

public void addEnumAttribute(String key,
                             org.springframework.roo.model.JavaType javaType,
                             org.springframework.roo.model.JavaSymbolName enumConstant)

addEnumAttribute

public void addEnumAttribute(String key,
                             org.springframework.roo.model.JavaType javaType,
                             String enumConstant)

addEnumAttribute

public void addEnumAttribute(String key,
                             String fullyQualifiedTypeName,
                             String enumConstant)

addIntegerAttribute

public void addIntegerAttribute(String key,
                                int value)

addLongAttribute

public void addLongAttribute(String key,
                             long value)

addStringAttribute

public void addStringAttribute(String key,
                               String value)

build

public AnnotationMetadata build()
Specified by:
build in interface org.springframework.roo.model.Builder<AnnotationMetadata>

getAnnotationType

public org.springframework.roo.model.JavaType getAnnotationType()

getAttributes

public Map<String,AnnotationAttributeValue<?>> getAttributes()

removeAttribute

public void removeAttribute(String key)

setAnnotationType

public void setAnnotationType(org.springframework.roo.model.JavaType annotationType)

setAttributes

public void setAttributes(Collection<AnnotationAttributeValue<?>> attributeValues)
Sets the attribute values

Parameters:
attributeValues - the values to set; can be null for none

getCommentStructure

public CommentStructure getCommentStructure()

setCommentStructure

public void setCommentStructure(CommentStructure commentStructure)


Copyright © 2009–2015. All rights reserved.