Package com.randomnoun.common
Class CamelCaser
java.lang.Object
com.randomnoun.common.CamelCaser
This class is used to convert the Maps and Lists returned by Spring DAO into
camelCase versions, which can be used when dealing with some databases
that return all column names in upper case.
Maps and Lists passed to this object will be modified in-place.
This object should be considered thread-safe, i.e. many threads may use a single instance of this object at a time.
- Author:
- knoxg
-
Constructor Summary
ConstructorsConstructorDescriptionCamelCaser
(String camelCaseNames) Creates a new CamelCaser objectCamelCaser
(List<String> nameList) Create a new map renamer. -
Method Summary
Modifier and TypeMethodDescriptionvoid
renameList
(List<? extends Object> list) Renames all the objects in a list.void
Renames all the keys in the map.renameString
(String string) Renames an individual string.
-
Constructor Details
-
CamelCaser
Create a new map renamer. The list supplied to this constructor contains a list of Strings that may be used as keys in the maps to be renamed. Each String is the camelCase version to return.- Parameters:
nameList
-
-
CamelCaser
Creates a new CamelCaser object- Parameters:
camelCaseNames
- A list of camelcased names, separated by commas.- Throws:
NullPointerException
- if there was a problem loading the resource property list, or the propertyKey does not exist in the resource.
-
-
Method Details
-
renameString
Renames an individual string. If the camelCase version of the string is not known, then it is returned without modification.- Parameters:
string
- The String to be renamed- Returns:
- The camelCase version of the String
-
renameMap
Renames all the keys in the map. The map may itself contain Maps and Lists, which will also be renamed.- Parameters:
map
- The map to rename
-
renameList
Renames all the objects in a list. Any Maps or Lists contained with the List will be recursed into.- Parameters:
list
- The list containing maps to rename.
-