public final class Conventions extends Object
| Modifier and Type | Method and Description |
|---|---|
static String |
attributeNameToPropertyName(String attributeName)
Convert
Strings in attribute name format (e.g. |
static String |
getQualifiedAttributeName(Class<?> enclosingClass,
String attributeName)
Return an attribute name qualified by the given enclosing
Class. |
static String |
getVariableName(Object value)
Determine the conventional variable name for the supplied
Object
based on its concrete type. |
static String |
getVariableNameForParameter(MethodParameter parameter)
Determine the conventional variable name for the given parameter taking
the generic collection type, if any, into account.
|
static String |
getVariableNameForReturnType(Method method)
Determine the conventional variable name for the return type of the
given method, taking the generic collection type, if any, into account.
|
static String |
getVariableNameForReturnType(Method method,
Class<?> resolvedType,
Object value)
Determine the conventional variable name for the return type of the given
method, taking the generic collection type, if any, into account, falling
back on the given return value if the method declaration is not specific
enough, e.g.
|
static String |
getVariableNameForReturnType(Method method,
Object value)
Determine the conventional variable name for the return type of the given
method, taking the generic collection type, if any, into account, falling
back on the given actual return value if the method declaration is not
specific enough, e.g.
|
public static String getVariableName(Object value)
Object
based on its concrete type. The convention used is to return the
un-capitalized short name of the Class, according to JavaBeans
property naming rules.
For example:
com.myapp.Product becomes "product"
com.myapp.MyProduct becomes "myProduct"
com.myapp.UKProduct becomes "UKProduct"
For arrays the pluralized version of the array component type is used.
For Collections an attempt is made to 'peek ahead' to determine
the component type and return its pluralized version.
value - the value to generate a variable name forpublic static String getVariableNameForParameter(MethodParameter parameter)
As of 5.0 this method supports reactive types:
Mono<com.myapp.Product> becomes "productMono"
Flux<com.myapp.MyProduct> becomes "myProductFlux"
Observable<com.myapp.MyProduct> becomes "myProductObservable"
parameter - the method or constructor parameterpublic static String getVariableNameForReturnType(Method method)
method - the method to generate a variable name forpublic static String getVariableNameForReturnType(Method method, @Nullable Object value)
Object return type or untyped collection.method - the method to generate a variable name forvalue - the return value (may be null if not available)public static String getVariableNameForReturnType(Method method, Class<?> resolvedType, @Nullable Object value)
Object return type or untyped collection.
As of 5.0 this method supports reactive types:
Mono<com.myapp.Product> becomes "productMono"
Flux<com.myapp.MyProduct> becomes "myProductFlux"
Observable<com.myapp.MyProduct> becomes "myProductObservable"
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 String attributeNameToPropertyName(String attributeName)
Strings in attribute name format (e.g. lowercase, hyphens
separating words) into property name format (camel-case). For example
transaction-manager becomes "transactionManager".