All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.tinkoff.kora.common.naming.SnakeCaseUpperNameConverter Maven / Gradle / Ivy

There is a newer version: 1.1.16
Show newest version
package ru.tinkoff.kora.common.naming;

import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * Example: "myFieldNAME" will convert to "MY_FIELD_NAME"
 */
public final class SnakeCaseUpperNameConverter implements NameConverter {

    @Override
    public String convert(String originalName) {
        final String[] splitted = originalName.split("(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|( +)");
        return Stream.of(splitted)
            .map(String::toUpperCase)
            .collect(Collectors.joining("_"));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy