Lombok - v0.10.1

lombok.core.handlers
Class TransformationsUtil

java.lang.Object
  extended by lombok.core.handlers.TransformationsUtil

public class TransformationsUtil
extends 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).


Field Summary
static Pattern NON_NULL_PATTERN
           
static Pattern NULLABLE_PATTERN
           
static Pattern PRIMITIVE_TYPE_NAME_PATTERN
           
 
Method Summary
static List<String> toAllGetterNames(CharSequence fieldName, boolean isBoolean)
          Returns all names of methods that would represent the getter for a field with the provided name.
static List<String> toAllSetterNames(CharSequence fieldName, boolean isBoolean)
          Returns all names of methods that would represent the setter for a field with the provided name.
static String toGetterName(CharSequence fieldName, boolean isBoolean)
          Generates a getter name from a given field name.
static String toSetterName(CharSequence fieldName, boolean isBoolean)
          Generates a setter name from a given field name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PRIMITIVE_TYPE_NAME_PATTERN

public static final Pattern PRIMITIVE_TYPE_NAME_PATTERN

NON_NULL_PATTERN

public static final Pattern NON_NULL_PATTERN

NULLABLE_PATTERN

public static final Pattern NULLABLE_PATTERN
Method Detail

toGetterName

public static String toGetterName(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 '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 String toSetterName(CharSequence fieldName,
                                  boolean isBoolean)
Generates a setter 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. Note that if the field is boolean and starts with 'is' followed by a non-lowercase letter, the 'is' is stripped and replaced with 'set'.

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.

toAllGetterNames

public static List<String> toAllGetterNames(CharSequence fieldName,
                                            boolean isBoolean)
Returns all names of methods that would represent the getter for a field with the provided name. For example if isBoolean is true, then a field named isRunning would produce:
[isRunning, getRunning, isIsRunning, getIsRunning]

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.

toAllSetterNames

public static List<String> toAllSetterNames(CharSequence fieldName,
                                            boolean isBoolean)
Returns all names of methods that would represent the setter for a field with the provided name. For example if isBoolean is true, then a field named isRunning would produce:
[setRunning, setIsRunning]

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.

Lombok - v0.10.1

Copyright © 2009-2010 Reinier Zwitserloot, Roel Spilker and Robbert Jan Grootjans, licensed under the MIT licence.