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

io.polyapi.plugin.utils.StringUtils Maven / Gradle / Ivy

There is a newer version: 0.15.3
Show newest version
package io.polyapi.plugin.utils;

import java.util.Optional;

import static java.util.function.Predicate.not;
import static org.apache.commons.text.WordUtils.capitalize;
import static org.apache.commons.text.WordUtils.uncapitalize;

public class StringUtils {
    private static final char[] DELIMITERS = new char[]{' ', '_', '-', '.'};
    private StringUtils() {
        // Do nothing.
    }

    public static String toPascalCase(String input) {

        return Optional.ofNullable(input)
                .filter(not(String::isBlank))
                .map(value -> capitalize(input, DELIMITERS).replaceAll("[\\-\\.\s]", ""))
                .orElse(input);
    }

    public static String toCamelCase(String input) {
        return uncapitalize(toPascalCase(input));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy