List of usage examples for com.google.common.base CaseFormat LOWER_UNDERSCORE
CaseFormat LOWER_UNDERSCORE
To view the source code for com.google.common.base CaseFormat LOWER_UNDERSCORE.
Click Source Link
From source file:org.eclipse.viatra.examples.cps.xform.m2t.util.FormatterUtil.java
public String purifyAndToUpperCamel(String string) { String str = purify(string.replace(' ', '_').toLowerCase()); return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, str); }
From source file:com.ning.billing.util.dao.LowerToCamelBeanMapper.java
public LowerToCamelBeanMapper(final Class<T> type) { this.type = type; try {//from w w w . j a v a 2s .co m final BeanInfo info = Introspector.getBeanInfo(type); for (final PropertyDescriptor descriptor : info.getPropertyDescriptors()) { properties.put( CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, descriptor.getName()).toLowerCase(), descriptor); } } catch (IntrospectionException e) { throw new IllegalArgumentException(e); } }
From source file:com.facebook.buck.query.AttrFilterFunction.java
@Override public Set<QueryTarget> eval(QueryEnvironment env, ImmutableList<Argument> args, ListeningExecutorService executor) throws QueryException, InterruptedException { QueryExpression argument = args.get(args.size() - 1).getExpression(); String attr = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, args.get(0).getWord()); final String attrValue = args.get(1).getWord(); final Predicate<Object> predicate = input -> attrValue.equals(input.toString()); Set<QueryTarget> result = new LinkedHashSet<>(); for (QueryTarget target : argument.eval(env, executor)) { ImmutableSet<Object> matchingObjects = env.filterAttributeContents(target, attr, predicate); if (!matchingObjects.isEmpty()) { result.add(target);//from w w w. j ava 2 s . com } } return result; }
From source file:org.killbill.commons.jdbi.mapper.LowerToCamelBeanMapper.java
public LowerToCamelBeanMapper(final Class<T> type) { this.type = type; try {//from w w w.j a v a 2 s . co m final BeanInfo info = Introspector.getBeanInfo(type); for (final PropertyDescriptor descriptor : info.getPropertyDescriptors()) { properties.put( CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, descriptor.getName()).toLowerCase(), descriptor); } } catch (final IntrospectionException e) { throw new IllegalArgumentException(e); } }
From source file:com.google.devtools.depan.nodes.filters.sequence.ComposeMode.java
public String getTitle() { return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name); }
From source file:com.thinkbiganalytics.feedmgr.rest.support.SystemNamingService.java
public static String generateSystemName(String name) { //first trim it String systemName = StringUtils.trimToEmpty(name); if (StringUtils.isBlank(systemName)) { return systemName; }/* w w w.ja v a 2s .c om*/ systemName = systemName.replaceAll(" +", "_"); systemName = systemName.replaceAll("[^\\w_]", ""); int i = 0; StringBuilder s = new StringBuilder(); CharacterIterator itr = new StringCharacterIterator(systemName); for (char c = itr.first(); c != CharacterIterator.DONE; c = itr.next()) { if (Character.isUpperCase(c)) { //if it is upper, not at the start and not at the end check to see if i am surrounded by upper then lower it. if (i > 0 && i != systemName.length() - 1) { char prevChar = systemName.charAt(i - 1); char nextChar = systemName.charAt(i + 1); if (Character.isUpperCase(prevChar) && (Character.isUpperCase(nextChar) || CharUtils.isAsciiNumeric(nextChar) || '_' == nextChar || '-' == nextChar)) { char lowerChar = Character.toLowerCase(systemName.charAt(i)); s.append(lowerChar); } else { s.append(c); } } else if (i > 0 && i == systemName.length() - 1) { char prevChar = systemName.charAt(i - 1); if (Character.isUpperCase(prevChar) && !CharUtils.isAsciiNumeric(systemName.charAt(i))) { char lowerChar = Character.toLowerCase(systemName.charAt(i)); s.append(lowerChar); } else { s.append(c); } } else { s.append(c); } } else { s.append(c); } i++; } systemName = s.toString(); systemName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, systemName); systemName = CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_UNDERSCORE, systemName); systemName = StringUtils.replace(systemName, "__", "_"); // Truncate length if exceeds Hive limit systemName = (systemName.length() > 128 ? systemName.substring(0, 127) : systemName); return systemName; }
From source file:com.facebook.buck.core.rules.provider.DefaultBuildRuleInfoProvider.java
/** * @return the type of the {@link com.facebook.buck.core.rules.BuildRule} as defined by the * interface {@link com.facebook.buck.core.rules.BuildRule#getType()} *//* w ww . j av a 2s . c o m*/ @Value.Lazy public String getType() { Class<?> clazz = getTypeClass(); if (clazz.isAnonymousClass()) { clazz = clazz.getSuperclass(); } return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, clazz.getSimpleName()).intern(); }
From source file:org.dbunitng.beans.BeanMetaData.java
/** * ????//from www . jav a2 s . co m */ protected void retrievePropertiesByField() { Field[] fields = targetClass.getFields(); for (int i = 0; i < fields.length; ++i) { Field field = fields[i]; field.setAccessible(true); if (PropertyUtil.isInstanceField(field)) { String fname = field.getName(); BeanProperty property = propertyMap.get(fname); if (property == null) { property = new BeanProperty(fname, field.getType(), field, null, null); propertyMap.put(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, fname), property); } else if (PropertyUtil.isPublicField(field)) { property.setField(field); } } } }
From source file:com.github.ko2ic.plugin.eclipse.taggen.common.domain.valueobject.NameRuleString.java
public String toUpperCamel() { String value = str;//w ww .j a v a2 s . com if (Character.isUpperCase(str.charAt(0))) { if (str.contains("_")) { value = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, str); } } else { if (str.contains("_")) { value = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, str); } else { value = CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, str); } } return value; }
From source file:org.sonarqube.wsgenerator.Helper.java
private String rawName(String path) { String x = path.replaceFirst("^api\\/", ""); if (x.contains("_")) { return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, x.toLowerCase()); }//w w w . j a va2 s .c om return capitalizeFirstLetter(x); }