Class CamelCaser

java.lang.Object
com.randomnoun.common.CamelCaser

public class CamelCaser extends Object
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 Details

    • CamelCaser

      public CamelCaser(List<String> nameList)
      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

      public CamelCaser(String camelCaseNames)
      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

      public String renameString(String string)
      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

      public void renameMap(Map<String,Object> map)
      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

      public void renameList(List<? extends Object> list)
      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.