|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.core.Conventions
public abstract class Conventions
Provides methods to support various naming and other conventions used throughout the framework. Mainly for internal use within the framework.
Field Summary | |
---|---|
private static java.util.Set<java.lang.Class> |
ignoredInterfaces
Set of interfaces that are supposed to be ignored when searching for the 'primary' interface of a proxy. |
private static java.lang.String |
PLURAL_SUFFIX
Suffix added to names when using arrays. |
Constructor Summary | |
---|---|
Conventions()
|
Method Summary | |
---|---|
static java.lang.String |
attributeNameToPropertyName(java.lang.String attributeName)
Convert String s in attribute name format (lowercase, hyphens separating words)
into property name format (camel-cased). |
private static java.lang.Class |
getClassForValue(java.lang.Object value)
Determines the class to use for naming a variable that contains the given value. |
static java.lang.String |
getQualifiedAttributeName(java.lang.Class enclosingClass,
java.lang.String attributeName)
Return an attribute name qualified by the supplied enclosing Class . |
static java.lang.String |
getVariableName(java.lang.Object value)
Determine the conventional variable name for the supplied Object based on its concrete type. |
static java.lang.String |
getVariableNameForParameter(MethodParameter parameter)
Determine the conventional variable name for the supplied parameter, taking the generic collection type (if any) into account. |
static java.lang.String |
getVariableNameForReturnType(java.lang.reflect.Method method)
Determine the conventional variable name for the return type of the supplied method, taking the generic collection type (if any) into account. |
static java.lang.String |
getVariableNameForReturnType(java.lang.reflect.Method method,
java.lang.Class resolvedType,
java.lang.Object value)
Determine the conventional variable name for the return type of the supplied method, taking the generic collection type (if any) into account, falling back to the given return value if the method declaration is not specific enough (i.e. |
static java.lang.String |
getVariableNameForReturnType(java.lang.reflect.Method method,
java.lang.Object value)
Determine the conventional variable name for the return type of the supplied method, taking the generic collection type (if any) into account, falling back to the given return value if the method declaration is not specific enough (i.e. |
private static java.lang.Object |
peekAhead(java.util.Collection collection)
Retrieves the Class of an element in the Collection . |
private static java.lang.String |
pluralize(java.lang.String name)
Pluralize the given name. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final java.lang.String PLURAL_SUFFIX
private static final java.util.Set<java.lang.Class> ignoredInterfaces
Constructor Detail |
---|
public Conventions()
Method Detail |
---|
public static java.lang.String getVariableName(java.lang.Object value)
Object
based on its concrete type. The convention
used is to return the uncapitalized short name of the Class
,
according to JavaBeans property naming rules: So,
com.myapp.Product
becomes product
;
com.myapp.MyProduct
becomes myProduct
;
com.myapp.UKProduct
becomes UKProduct
.
For arrays, we use the pluralized version of the array component type.
For Collection
s we attempt to 'peek ahead' in the
Collection
to determine the component type and
return the pluralized version of that component type.
value
- the value to generate a variable name for
public static java.lang.String getVariableNameForParameter(MethodParameter parameter)
parameter
- the method or constructor parameter to generate a variable name for
public static java.lang.String getVariableNameForReturnType(java.lang.reflect.Method method)
method
- the method to generate a variable name for
public static java.lang.String getVariableNameForReturnType(java.lang.reflect.Method method, java.lang.Object value)
Object
or as untyped collection).
method
- the method to generate a variable name forvalue
- the return value (may be null
if not available)
public static java.lang.String getVariableNameForReturnType(java.lang.reflect.Method method, java.lang.Class resolvedType, java.lang.Object value)
Object
or as untyped collection).
method
- the method to generate a variable name forresolvedType
- the resolved return type of the methodvalue
- the return value (may be null
if not available)
public static java.lang.String attributeNameToPropertyName(java.lang.String attributeName)
String
s in attribute name format (lowercase, hyphens separating words)
into property name format (camel-cased). For example, transaction-manager
is
converted into transactionManager
.
public static java.lang.String getQualifiedAttributeName(java.lang.Class enclosingClass, java.lang.String attributeName)
Class
. For example,
the attribute name 'foo
' qualified by Class
'com.myapp.SomeClass
'
would be 'com.myapp.SomeClass.foo
'
private static java.lang.Class getClassForValue(java.lang.Object value)
Will return the class of the given value, except when encountering a JDK proxy, in which case it will determine the 'primary' interface implemented by that proxy.
value
- the value to check
private static java.lang.String pluralize(java.lang.String name)
private static java.lang.Object peekAhead(java.util.Collection collection)
Class
of an element in the Collection
.
The exact element for which the Class
is retreived will depend
on the concrete Collection
implementation.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |