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

The following examples show how to use org.apache.commons.lang3.StringUtils#splitByCharacterTypeCamelCase() . 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 File: FebsUtil.java    From FEBS-Cloud with 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
Source File: JavaVariableCompletion.java    From meghanada-server with GNU General Public License v3.0 6 votes vote down vote up
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 File: MTable.java    From viritin with 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 File: SwitchCaseUtil.java    From youran with 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 File: SwitchCaseUtil.java    From youran with 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 File: MetadataUtil.java    From youran with 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 File: StringUtil.java    From gocd with 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 File: CreateUtils.java    From quarkus with 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 File: CreateProjectCommand.java    From quarkus with 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 File: Words.java    From requirementsascode with Apache License 2.0 4 votes vote down vote up
private static String[] toWordArray(String camelCaseString) {
  String[] wordsArray = StringUtils.splitByCharacterTypeCamelCase(camelCaseString);
  return wordsArray;
}