驼峰,连接符,下划线命名等互相转换 CaseFormat.LOWER_CAME等

1 jar:

guava-r05.jar

2

        String orderColumn = "orderColumn";
        //输入是LOWER_CAMEL,输出是LOWER_UNDERSCORE
        orderColumn = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, orderColumn);
        System.out.println(orderColumn);//order_column

        orderColumn = "orderColumn";
        //输入是LOWER_CAMEL,输出是UPPER_CAMEL
        orderColumn = CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL,orderColumn);
        System.out.println(orderColumn);//OrderColumn

        orderColumn = "order_column";
        //输入是LOWER_UNDERSCORE,输出是LOWER_CAMEL
        orderColumn = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL,orderColumn);
        System.out.println(orderColumn);//orderColumn

end

你可能感兴趣的:(Java)