Class NamingHelper


  • public class NamingHelper
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static NamingHelper INSTANCE
      Singleton access
    • Constructor Summary

      Constructors 
      Constructor Description
      NamingHelper()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String generateHashedConstraintName​(java.lang.String prefix, Identifier tableName, java.util.List<Identifier> columnNames)
      If a constraint is not explicitly named, this is called to generate a unique hash using the table and column names.
      java.lang.String generateHashedConstraintName​(java.lang.String prefix, Identifier tableName, Identifier... columnNames)
      If a constraint is not explicitly named, this is called to generate a unique hash using the table and column names.
      java.lang.String generateHashedFkName​(java.lang.String prefix, Identifier tableName, Identifier referencedTableName, java.util.List<Identifier> columnNames)
      If a foreign-key is not explicitly named, this is called to generate a unique hash using the table and column names.
      java.lang.String generateHashedFkName​(java.lang.String prefix, Identifier tableName, Identifier referencedTableName, Identifier... columnNames)
      If a foreign-key is not explicitly named, this is called to generate a unique hash using the table and column names.
      java.lang.String hashedName​(java.lang.String s)
      Hash a constraint name using MD5.
      static NamingHelper withCharset​(java.lang.String charset)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • INSTANCE

        public static final NamingHelper INSTANCE
        Singleton access
    • Constructor Detail

      • NamingHelper

        public NamingHelper()
    • Method Detail

      • withCharset

        public static NamingHelper withCharset​(java.lang.String charset)
      • generateHashedFkName

        public java.lang.String generateHashedFkName​(java.lang.String prefix,
                                                     Identifier tableName,
                                                     Identifier referencedTableName,
                                                     java.util.List<Identifier> columnNames)
        If a foreign-key is not explicitly named, this is called to generate a unique hash using the table and column names.
      • generateHashedFkName

        public java.lang.String generateHashedFkName​(java.lang.String prefix,
                                                     Identifier tableName,
                                                     Identifier referencedTableName,
                                                     Identifier... columnNames)
        If a foreign-key is not explicitly named, this is called to generate a unique hash using the table and column names.
      • generateHashedConstraintName

        public java.lang.String generateHashedConstraintName​(java.lang.String prefix,
                                                             Identifier tableName,
                                                             Identifier... columnNames)
        If a constraint is not explicitly named, this is called to generate a unique hash using the table and column names.
        Returns:
        String The generated name
      • generateHashedConstraintName

        public java.lang.String generateHashedConstraintName​(java.lang.String prefix,
                                                             Identifier tableName,
                                                             java.util.List<Identifier> columnNames)
        If a constraint is not explicitly named, this is called to generate a unique hash using the table and column names.
        Returns:
        String The generated name
      • hashedName

        public java.lang.String hashedName​(java.lang.String s)
        Hash a constraint name using MD5. Convert the MD5 digest to base 35 (full alphanumeric), guaranteeing that the length of the name will always be smaller than the 30 character identifier restriction enforced by a few dialects.
        Parameters:
        s - The name to be hashed.
        Returns:
        String The hashed name.