Class NamingUtil


  • public class NamingUtil
    extends Object
    The NamingUtil class is used to create names for the properties of the entities.
    Author:
    iperdomo, mtaal
    • Field Detail

      • ILLEGAL_ENTITY_NAME_CHARS

        public static final char[] ILLEGAL_ENTITY_NAME_CHARS
    • Constructor Detail

      • NamingUtil

        public NamingUtil()
    • Method Detail

      • doesNameHaveIllegalChars

        public static boolean doesNameHaveIllegalChars​(String name)
        Checks if a name of a table contains illegal chars.
        Parameters:
        name - the name to check
        Returns:
        true if the name contains a char from the ILLEGAL_ENTITY_NAME_CHARS).
      • doesNameContainNonNormalCharacters

        public static boolean doesNameContainNonNormalCharacters​(String name)
        Checks a name for non-normal characters. Non-normal is everything from a to z, A to Z, 0 to 9 and _.
        Parameters:
        name - the name to check
        Returns:
        true if the name contains illegal chars, false otherwise
      • getEntityName

        public static String getEntityName​(Class<?> clz)
        Returns the value of the ENTITY_NAME constant in the passed class.
        Parameters:
        clz - the entity class
        Returns:
        the ENTITY_NAME constant
      • getStaticPropertyName

        public static String getStaticPropertyName​(Class<?> clz,
                                                   String propertyName)
        Generated entity classes have String constants to denote their property name. It has a performance benefit if the String constant is used because then HashMap get operations are faster (as equals also tests on object equality). This method tries to retrieve the String constant from the passed class. The clz parameter maybe null (happens for dynamic entities). In this case the passed propertyName is returned.
        Parameters:
        clz - the entity class, maybe null, in which case propertyName is returned
        propertyName - the propertyName to search for in the class
        Returns:
        the String constant or the passed propertyName
      • formatAsPropertyName

        public static String formatAsPropertyName​(String name)
        Formats the given String as a property name which implies camel casing the characters after "_" and " ", removing illegal characters and lower casing the first character.
        Parameters:
        name - The name to be formatted
        Returns:
        the provided name formatted as a property name