Interface NamingStrategy
-
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface NamingStrategy
Derives a database name of an object from the Java name of an object.Provides various convenience methods for chaining several implementations. For example if the Java name of your stored procedure is
"blitz"
but the SQL name is"sp_Blitz"
then you can create this transformation using:NamingStrategy.capitalize() // converts "blitz" to "Blitz" .thenPrefix("sp_") // converts "Blitz" to "sp_Blitz"
- See Also:
- Deriving Names
-
-
Field Summary
Fields Modifier and Type Field Description static NamingStrategy
IDENTITY
The identity transformation.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static NamingStrategy
capitalize()
Creates a new transformation that converts the first character to upper case.static NamingStrategy
lowerCase()
Creates a new transformation that converts the entire string to lower case.static NamingStrategy
prefix(String prefix)
Creates a new transformation that applies a prefix to the string.static NamingStrategy
snakeCase()
Creates a new transformation that converts the entire string to snake case.default NamingStrategy
then(NamingStrategy next)
Applies another transformation after the current transformation.default NamingStrategy
thenCapitalize()
Applies an upper case transformation of the first character after the current transformation.default NamingStrategy
thenLowerCase()
Applies a lower case transformation of the entire string after the current transformation.default NamingStrategy
thenPrefix(String prefix)
Appends a prefix after the current transformation.default NamingStrategy
thenSnakeCase()
Applies snake case after the current transformation.default NamingStrategy
thenUpperCase()
Applies a upper case transformation of the entire string after the current transformation.default NamingStrategy
thenWithoutFirst(int skipped)
Skips a number of characters from the start of the name after the current transformation.String
translateToDatabase(String javaName)
Derives a database name of an object from the Java name of an object.static NamingStrategy
upperCase()
Creates a new transformation that converts the entire string to upper case.static NamingStrategy
withoutFirst(int skipped)
Creates a new transformation that skips a given number of characters from the start of the java name.
-
-
-
Field Detail
-
IDENTITY
static final NamingStrategy IDENTITY
The identity transformation. Simply returns the argument unchanged.
-
-
Method Detail
-
translateToDatabase
String translateToDatabase(String javaName)
Derives a database name of an object from the Java name of an object.- Parameters:
javaName
- the Java name of an object, nevernull
- Returns:
- the database name of an object, never
null
-
upperCase
static NamingStrategy upperCase()
Creates a new transformation that converts the entire string to upper case.Only works reliably for characters from the US-ASCII latin alphabet.
- Returns:
- a new transformation that converts the entire string to upper case
-
lowerCase
static NamingStrategy lowerCase()
Creates a new transformation that converts the entire string to lower case.Only works reliably for characters from the US-ASCII latin alphabet.
- Returns:
- a new transformation that converts the entire string to lower case
-
capitalize
static NamingStrategy capitalize()
Creates a new transformation that converts the first character to upper case.Only works for characters from the US-ASCII latin alphabet.
- Returns:
- a new transformation that converts the first character to upper case
-
snakeCase
static NamingStrategy snakeCase()
Creates a new transformation that converts the entire string to snake case.For example turns
"procedureName"
into"procedure_Name"
. No case conversion is done so you'll likely want to combine this with eitherthenUpperCase()
orthenLowerCase()
.- Returns:
- a new transformation that converts the entire string to snake case
-
prefix
static NamingStrategy prefix(String prefix)
Creates a new transformation that applies a prefix to the string.- Parameters:
prefix
- the prefix to append, notnull
- Returns:
- a new transformation that applies a prefix
-
withoutFirst
static NamingStrategy withoutFirst(int skipped)
Creates a new transformation that skips a given number of characters from the start of the java name.- Parameters:
skipped
- the number of characters from the start- Returns:
- a new transformation that skips the first characters
-
then
default NamingStrategy then(NamingStrategy next)
Applies another transformation after the current transformation.- Parameters:
next
- the transformation to apply after the current one, notnull
- Returns:
- a new transformation that applies the given transformation after the current transformation
-
thenUpperCase
default NamingStrategy thenUpperCase()
Applies a upper case transformation of the entire string after the current transformation.Only works reliably for characters from the US-ASCII latin alphabet.
- Returns:
- a new transformation that applies a upper case transformation after the current transformation
-
thenLowerCase
default NamingStrategy thenLowerCase()
Applies a lower case transformation of the entire string after the current transformation.Only works reliably for characters from the US-ASCII latin alphabet.
- Returns:
- a new transformation that applies a lower case transformation after the current transformation
-
thenCapitalize
default NamingStrategy thenCapitalize()
Applies an upper case transformation of the first character after the current transformation.Only works for characters from the US-ASCII latin alphabet.
- Returns:
- a new transformation that applies captialisation of the first character after the current transformation
-
thenSnakeCase
default NamingStrategy thenSnakeCase()
Applies snake case after the current transformation.For example turns
"procedureName"
into"procedure_Name"
. No case conversion is done so you'll likely want to combine this with eitherthenUpperCase()
orthenLowerCase()
.- Returns:
- a new transformation that applies snake case after the current transformation
-
thenPrefix
default NamingStrategy thenPrefix(String prefix)
Appends a prefix after the current transformation.- Parameters:
prefix
- the prefix to append, notnull
- Returns:
- a new transformation that applies a prefix after the current transformation
-
thenWithoutFirst
default NamingStrategy thenWithoutFirst(int skipped)
Skips a number of characters from the start of the name after the current transformation.- Parameters:
skipped
- the number of characters from the start- Returns:
- a new transformation that skips
skipped
characters after the current transformation
-
-