org.springframework.roo.classpath.itd
Class AbstractItdTypeDetailsProvidingMetadataItem

java.lang.Object
  extended by org.springframework.roo.metadata.AbstractMetadataItem
      extended by org.springframework.roo.classpath.itd.AbstractItdTypeDetailsProvidingMetadataItem
All Implemented Interfaces:
ItdTypeDetailsProvidingMetadataItem, MemberHoldingTypeDetailsMetadataItem<ItdTypeDetails>, org.springframework.roo.metadata.MetadataItem

public abstract class AbstractItdTypeDetailsProvidingMetadataItem
extends org.springframework.roo.metadata.AbstractMetadataItem
implements ItdTypeDetailsProvidingMetadataItem

Abstract implementation of ItdTypeDetailsProvidingMetadataItem, which assumes the subclass will require a non-null ClassOrInterfaceTypeDetails representing the governor and wishes to build an ITD via the ItdTypeDetailsBuilder mechanism.

Since:
1.0
Author:
Ben Alex

Field Summary
protected  org.springframework.roo.model.JavaType aspectName
           
protected  ItdTypeDetailsBuilder builder
           
protected  org.springframework.roo.model.JavaType destination
           
protected  PhysicalTypeMetadata governorPhysicalTypeMetadata
           
protected  ClassOrInterfaceTypeDetails governorTypeDetails
           
protected  ItdTypeDetails itdTypeDetails
           
 
Fields inherited from class org.springframework.roo.metadata.AbstractMetadataItem
valid
 
Constructor Summary
protected AbstractItdTypeDetailsProvidingMetadataItem(String identifier, org.springframework.roo.model.JavaType aspectName, PhysicalTypeMetadata governorPhysicalTypeMetadata)
          Validates input and constructs a superclass that implements ItdTypeDetailsProvidingMetadataItem.
 
Method Summary
protected  void buildItd()
          Generates the ItdTypeDetails from the current contents of this instance's ItdTypeDetailsBuilder.
protected  void ensureGovernorExtends(org.springframework.roo.model.JavaType javaType)
          Ensures that the governor extends the given type, i.e. introduces that type as a supertype iff it's not already one
protected  void ensureGovernorImplements(org.springframework.roo.model.JavaType javaType)
          Ensures that the governor implements the given type.
protected  MethodMetadataBuilder getAccessorMethod(FieldMetadata field)
           
protected  MethodMetadataBuilder getAccessorMethod(FieldMetadata field, InvocableMemberBodyBuilder bodyBuilder)
           
protected  MethodMetadataBuilder getAccessorMethod(org.springframework.roo.model.JavaSymbolName fieldName, org.springframework.roo.model.JavaType fieldType)
           
protected  MethodMetadataBuilder getAccessorMethod(org.springframework.roo.model.JavaSymbolName fieldName, org.springframework.roo.model.JavaType fieldType, InvocableMemberBodyBuilder bodyBuilder)
           
 org.springframework.roo.model.JavaType getAspectName()
          Return current aspect name
protected  FieldMetadataBuilder getField(int modifier, org.springframework.roo.model.JavaSymbolName fieldName, org.springframework.roo.model.JavaType fieldType, String fieldInitializer)
          Convenience method for returning a simple private field based on the field name, type, and initializer.
protected  FieldMetadataBuilder getField(org.springframework.roo.model.JavaSymbolName fieldName, org.springframework.roo.model.JavaType fieldType)
           
protected  MethodMetadata getGovernorMethod(org.springframework.roo.model.JavaSymbolName methodName, org.springframework.roo.model.JavaType... parameterTypes)
          Returns the given method of the governor.
protected  MethodMetadata getGovernorMethod(org.springframework.roo.model.JavaSymbolName methodName, List<org.springframework.roo.model.JavaType> parameterTypes)
          Returns the given method of the governor.
 ItdTypeDetails getMemberHoldingTypeDetails()
          Obtains the MemberHoldingTypeDetails, if available.
protected  MethodMetadataBuilder getMethod(int modifier, org.springframework.roo.model.JavaSymbolName methodName, org.springframework.roo.model.JavaType returnType, List<org.springframework.roo.model.JavaType> parameterTypes, List<org.springframework.roo.model.JavaSymbolName> parameterNames, InvocableMemberBodyBuilder bodyBuilder)
          Returns a public method given the method name, return type, parameter types, parameter names, and method body.
protected  MethodMetadataBuilder getMutatorMethod(org.springframework.roo.model.JavaSymbolName fieldName, org.springframework.roo.model.JavaType parameterType)
           
protected  MethodMetadataBuilder getMutatorMethod(org.springframework.roo.model.JavaSymbolName fieldName, org.springframework.roo.model.JavaType parameterType, InvocableMemberBodyBuilder bodyBuilder)
           
