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

com.github.wu191287278.maven.swagger.doc.utils.CamelUtils Maven / Gradle / Ivy

There is a newer version: 2.1.9
Show newest version
package com.github.wu191287278.maven.swagger.doc.utils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.regex.Pattern;

/**
 * @author yu.wu
 */
public class CamelUtils {
    private static final String UPPER = "\\p{Lu}|\\P{InBASIC_LATIN}";
    private static final String LOWER = "\\p{Ll}";
    private static final String CAMEL_CASE_REGEX = "(? split(String source, boolean toLower) {

        String[] parts = CAMEL_CASE.split(source);
        List result = new ArrayList<>(parts.length);

        for (String part : parts) {
            result.add(toLower ? part.toLowerCase() : part);
        }

        return Collections.unmodifiableList(result);
    }

    public static String toSnake(String source) {
        return String.join("_", split(source, true));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy