Class CaseStyleBuilder

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 a String to the desired case. The state of the Case accessible via getCase() has not an effect on some of the methods. For example it has no effect on toCamelCase(), but it has an effect in toSnakeCase(String).
  • Constructor Details

    • CaseStyleBuilder

      public CaseStyleBuilder()
  • Method Details

    • getText

      public String getText()
      Specified by:
      getText in interface org.refcodes.mixin.TextAccessor
    • setText

      public void setText(String aText)
      Specified by:
      setText in interface org.refcodes.mixin.TextAccessor.TextMutator
    • withText

      public CaseStyleBuilder withText(String aText)
      Specified by:
      withText in interface org.refcodes.mixin.TextAccessor.TextBuilder<CaseStyleBuilder>
    • getCase

      public Case getCase()
      Gets the currently set Case being used.
      Specified by:
      getCase in interface CaseAccessor
      Returns:
      The currently configured Cases.
    • setCase

      public void setCase(Case aCase)
      Sets the Case to be used.
      Specified by:
      setCase in interface CaseAccessor.CaseMutator
      Parameters:
      aCase - The Case to be stored by the Case property.
    • toCamelCase

      public String toCamelCase()
      Converts the text as of getText() to camel-case ("camelCase").
      Returns:
      The camel-case representation of the according text.
    • toSnakeCase

      public String toSnakeCase()
      Converts the text as of getText() to snake-case, either in upper case as of "SNAKE_CASE" or in lower-case as of "snake_case", depending on the Case property (as of setCase(Case) and getCase()).
      Returns:
      The pascal-case representation of the according text.
    • toPascalCase

      public String toPascalCase()
      Converts the text as of getText() to pascal-case ("PascalCase").
      Returns:
      The camel-case representation of the according text.
    • toKebabCase

      public String toKebabCase()
      Converts the text as of getText() to kebab-case, either in upper case as of "KEBAB-CASE" or in lower-case as of "kebab-case", depending on the Case property (as of setCase(Case) and getCase()).
      Returns:
      The kebab-case representation of the according text.
    • toCamelCase

      public String toCamelCase(String aText)
      Converts the provided text as of getText() 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 of getText() to snake-case, either in upper case as of "SNAKE_CASE" or in lower-case as of "snake_case", depending on the Case property (as of setCase(Case) and getCase()).
      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 of getText() 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 of getText() to kebab-case, either in upper case as of "KEBAB-CASE" or in lower-case as of "kebab-case", depending on the Case property (as of setCase(Case) and getCase()).
      Parameters:
      aText - The text to be converted.
      Returns:
      The kebab-case representation of the according text.
    • withCase

      public CaseStyleBuilder withCase(Case aCase)
      Sets the rows Case to use returns this builder as of the Builder-Pattern.
      Specified by:
      withCase in interface CaseAccessor.CaseBuilder<CaseStyleBuilder>
      Parameters:
      aCase - The Case 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 method toCamelCase(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 method toSnakeCase(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 method toSnakeCase(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 method toPascalCase(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 method toKebabCase(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 method toKebabCase(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.