org.springframework.roo.classpath.details
Class BeanInfoUtils

java.lang.Object
  extended by org.springframework.roo.classpath.details.BeanInfoUtils

public final class BeanInfoUtils
extends Object

Provides utility methods for querying JavaBeans.

Since:
1.1.1
Author:
Ben Alex

Method Summary
static org.springframework.roo.model.JavaSymbolName getAccessorMethodName(FieldMetadata field)
          Returns the accessor name for the given field.
static org.springframework.roo.model.JavaSymbolName getAccessorMethodName(org.springframework.roo.model.JavaSymbolName fieldName, org.springframework.roo.model.JavaType fieldType)
          Returns the accessor name for the given field name and field type.
static FieldMetadata getFieldForJavaBeanMethod(MemberDetails memberDetails, MethodMetadata method)
          Attempts to locate the field which is represented by the presented java bean method.
static FieldMetadata getFieldForPropertyName(MemberDetails memberDetails, org.springframework.roo.model.JavaSymbolName propertyName)
          Attempts to locate the field which is represented by the presented property name.
static org.springframework.roo.model.JavaSymbolName getMutatorMethodName(FieldMetadata field)
          Returns the mutator name for the given field.
static org.springframework.roo.model.JavaSymbolName getMutatorMethodName(org.springframework.roo.model.JavaSymbolName fieldName)
          Returns the mutator name for the given field name.
static org.springframework.roo.model.JavaSymbolName getPropertyNameForJavaBeanMethod(MethodMetadata method)
          Obtains the property name for the specified JavaBean accessor or mutator method.
static boolean hasAccessorAndMutator(FieldMetadata field, MemberDetails memberDetails)
          Attempts to locate an accessor and a mutator method for a given field.
static boolean isAccessorMethod(MethodMetadata method)
          Indicates if the presented method compiles with the JavaBean conventions around accessor methods (public, "set" or "is", 0 args etc).
static boolean isEntityReasonablyNamed(org.springframework.roo.model.JavaType entity)
          Determines whether the presented entity is a test class or not.
static boolean isMutatorMethod(MethodMetadata method)
          Indicates if the presented method compiles with the JavaBean conventions around mutator methods (public, "set", 1 arg etc).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getAccessorMethodName

public static org.springframework.roo.model.JavaSymbolName getAccessorMethodName(FieldMetadata field)
Returns the accessor name for the given field.

Parameters:
field - the field to determine the accessor name
Returns:
the accessor method name

getAccessorMethodName

public static org.springframework.roo.model.JavaSymbolName getAccessorMethodName(org.springframework.roo.model.JavaSymbolName fieldName,
                                                                                 org.springframework.roo.model.JavaType fieldType)
Returns the accessor name for the given field name and field type.

Parameters:
fieldName - the field name used to determine the accessor name
fieldType - the field type
Returns:
the accessor method name

getFieldForJavaBeanMethod

public static FieldMetadata getFieldForJavaBeanMethod(MemberDetails memberDetails,
                                                      MethodMetadata method)
Attempts to locate the field which is represented by the presented java bean method.

Not every JavaBean getter or setter actually backs to a field with an identical name. In such cases, null will be returned.

Parameters:
memberDetails - the member holders to scan (required)
method - the method name (required)
Returns:
the field if found, or null if it could not be found

getFieldForPropertyName

public static FieldMetadata getFieldForPropertyName(MemberDetails memberDetails,
                                                    org.springframework.roo.model.JavaSymbolName propertyName)
Attempts to locate the field which is represented by the presented property name.

Not every JavaBean getter or setter actually backs to a field with an identical name. In such cases, null will be returned.

Parameters:
memberDetails - the member holders to scan (required)
propertyName - the property name (required)
Returns:
the field if found, or null if it could not be found

getMutatorMethodName

public static org.springframework.roo.model.JavaSymbolName getMutatorMethodName(FieldMetadata field)
Returns the mutator name for the given field.

Parameters:
field - the field used to determine the accessor name
Returns:
the mutator method name

getMutatorMethodName

public static org.springframework.roo.model.JavaSymbolName getMutatorMethodName(org.springframework.roo.model.JavaSymbolName fieldName)
Returns the mutator name for the given field name.

Parameters:
fieldName - the field name used to determine the accessor name
Returns:
the mutator method name

getPropertyNameForJavaBeanMethod

public static org.springframework.roo.model.JavaSymbolName getPropertyNameForJavaBeanMethod(MethodMetadata method)
Obtains the property name for the specified JavaBean accessor or mutator method. This is determined by discarding the first 2 or 3 letters of the method name (depending whether it is a "get", "set" or "is" method). There is no special searching back to the actual field name.

Parameters:
method - to search (required, and must be a "get", "set" or "is" method)
Returns:
the name of the property (never returned null)

hasAccessorAndMutator

public static boolean hasAccessorAndMutator(FieldMetadata field,
                                            MemberDetails memberDetails)
Attempts to locate an accessor and a mutator method for a given field.

Not every JavaBean getter or setter actually backs to a field with an identical name. In such cases, false will be returned.

Parameters:
field - the member holders to scan (required)
memberDetails - the member details to scan
Returns:
true if an accessor and a mutator are present, or false otherwise

isAccessorMethod

public static boolean isAccessorMethod(MethodMetadata method)
Indicates if the presented method compiles with the JavaBean conventions around accessor methods (public, "set" or "is", 0 args etc).

Parameters:
method - to evaluate (required)
Returns:
true if the presented method is an accessor, otherwise false

isEntityReasonablyNamed

public static boolean isEntityReasonablyNamed(org.springframework.roo.model.JavaType entity)
Determines whether the presented entity is a test class or not.

Parameters:
entity - the type to test
Returns:
true if the entity is likely not a test class, otherwise false

isMutatorMethod

public static boolean isMutatorMethod(MethodMetadata method)
Indicates if the presented method compiles with the JavaBean conventions around mutator methods (public, "set", 1 arg etc).

Parameters:
method - to evaluate (required)
Returns:
true if the presented method is a mutator, otherwise false


Copyright © 2009–2015. All rights reserved.