protected  AnnotationMetadata getTypeAnnotation(org.springframework.roo.model.JavaType annotationType)
          Returns the metadata for an annotation of the given type if the governor does not already have one.
protected  boolean governorHasMethod(org.springframework.roo.model.JavaSymbolName methodName, org.springframework.roo.model.JavaType... parameterTypes)
          Indicates whether the governor has a method with the given signature.
protected  boolean governorHasMethod(org.springframework.roo.model.JavaSymbolName methodName, List<org.springframework.roo.model.JavaType> parameterTypes)
          Indicates whether the governor has a method with the given signature.
protected  boolean governorHasMethodWithSameName(org.springframework.roo.model.JavaSymbolName methodName)
          Indicates whether the governor has a method with the given method name regardless of method parameters.
 int hashCode()
           
protected  boolean isImplementing(ClassOrInterfaceTypeDetails clazz, org.springframework.roo.model.JavaType interfaceTarget)
          Determines if the presented class (or any of its superclasses) implements the target interface.
 String toString()
           
 
Methods inherited from class org.springframework.roo.metadata.AbstractMetadataItem
getId, isValid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.springframework.roo.metadata.MetadataItem
getId, isValid
 

Field Detail

aspectName

protected org.springframework.roo.model.JavaType aspectName

builder

protected ItdTypeDetailsBuilder builder

destination

protected org.springframework.roo.model.JavaType destination

governorPhysicalTypeMetadata

protected PhysicalTypeMetadata governorPhysicalTypeMetadata

governorTypeDetails

protected ClassOrInterfaceTypeDetails governorTypeDetails

itdTypeDetails

protected ItdTypeDetails itdTypeDetails
Constructor Detail

AbstractItdTypeDetailsProvidingMetadataItem

protected AbstractItdTypeDetailsProvidingMetadataItem(String identifier,
                                                      org.springframework.roo.model.JavaType aspectName,
                                                      PhysicalTypeMetadata governorPhysicalTypeMetadata)
Validates input and constructs a superclass that implements ItdTypeDetailsProvidingMetadataItem.

Exposes the ClassOrInterfaceTypeDetails of the governor, if available. If they are not available, ensures AbstractMetadataItem.isValid() returns false.

Subclasses should generally return immediately if AbstractMetadataItem.isValid() is false. Subclasses should also attempt to set the itdTypeDetails to contain the output of their ITD where AbstractMetadataItem.isValid() is true.

Parameters:
identifier - the identifier for this item of metadata (required)
aspectName - the Java type of the ITD (required)
governorPhysicalTypeMetadata - the governor, which is expected to contain a ClassOrInterfaceTypeDetails (required)
Method Detail

buildItd

protected void buildItd()
Generates the ItdTypeDetails from the current contents of this instance's ItdTypeDetailsBuilder.

Since:
1.2.0

ensureGovernorExtends

protected final void ensureGovernorExtends(org.springframework.roo.model.JavaType javaType)
Ensures that the governor extends the given type, i.e. introduces that type as a supertype iff it's not already one

Parameters:
javaType - the type to extend (required)
Since:
1.2.0

ensureGovernorImplements

protected final void ensureGovernorImplements(org.springframework.roo.model.JavaType javaType)
Ensures that the governor implements the given type.

Parameters:
javaType - the type to implement (required)
Since:
1.2.0

getAccessorMethod

protected MethodMetadataBuilder getAccessorMethod(FieldMetadata field)

getAccessorMethod

protected MethodMetadataBuilder getAccessorMethod(FieldMetadata field,
                                                  InvocableMemberBodyBuilder bodyBuilder)

getAccessorMethod

protected MethodMetadataBuilder getAccessorMethod(org.springframework.roo.model.JavaSymbolName fieldName,
                                                  org.springframework.roo.model.JavaType fieldType)

getAccessorMethod

protected MethodMetadataBuilder getAccessorMethod(org.springframework.roo.model.JavaSymbolName fieldName,
                                                  org.springframework.roo.model.JavaType fieldType,
                                                  InvocableMemberBodyBuilder bodyBuilder)

getField

protected FieldMetadataBuilder getField(int modifier,
                                        org.springframework.roo.model.JavaSymbolName fieldName,
                                        org.springframework.roo.model.JavaType fieldType,
                                        String fieldInitializer)
Convenience method for returning a simple private field based on the field name, type, and initializer.

Parameters:
fieldName - the field name
fieldType - the field type
fieldInitializer - the string to initialize the field with
Returns:
null if the field exists on the governor, otherwise a new field with the given field name and type

getField

protected FieldMetadataBuilder getField(org.springframework.roo.model.JavaSymbolName fieldName,
                                        org.springframework.roo.model.JavaType fieldType)

getGovernorMethod

