camel-name-utils 在驼峰风格跟下划线风格之间切换

用处

用来将字符串在驼峰风格跟下划线风格之间切换。

对于一般人可能没用。对于写orm框架的人有点作用。

样例:

company_name -> companyName

安装方式

加入下面依赖到pom.xml
<dependency>
  <groupId>org.crazycake</groupId>
  <artifactId>camel-name-utils</artifactId>
  <version>1.0.0-RELEASE</version>
</dependency>

使用方式

@Test
public void testCamel2underscore() {
        String underscoreName = CamelNameUtils.camel2underscore("AaaBbb");
        assertThat(underscoreName, is("aaa_bbb"));
}

@Test
public void testUnderscore2camel() {
        String camelName = CamelNameUtils.underscore2camel("user_name");
        assertThat(camelName,is("userName"));
}

@Test
public void testCapitalize() {
        String capitalName = CamelNameUtils.capitalize("student");
        assertThat(capitalName,is("Student"));
}
以上的介绍随时可能过期,最新版本号以项目主页为主
https://github.com/alexxiyang/camel-name-utils

原文地址:https://www.cnblogs.com/mengfanrong/p/5182119.html