lombok.core.handlers
Class TransformationsUtil
java.lang.Object
lombok.core.handlers.TransformationsUtil
public class TransformationsUtil
- extends java.lang.Object
Container for static utility methods useful for some of the standard lombok transformations, regardless of
target platform (e.g. useful for both javac and Eclipse lombok implementations).
|
Method Summary |
static java.util.List<java.lang.String> |
toAllGetterNames(java.lang.CharSequence fieldName,
boolean isBoolean)
|
static java.lang.String |
toGetterName(java.lang.CharSequence fieldName,
boolean isBoolean)
Generates a getter name from a given field name. |
static java.lang.String |
toSetterName(java.lang.CharSequence fieldName)
Generates a getter name from a given field name. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PRIMITIVE_TYPE_NAME_PATTERN
public static final java.util.regex.Pattern PRIMITIVE_TYPE_NAME_PATTERN
NON_NULL_PATTERN
public static final java.util.regex.Pattern NON_NULL_PATTERN
NULLABLE_PATTERN
public static final java.util.regex.Pattern NULLABLE_PATTERN
toGetterName
public static java.lang.String toGetterName(java.lang.CharSequence fieldName,
boolean isBoolean)
- Generates a getter name from a given field name.
Strategy:
First, pick a prefix. 'get' normally, but 'is' if
isBoolean is true.
Then, check if the first character of the field is lowercase. If so, check if the second character
exists and is title or upper case. If so, uppercase the first character. If not, titlecase the first character.
return the prefix plus the possibly title/uppercased first character, and the rest of the field name.
Note that for boolean fields, if the field starts with 'has', 'get', or 'is', and the character after that is
not a lowercase character, the field name is returned without changing any character's case and without
any prefix.
- Parameters:
fieldName - the name of the field.isBoolean - if the field is of type 'boolean'. For fields of type 'java.lang.Boolean', you should provide false.
toSetterName
public static java.lang.String toSetterName(java.lang.CharSequence fieldName)
- Generates a getter name from a given field name.
Strategy:
Check if the first character of the field is lowercase. If so, check if the second character
exists and is title or upper case. If so, uppercase the first character. If not, titlecase the first character.
return "set" plus the possibly title/uppercased first character, and the rest of the field name.
- Parameters:
fieldName - the name of the field.
toAllGetterNames
public static java.util.List<java.lang.String> toAllGetterNames(java.lang.CharSequence fieldName,
boolean isBoolean)
Copyright © 2009 Reinier Zwitserloot and Roel Spilker, licensed under the MIT licence.