org.springframework.roo.classpath.layers
Class MemberTypeAdditions

java.lang.Object
  extended by org.springframework.roo.classpath.layers.MemberTypeAdditions

public class MemberTypeAdditions
extends Object

The required additions to a given type in order to invoke a given application layer method, e.g. findAll(). Instances are immutable.

Since:
1.2.0
Author:
Stefan Schmidt, Andrew Swan

Constructor Summary
MemberTypeAdditions(ClassOrInterfaceTypeDetailsBuilder builder, String methodName, String methodCall, boolean isStatic, List<MethodParameter> methodParameters)
          Constructor that takes a pre-built method call.
 
Method Summary
 void copyAdditionsTo(AbstractMemberHoldingTypeDetailsBuilder<?> targetBuilder, ClassOrInterfaceTypeDetails governorClassOrInterfaceTypeDetails)
          Copies this instance's additions (if any) into the given builder
static MemberTypeAdditions getInstance(ClassOrInterfaceTypeDetailsBuilder builder, String targetName, String methodName, boolean isStatic, List<MethodParameter> parameters)
          Factory method that builds the method call from the given target, method, and list of parameter names.
static MemberTypeAdditions getInstance(ClassOrInterfaceTypeDetailsBuilder builder, String targetName, String methodName, boolean isStatic, MethodParameter... parameters)
          Factory method that builds the method call from the given target, method, and array of parameter names.
 FieldMetadata getInvokedField()
          Returns the field on which this method is invoked
 String getMethodCall()
          Returns the snippet of Java code that calls the method in question, for example "personService.findAll()".
 String getMethodName()
          Returns the bare name of the invoked method
 List<MethodParameter> getMethodParameters()
          Returns the parameters taken by the invoked method
 boolean isStatic()
          Indicates whether this is a static method call
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MemberTypeAdditions

public MemberTypeAdditions(ClassOrInterfaceTypeDetailsBuilder builder,
                           String methodName,
                           String methodCall,
                           boolean isStatic,
                           List<MethodParameter> methodParameters)
Constructor that takes a pre-built method call.

Parameters:
builder - stores any changes the caller should make in order to make the given method call, e.g. the field that is the method target; can be null if the caller requires no changes other than the given method call
methodName - the bare name of the method being invoked (required)
methodCall - a valid Java snippet that calls the method, including any required target and parameters, for example "foo.bar(baz)" (required)
isStatic - whether the invoked method is static
methodParameters - the parameters taken by the invoked method (can be null)
Method Detail

getInstance

public static MemberTypeAdditions getInstance(ClassOrInterfaceTypeDetailsBuilder builder,
                                              String targetName,
                                              String methodName,
                                              boolean isStatic,
                                              List<MethodParameter> parameters)
Factory method that builds the method call from the given target, method, and list of parameter names.

Parameters:
builder - stores any changes the caller should make in order to make the given method call, e.g. the field that is the method target (required)
targetName - the name of the object or class on which the method is being invoked (if not blank, must be a valid Java name)
methodName - the name of the method being invoked (must be a valid Java name)
isStatic - whether the invoked method is static
parameterNames - the names of any parameters passed to the method (required)

getInstance

public static MemberTypeAdditions getInstance(ClassOrInterfaceTypeDetailsBuilder builder,
                                              String targetName,
                                              String methodName,
                                              boolean isStatic,
                                              MethodParameter... parameters)
Factory method that builds the method call from the given target, method, and array of parameter names.

Parameters:
builder - stores any changes the caller should make in order to make the given method call, e.g. the field that is the method target (required)
targetName - the name of the object or class on which the method is being invoked (if not blank, must be a valid Java name)
methodName - the name of the method being invoked (must be a valid Java name)
isStatic - whether the invoked method is static
parameterNames - the names of any parameters passed to the method (required)

copyAdditionsTo

public void copyAdditionsTo(AbstractMemberHoldingTypeDetailsBuilder<?> targetBuilder,
                            ClassOrInterfaceTypeDetails governorClassOrInterfaceTypeDetails)
Copies this instance's additions (if any) into the given builder

Parameters:
targetBuilder - the ITD builder to receive the additions (required)
governorClassOrInterfaceTypeDetails - the ClassOrInterfaceTypeDetails of the governor (required)

getInvokedField

public FieldMetadata getInvokedField()
Returns the field on which this method is invoked

Returns:
null if it's a static method call
Throws:
IllegalStateException - if there's more than one field in the builder

getMethodCall

public String getMethodCall()
Returns the snippet of Java code that calls the method in question, for example "personService.findAll()".

Returns:
a non-blank String

getMethodName

public String getMethodName()
Returns the bare name of the invoked method

Returns:
a non-blank name

getMethodParameters

public List<MethodParameter> getMethodParameters()
Returns the parameters taken by the invoked method

Returns:
a non-null copy of this list

isStatic

public boolean isStatic()
Indicates whether this is a static method call

Returns:
see above

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2009–2015. All rights reserved.