下划线、驼峰式变量相互转换

com.google.common.base.CaseFormat是一种实用工具类,以提供不同的ASCII字符格式之间的转换。

 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

你可能感兴趣的:(下划线、驼峰式变量相互转换)