Package org.immutables.generator
Class Naming
java.lang.Object
org.immutables.generator.Naming
- Direct Known Subclasses:
Naming.ConstantNaming,Naming.JavaBeanNaming,Naming.PrefixSuffixNaming
public abstract class Naming
extends Object
implements com.google.common.base.Function<String,String>
Converter-like function to apply or extract naming, derived from input.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classprivate static classstatic enumprivate static classstatic enum -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract StringApplies naming to input identifier, converting it to desired naming.abstract StringTries to extract source identifier name out of already applied naming.static Namingstatic Naming[]static Namingidentity()Naming the repeats the input nameabstract booleanChecks if is constant naming.abstract booleanChecks if it's identity naming.abstract NamingRequire naming to follow JavaBeam capitalization convention.abstract NamingrequireNonConstant(Naming.Preference preference) Returns non-contant naming which is this.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.google.common.base.Function
equals
-
Field Details
-
NOT_DETECTED
- See Also:
-
NAME_PLACEHOLDER
- See Also:
-
TEMPLATE_SPLITTER
private static final com.google.common.base.Splitter TEMPLATE_SPLITTER -
TEMPLATE_CHAR_MATCHER
private static final com.google.common.base.CharMatcher TEMPLATE_CHAR_MATCHER -
IDENTITY_NAMING
-
-
Constructor Details
-
Naming
private Naming()
-
-
Method Details
-
apply
Applies naming to input identifier, converting it to desired naming. -
detect
Tries to extract source identifier name out of already applied naming.- Parameters:
identifier- to detect naming from- Returns:
- empty string if nothing detected
-
isIdentity
public abstract boolean isIdentity()Checks if it's identity naming.- Returns:
- true, if is identity naming
- See Also:
-
isConstant
public abstract boolean isConstant()Checks if is constant naming. Verbatim naming convention do not use any supplied input name as base. Consider example factory method "from" constant naming, contrary to the factory method "newMyType" uses "MyType" as and input applying "new" prefix.- Returns:
- true, if is constant
-
requireNonConstant
Returns non-contant naming which is this. Sometimes context require naming should be non-contant, otherwise names will clash in shared identifier scope. If this naming is constant, then it is turned into corresponding prefix naming.- Parameters:
preference- preference for prefix or suffix naming- Returns:
- non-constant naming template or
thisif already non-constant
-
requireJavaBeanConvention
Require naming to follow JavaBeam capitalization convention.See 8.8 Capitalization of inferred names
Thus when we extract a property or event name from the middle of an existing Java name, we normally convert the first character to lower case. However to support the occasional use of all upper-case names, we check if the first two characters of the name are both upper case and if so leave it alone. So for example, "FooBah" becomes "fooBah", "Z" becomes "z", "URL" becomes "URL"
- See Also:
-
identity
Naming the repeats the input name- Returns:
- identity naming
-
from
- Parameters:
template- template string- Returns:
- naming that could be applied or detected following template
-
fromAll
-