Java Code Examples for com.google.common.base.CaseFormat#LOWER_CAMEL
The following examples show how to use
com.google.common.base.CaseFormat#LOWER_CAMEL .
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: CaseFormatUtil.java From raptor with Apache License 2.0 | 6 votes |
/** * 判断str是哪种命名格式的,不能保证一定判断对,慎用 * * @param str * @return */ public static CaseFormat determineFormat(String str) { Preconditions.checkNotNull(str); String[] split = str.split("_"); List<String> splitedStrings = Arrays.stream(split).map(String::trim).filter(StringUtils::isNotBlank).collect(Collectors.toList()); if (splitedStrings.size() == 1) { //camel if (CharUtils.isAsciiAlphaUpper(splitedStrings.get(0).charAt(0))) { return CaseFormat.UPPER_CAMEL; } else { return CaseFormat.LOWER_CAMEL; } } else if (splitedStrings.size() > 1) { //underscore if (CharUtils.isAsciiAlphaUpper(splitedStrings.get(0).charAt(0))) { return CaseFormat.UPPER_UNDERSCORE; } else { return CaseFormat.LOWER_UNDERSCORE; } }else{ //判断不出那个 return CaseFormat.LOWER_CAMEL; } }
Example 2
Source File: DefaultCaseFormatDetector.java From opentracing-toolbox with MIT License | 6 votes |
@Override public CaseFormat detect(final String s) { if (isLowerCase(s)) { if (hasHyphen(s)) { return CaseFormat.LOWER_HYPHEN; } return CaseFormat.LOWER_UNDERSCORE; } if (isUpperCase(s)) { return CaseFormat.UPPER_UNDERSCORE; } if (startsLowerCase(s)) { return CaseFormat.LOWER_CAMEL; } return CaseFormat.UPPER_CAMEL; }
Example 3
Source File: ProtoTypeAdapter.java From gson with Apache License 2.0 | 2 votes |
/** * Creates a new {@link ProtoTypeAdapter} builder, defaulting enum serialization to * {@link EnumSerialization#NAME} and converting field serialization from * {@link CaseFormat#LOWER_UNDERSCORE} to {@link CaseFormat#LOWER_CAMEL}. */ public static Builder newBuilder() { return new Builder(EnumSerialization.NAME, CaseFormat.LOWER_UNDERSCORE, CaseFormat.LOWER_CAMEL); }