Class AbstractNamingFactory

    • Field Detail

      • reservedWords

        protected Set<String> reservedWords
      • wordSeparator

        protected String wordSeparator
        Separator to use for words in the identifiers.
      • quoteString

        protected String quoteString
        Quote used when the identifier case selected requires it.
    • Constructor Detail

      • AbstractNamingFactory

        public AbstractNamingFactory​(NucleusContext nucCtx)
    • Method Detail

      • setReservedKeywords

        public NamingFactory setReservedKeywords​(Set<String> keywords)
        Description copied from interface: NamingFactory
        Method to set the provided list of keywords as names that identifiers have to surround by quotes to use.
        Specified by:
        setReservedKeywords in interface NamingFactory
        Parameters:
        keywords - The keywords
        Returns:
        This naming factory
      • setQuoteString

        public NamingFactory setQuoteString​(String quote)
        Description copied from interface: NamingFactory
        Method to set the quote string to use (when the identifiers need to be quoted). See
        setIdentifierCase
        .
        Specified by:
        setQuoteString in interface NamingFactory
        Parameters:
        quote - The quote string
        Returns:
        This naming factory
      • setMaximumLength

        public NamingFactory setMaximumLength​(SchemaComponent cmpt,
                                              int max)
        Description copied from interface: NamingFactory
        Method to set the maximum length of the name of the specified schema component.
        Specified by:
        setMaximumLength in interface NamingFactory
        Parameters:
        cmpt - The component
        max - The maximum it accepts
        Returns:
        This naming factory
      • getMaximumLengthForComponent

        protected int getMaximumLengthForComponent​(SchemaComponent cmpt)
      • getColumnName

        public String getColumnName​(AbstractMemberMetaData mmd,
                                    ColumnType type)
        Description copied from interface: NamingFactory
        Method to return the name of the column for the specified field. If you have multiple columns for a field then call the other
        getColumnName
        method.
        Specified by:
        getColumnName in interface NamingFactory
        Parameters:
        mmd - Metadata for the field
        type - Type of column
        Returns:
        The column name
      • getColumnName

        public String getColumnName​(List<AbstractMemberMetaData> mmds,
                                    int colPosition)
        Description copied from interface: NamingFactory
        Method to return the name of the column for the position of the specified EMBEDDED field, within the specified owner field. For example, say we have a class Type1 with field "field1" that is marked as embedded, and this is of type Type2. In turn Type2 has a field "field2" that is also embedded, of type Type3. Type3 has a field "name". So to get the column name for Type3.name in the table for Type1 we call "getColumnName({mmdForField1InType1, mmdForField2InType2, mmdForNameInType3}, 0)".
        Specified by:
        getColumnName in interface NamingFactory
        Parameters:
        mmds - MetaData for the field(s) with the column. The first value is the original field that is embedded, followed by fields of the embedded object(s).
        colPosition - The position of the column (where this field has multiple columns)
        Returns:
        The column name TODO Pass in something that distinguishes between map key and map value
      • getConstraintName

        public String getConstraintName​(AbstractClassMetaData cmd,
                                        ConstraintMetaData cnstrmd,
                                        int position)
        Description copied from interface: NamingFactory
        Method to return the name of a constraint specified at class level.
        Specified by:
        getConstraintName in interface NamingFactory
        Parameters:
        cmd - Metadata for the class
        cnstrmd - The constraint metadata
        position - Number of the constraint at class level (first is 0)
        Returns:
        Name of the constraint
      • getConstraintName

        public String getConstraintName​(String className,
                                        AbstractMemberMetaData mmd,
                                        ConstraintMetaData cnstrmd)
        Description copied from interface: NamingFactory
        Method to return the name of a constraint specified at member level.
        Specified by:
        getConstraintName in interface NamingFactory
        Parameters:
        className - Name of the class that this constraint is for.
        mmd - Metadata for the member
        cnstrmd - The constraint metadata
        Returns:
        Name of the constraint
      • truncate

        protected static String truncate​(String name,
                                         int length)
        Method to truncate a name to fit within the specified name length. If truncation is necessary will use a 4 char hashcode (defined by TRUNCATE_HASH_LENGTH) (at the end) to attempt to create uniqueness.
        Parameters:
        name - The name
        length - The (max) length to use
        Returns:
        The truncated name.
      • getNameInRequiredCase

        protected String getNameInRequiredCase​(String name)
        Convenience method to convert the passed name into a name in the required "case". Also adds on any required quoting.
        Parameters:
        name - The name
        Returns:
        The updated name in the correct case
      • prepareIdentifierNameForUse

        protected String prepareIdentifierNameForUse​(String name,
                                                     SchemaComponent cmpt)
        Convenience method that will truncate the provided name if it is longer than the longest possible for the specified schema component, and then convert it into the required case.
        Parameters:
        name - The name
        cmpt - The schema component that it is for
        Returns:
        The prepared identifier name