protected MethodMetadata getGovernorMethod(org.springframework.roo.model.JavaSymbolName methodName,
                                           org.springframework.roo.model.JavaType... parameterTypes)
Returns the given method of the governor.

Parameters:
methodName - the name of the method for which to search
parameterTypes - the method's parameter types
Returns:
null if there was no such method
Since:
1.2.0
See Also:
MemberFindingUtils.getDeclaredMethod(org.springframework.roo.classpath.details.MemberHoldingTypeDetails, JavaSymbolName, List)

getGovernorMethod

protected MethodMetadata getGovernorMethod(org.springframework.roo.model.JavaSymbolName methodName,
                                           List<org.springframework.roo.model.JavaType> parameterTypes)
Returns the given method of the governor.

Parameters:
methodName - the name of the method for which to search
parameterTypes - the method's parameter types
Returns:
null if there was no such method
Since:
1.2.0 (previously called methodExists)
See Also:
MemberFindingUtils.getDeclaredMethod(org.springframework.roo.classpath.details.MemberHoldingTypeDetails, JavaSymbolName, List)

getMemberHoldingTypeDetails

public final ItdTypeDetails getMemberHoldingTypeDetails()
Description copied from interface: MemberHoldingTypeDetailsMetadataItem
Obtains the MemberHoldingTypeDetails, if available.

An MemberHoldingTypeDetails should be returned even if no members should be introduced. Only return null if there was a failure during parsing or other unexpected condition.

Specified by:
getMemberHoldingTypeDetails in interface MemberHoldingTypeDetailsMetadataItem<ItdTypeDetails>
Returns:
the details, or null if the details are unavailable or no member details are required

getMethod

protected MethodMetadataBuilder getMethod(int modifier,
                                          org.springframework.roo.model.JavaSymbolName methodName,
                                          org.springframework.roo.model.JavaType returnType,
                                          List<org.springframework.roo.model.JavaType> parameterTypes,
                                          List<org.springframework.roo.model.JavaSymbolName> parameterNames,
                                          InvocableMemberBodyBuilder bodyBuilder)
Returns a public method given the method name, return type, parameter types, parameter names, and method body.

Parameters:
methodName - the method name
returnType - the return type
parameterTypes - a list of parameter types
parameterNames - a list of parameter names
bodyBuilder - the method body
Returns:
null if the method exists on the governor, otherwise a new method is returned

getMutatorMethod

protected MethodMetadataBuilder getMutatorMethod(org.springframework.roo.model.JavaSymbolName fieldName,
                                                 org.springframework.roo.model.JavaType parameterType)

getMutatorMethod

protected MethodMetadataBuilder getMutatorMethod(org.springframework.roo.model.JavaSymbolName fieldName,
                                                 org.springframework.roo.model.JavaType parameterType,
                                                 InvocableMemberBodyBuilder bodyBuilder)

getTypeAnnotation

protected AnnotationMetadata getTypeAnnotation(org.springframework.roo.model.JavaType annotationType)
Returns the metadata for an annotation of the given type if the governor does not already have one.

Parameters:
annotationType - the type of annotation to generate (required)
Returns:
null if the governor already has that annotation

governorHasMethod

protected boolean governorHasMethod(org.springframework.roo.model.JavaSymbolName methodName,
                                    org.springframework.roo.model.JavaType... parameterTypes)
Indicates whether the governor has a method with the given signature.

Parameters:
methodName - the name of the method for which to search
parameterTypes - the method's parameter types
Returns:
see above
Since:
1.2.0

governorHasMethod

protected boolean governorHasMethod(org.springframework.roo.model.JavaSymbolName methodName,
                                    List<org.springframework.roo.model.JavaType> parameterTypes)
Indicates whether the governor has a method with the given signature.

Parameters:
methodName - the name of the method for which to search
parameterTypes - the method's parameter types
Returns:
see above
Since:
1.2.1

governorHasMethodWithSameName

protected boolean governorHasMethodWithSameName(org.springframework.roo.model.JavaSymbolName methodName)
Indicates whether the governor has a method with the given method name regardless of method parameters.

Parameters:
methodName - the name of the method for which to search
Returns:
see above
Since:
1.2.0

hashCode

public int hashCode()
Overrides:
hashCode in class Object

isImplementing

protected boolean isImplementing(ClassOrInterfaceTypeDetails clazz,
                                 org.springframework.roo.model.JavaType interfaceTarget)
Determines if the presented class (or any of its superclasses) implements the target interface.

Parameters:
clazz - the cid to search
interfaceTarget - the interface to locate
Returns:
true if the class or any of its superclasses contains the specified interface

toString

public String toString()
Overrides:
toString in class Object

getAspectName

public org.springframework.roo.model.JavaType getAspectName()
Return current aspect name

Returns:


Copyright © 2009–2015. All rights reserved.