Skip to content

Create Naming-variations on-the-fly #225

@sebastian-peter

Description

@sebastian-peter

In Naming.java, all variants of a provided String are calculated during construction of the object.

String flatCase = String.join("", components);
String upperFlatCase =
components.stream().map(String::toUpperCase).collect(Collectors.joining(""));
String camelCase = String.join("", camelCasing(components));
String pascalCase =
components.stream().map(StringUtils::capitalize).collect(Collectors.joining(""));
String snakeCase = String.join("_", components);
String screamingSnakeCase =
components.stream().map(String::toUpperCase).collect(Collectors.joining("_"));
String camelSnakeCase = String.join("_", camelCasing(components));
String pascalSnakeCase =
components.stream().map(StringUtils::capitalize).collect(Collectors.joining("_"));
String kebabCase = String.join("-", components);
String donerCase = String.join("|", components);
String screamingKebabCase =
components.stream().map(String::toUpperCase).collect(Collectors.joining("-"));
String trainCase =
components.stream().map(StringUtils::capitalize).collect(Collectors.joining("-"));

This is rather time and space consuming, as in most cases, only a small number is actually required. The code could be adapted to construct the desired variant on-the-fly when any method such as flatCase() is called. One could even implement some sort of caching here, where the variants are only lazily built once they're requested.

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions