List of usage examples for com.google.common.base CaseFormat UPPER_CAMEL
CaseFormat UPPER_CAMEL
To view the source code for com.google.common.base CaseFormat UPPER_CAMEL.
Click Source Link
From source file:com.github.ko2ic.plugin.eclipse.taggen.common.domain.valueobject.NameRuleString.java
public String toUpperCamel() { String value = str;/* w w w . j a v a 2 s . c o m*/ 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.lendingclub.mercator.docker.DockerSerializerModule.java
public ObjectNode flatten(JsonNode n) { ObjectNode out = vanillaObjectMapper.createObjectNode(); Converter<String, String> caseFormat = CaseFormat.UPPER_CAMEL.converterTo(CaseFormat.LOWER_CAMEL); n.fields().forEachRemaining(it -> { JsonNode val = it.getValue(); String key = it.getKey(); key = caseFormat.convert(key);/*from ww w. j a v a 2 s . co m*/ if (val.isValueNode()) { out.set(key, it.getValue()); } else if (val.isArray()) { if (val.size() == 0) { out.set(key, val); } boolean valid = true; Class<? extends Object> type = null; ArrayNode an = (ArrayNode) val; for (int i = 0; valid && i < an.size(); i++) { if (!an.get(i).isValueNode()) { valid = false; } if (type != null && an.get(i).getClass() != type) { valid = false; } } } }); renameAttribute(out, "oSType", "osType"); renameAttribute(out, "iD", "id"); renameAttribute(out, "neventsListener", "nEventsListener"); renameAttribute(out, "cPUSet", "cpuSet"); renameAttribute(out, "cPUShares", "cpuShares"); renameAttribute(out, "iPv4Forwarding", "ipv4Forwarding"); renameAttribute(out, "oOMKilled", "oomKilled"); renameAttribute(out, "state_oomkilled", "state_oomKilled"); renameAttribute(out, "bridgeNfIptables", "bridgeNfIpTables"); renameAttribute(out, "bridgeNfIp6tables", "bridgeNfIp6Tables"); out.remove("ngoroutines"); return out; }
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; }/*from w w w. j a v a2s .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()} *///from ww w.j a v a 2s. com @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:aritzh.waywia.universe.World.java
public static World newWorld(String name, File universeFolder) throws IOException { String folderName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, name); File root = new File(universeFolder, folderName); if (!root.exists() && !root.mkdirs()) throw new IOException("Could not create folder for new world at: " + root.getAbsolutePath()); BDSCompound customData = new BDSCompound("CustomData"); Multimap<String, Entity> entities = ArrayListMultimap.create(); HashMap<String, Player> player = Maps.newHashMap(); Matrix<Block> blocks = new Matrix<>(50, 38, new BackgroundBlock()); return new World(name, root, customData, entities, player, blocks); }
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:org.openehr.designer.json.AmTypeIdResolver.java
private void addClassesFromObjectFactory(Map<String, Class> target, Class<?> objectFactory) { for (Method method : objectFactory.getMethods()) { if (method.getName().startsWith("create")) { if (method.getParameterCount() == 0) { Class c = method.getReturnType(); target.put(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, c.getSimpleName()), c); } else { Class c = method.getParameterTypes()[0]; target.put(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, c.getSimpleName()), c); }// ww w . j av a2 s . c o m } } }
From source file:com.opengamma.strata.product.credit.type.CdsQuoteConvention.java
/** * Obtains an instance from the specified unique name. * // ww w . jav a 2s.co m * @param uniqueName the unique name * @return the type * @throws IllegalArgumentException if the name is not known */ @FromString public static CdsQuoteConvention of(String uniqueName) { ArgChecker.notNull(uniqueName, "uniqueName"); return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, uniqueName)); }
From source file:com.cinchapi.concourse.server.cli.ManagedOperationCli.java
/** * Construct a new instance that is seeded with an object containing options * metadata. The {@code options} will be parsed by {@link JCommander} to * configure them appropriately./* w w w . java 2 s .c o m*/ * * @param options * @param args - these usually come from the main method */ public ManagedOperationCli(Options options, String... args) { try { this.parser = new JCommander(options, args); this.options = options; parser.setProgramName( CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, this.getClass().getSimpleName())); if (!isReadyToRun()) { parser.usage(); System.exit(1); } this.console = new ConsoleReader(); console.setExpandEvents(false); } catch (ParameterException e) { die(e.getMessage()); } catch (IOException e) { die(e.getMessage()); } }
From source file:growthcraft.api.core.item.EnumDye.java
public String getOreName() { return String.format("dye%s", CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name())); }