- java.lang.Object
-
- org.refcodes.textual.CaseStyleBuilder
-
- All Implemented Interfaces:
org.refcodes.mixin.TextAccessor
,org.refcodes.mixin.TextAccessor.TextBuilder<CaseStyleBuilder>
,org.refcodes.mixin.TextAccessor.TextMutator
,org.refcodes.mixin.TextAccessor.TextProperty
,CaseAccessor
,CaseAccessor.CaseBuilder<CaseStyleBuilder>
,CaseAccessor.CaseMutator
,CaseAccessor.CaseProperty
public class CaseStyleBuilder extends Object implements org.refcodes.mixin.TextAccessor.TextProperty, org.refcodes.mixin.TextAccessor.TextBuilder<CaseStyleBuilder>, CaseAccessor.CaseProperty, CaseAccessor.CaseBuilder<CaseStyleBuilder>
Converts a text to the format of aString
to the desired case. The state of theCase
accessible viagetCase()
has not an effect on some of the methods. For example it has no effect ontoCamelCase()
, but it has an effect intoSnakeCase(String)
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.refcodes.textual.CaseAccessor
CaseAccessor.CaseBuilder<B extends CaseAccessor.CaseBuilder<?>>, CaseAccessor.CaseMutator, CaseAccessor.CaseProperty
-
-
Constructor Summary
Constructors Constructor Description CaseStyleBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static String
asCamelCase(String aText)
This method represents a shortcut for the instance methodtoCamelCase(String)
though with default settings.static String
asKebabCase(String aText)
This method represents a shortcut for the instance methodtoKebabCase(String)
though with default settings.static String
asKebabCase(String aText, Case aCase)
This method represents a shortcut for the instance methodtoKebabCase(String)
.static String
asPascalCase(String aText)
This method represents a shortcut for the instance methodtoPascalCase(String)
though with default settings.static String
asSnakeCase(String aText)
This method represents a shortcut for the instance methodtoSnakeCase(String)
though with default settings.static String
asSnakeCase(String aText, Case aCase)
This method represents a shortcut for the instance methodtoSnakeCase(String)
.Case
getCase()
Gets the currently setCase
being used.String
getText()
void
setCase(Case aCase)
Sets theCase
to be used.void
setText(String aText)
String
toCamelCase()
Converts the text as ofgetText()
to camel-case ("camelCase").String
toCamelCase(String aText)
Converts the provided text as ofgetText()
to camel-case ("camelCase").String
toKebabCase()
Converts the text as ofgetText()
to kebab-case, either in upper case as of "KEBAB-CASE" or in lower-case as of "kebab-case", depending on theCase
property (as ofsetCase(Case)
andgetCase()
).String
toKebabCase(String aText)
Converts the provided text as ofgetText()
to kebab-case, either in upper case as of "KEBAB-CASE" or in lower-case as of "kebab-case", depending on theCase
property (as ofsetCase(Case)
andgetCase()
).String
toPascalCase()
Converts the text as ofgetText()
to pascal-case ("PascalCase").String
toPascalCase(String aText)
Converts the provided text as ofgetText()
to pascal-case ("PascalCase").String
toSnakeCase()
Converts the text as ofgetText()
to snake-case, either in upper case as of "SNAKE_CASE" or in lower-case as of "snake_case", depending on theCase
property (as ofsetCase(Case)
andgetCase()
).String
toSnakeCase(String aText)
Converts the provided text as ofgetText()
to snake-case, either in upper case as of "SNAKE_CASE" or in lower-case as of "snake_case", depending on theCase
property (as ofsetCase(Case)
andgetCase()
).CaseStyleBuilder
withCase(Case aCase)
Sets the rowsCase
to use returns this builder as of the Builder-Pattern.CaseStyleBuilder
withText(String aText)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.refcodes.textual.CaseAccessor.CaseProperty
letCase
-
-
-
-
Method Detail
-
getText
public String getText()
- Specified by:
getText
in interfaceorg.refcodes.mixin.TextAccessor
-
setText
public void setText(String aText)
- Specified by:
setText
in interfaceorg.refcodes.mixin.TextAccessor.TextMutator
-
withText
public CaseStyleBuilder withText(String aText)
- Specified by:
withText
in interfaceorg.refcodes.mixin.TextAccessor.TextBuilder<CaseStyleBuilder>
-
getCase
public Case getCase()
Gets the currently setCase
being used.- Specified by:
getCase
in interfaceCaseAccessor
- Returns:
- The currently configured
Case
s.
-
setCase
public void setCase(Case aCase)
Sets theCase
to be used.- Specified by:
setCase
in interfaceCaseAccessor.CaseMutator
- Parameters:
aCase
- TheCase
to be stored by theCase
property.
-
toCamelCase
public String toCamelCase()
Converts the text as ofgetText()
to camel-case ("camelCase").- Returns:
- The camel-case representation of the according text.
-
toSnakeCase
public String toSnakeCase()
Converts the text as ofgetText()
to snake-case, either in upper case as of "SNAKE_CASE" or in lower-case as of "snake_case", depending on theCase
property (as ofsetCase(Case)
andgetCase()
).- Returns:
- The pascal-case representation of the according text.
-
toPascalCase
public String toPascalCase()
Converts the text as ofgetText()
to pascal-case ("PascalCase").- Returns:
- The camel-case representation of the according text.
-
toKebabCase
public String toKebabCase()
Converts the text as ofgetText()
to kebab-case, either in upper case as of "KEBAB-CASE" or in lower-case as of "kebab-case", depending on theCase
property (as ofsetCase(Case)
andgetCase()
).- Returns:
- The kebab-case representation of the according text.
-
toCamelCase
public String toCamelCase(String aText)
Converts the provided text as ofgetText()
to camel-case ("camelCase").- Parameters:
aText
- The text to be converted.- Returns:
- The camel-case representation of the according text.
-
toSnakeCase
public String toSnakeCase(String aText)
Converts the provided text as ofgetText()
to snake-case, either in upper case as of "SNAKE_CASE" or in lower-case as of "snake_case", depending on theCase
property (as ofsetCase(Case)
andgetCase()
).- Parameters:
aText
- The text to be converted.- Returns:
- The snake-case representation of the according text.
-
toPascalCase
public String toPascalCase(String aText)
Converts the provided text as ofgetText()
to pascal-case ("PascalCase").- Parameters:
aText
- The text to be converted.- Returns:
- The pascal-case representation of the according text.
-
toKebabCase
public String toKebabCase(String aText)
Converts the provided text as ofgetText()
to kebab-case, either in upper case as of "KEBAB-CASE" or in lower-case as of "kebab-case", depending on theCase
property (as ofsetCase(Case)
andgetCase()
).- Parameters:
aText
- The text to be converted.- Returns:
- The kebab-case representation of the according text.
-
withCase
public CaseStyleBuilder withCase(Case aCase)
Sets the rowsCase
to use returns this builder as of the Builder-Pattern.- Specified by:
withCase
in interfaceCaseAccessor.CaseBuilder<CaseStyleBuilder>
- Parameters:
aCase
- TheCase
to be used when printing a row or the header.- Returns:
- This
CaseAccessor.CaseBuilder
instance to continue configuration.
-
asCamelCase
public static String asCamelCase(String aText)
This method represents a shortcut for the instance methodtoCamelCase(String)
though with default settings.- Parameters:
aText
- The text to be converted.- Returns:
- The camel-case representation of the according text.
-
asSnakeCase
public static String asSnakeCase(String aText)
This method represents a shortcut for the instance methodtoSnakeCase(String)
though with default settings.- Parameters:
aText
- The text to be converted.- Returns:
- The snake-case representation of the according text.
-
asSnakeCase
public static String asSnakeCase(String aText, Case aCase)
This method represents a shortcut for the instance methodtoSnakeCase(String)
.- Parameters:
aText
- The text to be converted.aCase
- The case to use, either upper or lower.- Returns:
- The snake-case representation of the according text.
-
asPascalCase
public static String asPascalCase(String aText)
This method represents a shortcut for the instance methodtoPascalCase(String)
though with default settings.- Parameters:
aText
- The text to be converted.- Returns:
- The pascal-case representation of the according text.
-
asKebabCase
public static String asKebabCase(String aText)
This method represents a shortcut for the instance methodtoKebabCase(String)
though with default settings.- Parameters:
aText
- The text to be converted.- Returns:
- The "kebab-case" representation of the according text.
-
asKebabCase
public static String asKebabCase(String aText, Case aCase)
This method represents a shortcut for the instance methodtoKebabCase(String)
.- Parameters:
aText
- The text to be converted.aCase
- The case to use, either upper or lower.- Returns:
- The "kebab-case" representation of the according text.
-
-