Java Code Examples for org.apache.commons.lang3.StringUtils#splitByCharacterTypeCamelCase()

The following examples show how to use org.apache.commons.lang3.StringUtils#splitByCharacterTypeCamelCase() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: FEBS-Cloud   File: FebsUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 驼峰转下划线
 *
 * @param value 待转换值
 * @return 结果
 */
public static String camelToUnderscore(String value) {
    if (StringUtils.isBlank(value)) {
        return value;
    }
    String[] arr = StringUtils.splitByCharacterTypeCamelCase(value);
    if (arr.length == 0) {
        return value;
    }
    StringBuilder result = new StringBuilder();
    IntStream.range(0, arr.length).forEach(i -> {
        if (i != arr.length - 1) {
            result.append(arr[i]).append("_");
        } else {
            result.append(arr[i]);
        }
    });
    return StringUtils.lowerCase(result.toString());
}
 
Example 2
private List<String> fromName(final AccessSymbol accessSymbol) {
  final Set<String> names = new HashSet<>(4);

  String name = accessSymbol.name;
  if (name.startsWith("get")) {
    name = name.substring(3);
  }

  // add simpleName
  final String uncapitalize = StringUtils.uncapitalize(name);
  final String[] strings = StringUtils.splitByCharacterTypeCamelCase(uncapitalize);
  final List<String> nameList = new ArrayList<>(Arrays.asList(strings));

  addName(names, nameList);
  names.add(uncapitalize);

  // add scope + simpleName
  final String scope = accessSymbol.scope;
  if (!scope.isEmpty() && !StringUtils.containsAny(scope, "(", ".", "$")) {
    //
    final String scopeName = StringUtils.uncapitalize(scope) + StringUtils.capitalize(name);
    names.add(scopeName);
  }

  return new ArrayList<>(names);
}
 
Example 3
Source Project: viritin   File: MTable.java    License: Apache License 2.0 6 votes vote down vote up
public MTable<T> withProperties(String... visibleProperties) {
    if (isContainerInitialized()) {
        bic.setContainerPropertyIds(visibleProperties);
        setVisibleColumns((Object[]) visibleProperties);
    } else {
        pendingProperties = visibleProperties;
        for (String string : visibleProperties) {
            addContainerProperty(string, String.class, "");
        }
    }
    for (String visibleProperty : visibleProperties) {
        String[] parts = StringUtils.splitByCharacterTypeCamelCase(
                visibleProperty);
        parts[0] = StringUtils.capitalize(parts[0]);
        for (int i = 1; i < parts.length; i++) {
            parts[i] = parts[i].toLowerCase();
        }
        String saneCaption = StringUtils.join(parts, " ");
        setColumnHeader(visibleProperty, saneCaption);
    }
    return this;
}
 
Example 4
Source Project: youran   File: SwitchCaseUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 驼峰转下划线
 *
 * @param name
 * @param upCase
 * @return
 */
public static String camelCaseToSnakeCase(String name, boolean upCase) {
    String[] split = StringUtils.splitByCharacterTypeCamelCase(name);
    Stream<String> stream = Arrays.stream(split);
    if (upCase) {
        stream = stream.map(String::toUpperCase);
    } else {
        stream = stream.map(String::toLowerCase);
    }
    return stream.collect(Collectors.joining("_"));
}
 
Example 5
Source Project: youran   File: SwitchCaseUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 首个单词转小写
 *
 * @param name
 * @return
 */
public static String lowerFirstWord(String name) {
    String[] split = StringUtils.splitByCharacterTypeCamelCase(name);
    if(ArrayUtils.isEmpty(split)){
        return name;
    }
    split[0] = split[0].toLowerCase();
    return Arrays.stream(split)
        .collect(Collectors.joining(""));
}
 
Example 6
Source Project: youran   File: MetadataUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 构建默认多对多外键别名
 *
 * @param className
 * @param forSql
 * @return
 */
public static String buildDefaultMtmFkAlias(String className, boolean forSql) {
    String alias = SwitchCaseUtil.lowerFirstWord(className) + "Id";
    if (forSql) {
        String[] split = StringUtils.splitByCharacterTypeCamelCase(alias);
        String join = Joiner.on("_").join(split);
        alias = join.toLowerCase();
    }
    return alias;
}
 
Example 7
Source Project: gocd   File: StringUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static String humanize(String s) {
    String[] strings = StringUtils.splitByCharacterTypeCamelCase(s);
    for (int i = 0; i < strings.length; i++) {
        String string = strings[i];
        strings[i] = string.toLowerCase();
    }
    return StringUtils.join(strings, " ");
}
 
Example 8
Source Project: quarkus   File: CreateUtils.java    License: Apache License 2.0 4 votes vote down vote up
public static String getDerivedPath(String className) {
    String[] resourceClassName = StringUtils.splitByCharacterTypeCamelCase(
            className.substring(className.lastIndexOf(".") + 1));
    return "/" + resourceClassName[0].toLowerCase();
}
 
Example 9
Source Project: quarkus   File: CreateProjectCommand.java    License: Apache License 2.0 4 votes vote down vote up
private static String getDerivedPath(String className) {
    String[] resourceClassName = StringUtils.splitByCharacterTypeCamelCase(
            className.substring(className.lastIndexOf(".") + 1));
    return "/" + resourceClassName[0].toLowerCase();
}
 
Example 10
Source Project: requirementsascode   File: Words.java    License: Apache License 2.0 4 votes vote down vote up
private static String[] toWordArray(String camelCaseString) {
  String[] wordsArray = StringUtils.splitByCharacterTypeCamelCase(camelCaseString);
  return wordsArray;
}