com.github.wu191287278.maven.swagger.doc.utils.CamelUtils Maven / Gradle / Ivy
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));
}
}