Class ModelUtilities

java.lang.Object
org.tentackle.model.ModelUtilities

@Service(ModelUtilities.class) public class ModelUtilities extends Object
Model utility methods.
May be replaced by project specific implementation via @Service.
  • Constructor Details

    • ModelUtilities

      public ModelUtilities()
      Creates the model utilities.
  • Method Details

    • getInstance

      public static ModelUtilities getInstance()
      The singleton.
      Returns:
      the singleton
    • isVowel

      public boolean isVowel(char c)
      Returns whether the character should be treated as a vowel.
      Parameters:
      c - the character
      Returns:
      true if vowel
    • containsVowel

      public boolean containsVowel(String s)
      Returns whether the given string contains at least one vowel.
      Parameters:
      s - the string
      Returns:
      true if vowels found
    • extractSyllables

      public List<String> extractSyllables(String name)
      Extracts the syllables of a name.
      The default implementation is very simple, but works good enough for the purpose of column migration.
      Parameters:
      name - the column name
      Returns:
      the syllables
    • bestMatch

      public String bestMatch(String modelName, List<String> existingNames)
      Finds the best match for a given model name among existing names.
      Parameters:
      modelName - the new name according to the model
      existingNames - the existing column names in the database table
      Returns:
      the best match, null if existingNames is empty
    • isJoinedLetter

      protected boolean isJoinedLetter(char c1, char c2)
      Returns whether two character can be regarded as one.
      Parameters:
      c1 - the first char
      c2 - the second char
      Returns:
      true if treat as single char