public class Inflector extends Object
Modifier and Type | Method and Description |
---|---|
static void |
addIrregular(String rule,
String replacement) |
static void |
addPlural(String rule,
String replacement) |
static void |
addSingular(String rule,
String replacement) |
static String |
camelize(String underscore)
Generates a camel case version of a phrase from underscore.
|
static String |
camelize(String underscore,
boolean capitalizeFirstChar)
Generates a camel case version of a phrase from underscore.
|
static String |
capitalize(String word)
Capitalizes a word - only a first character is converted to upper case.
|
static String |
getIdName(String tableName) |
static String |
getOtherName(String source,
String target)
If a table name is made of two other table names (as is typical for many to many relationships),
this method retrieves a name of "another" table from a join table name.
|
static String |
gsub(String word,
String rule,
String replacement)
Replaces a found pattern in a word and returns a transformed word.
|
static String |
pluralize(String word) |
static String |
singularize(String word) |
static String |
tableize(String camelCase)
Converts a camel case to underscore and then pluralizes.
|
static String |
underscore(String camel)
Converts a CamelCase string to underscores: "AliceInWonderLand" becomes:
"alice_in_wonderland"
|
public static String gsub(String word, String rule, String replacement)
word
- rule
- replacement
- public static String tableize(String camelCase)
camelCase
- any CamelCase phrase.public static String underscore(String camel)
camel
- camel case inputpublic static String camelize(String underscore)
underscore
- underscore version of a word to converted to camel case.public static String camelize(String underscore, boolean capitalizeFirstChar)
underscore
- underscore version of a word to converted to camel case.capitalizeFirstChar
- set to true if first character needs to be capitalized, false if not.public static String capitalize(String word)
word
- word/phrase to capitalize.public static String getOtherName(String source, String target)
source
- known table name. It may or may not exist in the target table name.target
- this is a potential "join" table name.Copyright © 2019 JavaLite. All rights reserved.