class CaseTools {

    public static String snake(String s) {
        if (s == null) {
            return null;
        }
        int dst = 0;
        final var result = new char[2 * s.length()];
        for (int src = 0; src < s.length(); src++) {
            if (Character.isUpperCase(s.charAt(src)) && src > 0) {
                result[dst++] = '_';
            }
            result[dst++] = Character.toUpperCase(s.charAt(src));
        }
        return new String(result, 0, dst);
    }

}