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:org.ballerinalang.composer.service.workspace.tools.ModelGenerator.java
public static JsonObject getContext() { // Set alias for the classes alias.put("ImportNode", "ImportPackageNode"); alias.put("RecordLiteralKeyValueNode", "RecordKeyValueNode"); alias.put("XmlnsNode", "XMLNSDeclarationNode"); alias.put("ArrayLiteralExprNode", "ArrayLiteralNode"); alias.put("BinaryExprNode", "BinaryExpressionNode"); alias.put("ConnectorInitExprNode", "ConnectorInitNode"); alias.put("FieldBasedAccessExprNode", "FieldBasedAccessNode"); alias.put("IndexBasedAccessExprNode", "IndexBasedAccessNode"); alias.put("LambdaNode", "LambdaFunctionNode"); alias.put("RecordLiteralExprNode", "RecordLiteralNode"); alias.put("SimpleVariableRefNode", "SimpleVariableReferenceNode"); alias.put("TernaryExprNode", "TernaryExpressionNode"); alias.put("TypeCastExprNode", "TypeCastNode"); alias.put("TypeConversionExprNode", "TypeConversionNode"); alias.put("UnaryExprNode", "UnaryExpressionNode"); alias.put("XmlAttributeNode", "XMLAttributeNode"); alias.put("XmlCommentLiteralNode", "XMLCommentLiteralNode"); alias.put("XmlElementLiteralNode", "XMLElementLiteralNode"); alias.put("XmlPiLiteralNode", "XMLProcessingInstructionLiteralNode"); alias.put("XmlQnameNode", "XMLQNameNode"); alias.put("XmlQuotedStringNode", "XMLQuotedStringNode"); alias.put("XmlTextLiteralNode", "XMLTextLiteralNode"); alias.put("TryNode", "TryCatchFinallyNode"); alias.put("VariableDefNode", "VariableDefinitionNode"); alias.put("BuiltInRefTypeNode", "BuiltInReferenceTypeNode"); alias.put("EnumeratorNode", "EnumNode"); List<Class<?>> list = ModelGenerator.find("org.ballerinalang.model.tree"); NodeKind[] nodeKinds = NodeKind.class.getEnumConstants(); JsonObject nodes = new JsonObject(); for (NodeKind node : nodeKinds) { String nodeKind = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, node.toString()); String nodeClassName = nodeKind + "Node"; try {/* ww w . ja va2 s . c o m*/ String actualClassName = (alias.get(nodeClassName) != null) ? alias.get(nodeClassName) : nodeClassName; Class<?> clazz = list.stream() .filter(nodeClass -> nodeClass.getSimpleName().equals(actualClassName)).findFirst().get(); JsonObject nodeObj = new JsonObject(); nodeObj.addProperty("kind", nodeKind); nodeObj.addProperty("name", nodeClassName); nodeObj.addProperty("fileName", CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, nodeClassName)); JsonArray attr = new JsonArray(); JsonArray bools = new JsonArray(); JsonArray imports = new JsonArray(); List<String> parents = Arrays.asList(clazz.getInterfaces()).stream() .map(parent -> parent.getSimpleName()).collect(Collectors.toList()); // tag object with supper type if (parents.contains("StatementNode")) { nodeObj.addProperty("isStatement", true); JsonObject imp = new JsonObject(); imp.addProperty("returnType", "StatementNode"); imp.addProperty("returnTypeFile", "statement-node"); imports.add(imp); } else { nodeObj.addProperty("isStatement", false); } if (parents.contains("ExpressionNode")) { nodeObj.addProperty("isExpression", true); JsonObject imp = new JsonObject(); imp.addProperty("returnType", "ExpressionNode"); imp.addProperty("returnTypeFile", "expression-node"); imports.add(imp); } else { nodeObj.addProperty("isExpression", false); } if (!parents.contains("StatementNode") && !parents.contains("ExpressionNode")) { JsonObject imp = new JsonObject(); imp.addProperty("returnType", "Node"); imp.addProperty("returnTypeFile", "node"); imports.add(imp); } Method[] methods = clazz.getMethods(); for (Method m : methods) { String methodName = m.getName(); if ("getKind".equals(methodName) || "getWS".equals(methodName) || "getPosition".equals(methodName)) { continue; } if (methodName.startsWith("get")) { JsonObject attribute = new JsonObject(); JsonObject imp = new JsonObject(); attribute.addProperty("property", toJsonName(m.getName(), 3)); attribute.addProperty("methodSuffix", m.getName().substring(3)); attribute.addProperty("list", List.class.isAssignableFrom(m.getReturnType())); attribute.addProperty("isNode", Node.class.isAssignableFrom(m.getReturnType())); if (Node.class.isAssignableFrom(m.getReturnType())) { String returnClass = m.getReturnType().getSimpleName(); if (alias.containsValue(m.getReturnType().getSimpleName())) { returnClass = getKindForAliasClass(m.getReturnType().getSimpleName()); } imp.addProperty("returnType", returnClass); attribute.addProperty("returnType", returnClass); imp.addProperty("returnTypeFile", CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, returnClass)); if (!imports.contains(imp)) { imports.add(imp); } } attr.add(attribute); } if (methodName.startsWith("is")) { JsonObject attribute = new JsonObject(); JsonObject imp = new JsonObject(); attribute.addProperty("property", toJsonName(m.getName(), 2)); attribute.addProperty("methodSuffix", m.getName().substring(2)); attribute.addProperty("list", List.class.isAssignableFrom(m.getReturnType())); attribute.addProperty("isNode", Node.class.isAssignableFrom(m.getReturnType())); if (Node.class.isAssignableFrom(m.getReturnType())) { String returnClass = m.getReturnType().getSimpleName(); if (alias.containsValue(m.getReturnType().getSimpleName())) { returnClass = getKindForAliasClass(m.getReturnType().getSimpleName()); } imp.addProperty("returnType", returnClass); attribute.addProperty("returnType", returnClass); imp.addProperty("returnTypeFile", CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, returnClass)); if (!imports.contains(imp)) { imports.add(imp); } } bools.add(attribute); } } nodeObj.add("attributes", attr); nodeObj.add("bools", bools); nodeObj.add("imports", imports); nodes.add(nodeClassName, nodeObj); } catch (NoSuchElementException e) { out.println("alias.put(\"" + nodeClassName + "\", \"\");"); } } out.println(nodes); return nodes; }
From source file:org.syncany.plugins.transfer.TransferPluginUtil.java
/** * Determines the {@link TransferPlugin} class for a given * {@link TransferSettings} class./*from ww w . j a v a2s . co m*/ */ public static Class<? extends TransferPlugin> getTransferPluginClass( Class<? extends TransferSettings> transferSettingsClass) { String pluginNameIdentifier = TransferPluginUtil.getPluginPackageName(transferSettingsClass); if (pluginNameIdentifier == null) { throw new RuntimeException( "The transfer settings are orphan (" + transferSettingsClass.getName() + ")"); } else { try { String pluginPackageIdentifier = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, pluginNameIdentifier); String transferPluginClassName = MessageFormat.format(PLUGIN_TRANSFER_PLUGIN_CLASS_NAME, pluginPackageIdentifier, pluginNameIdentifier); return Class.forName(transferPluginClassName).asSubclass(TransferPlugin.class); } catch (Exception e) { throw new RuntimeException("Cannot find matching transfer plugin class for plugin settings (" + transferSettingsClass.getName() + ")"); } } }
From source file:com.facebook.presto.operator.aggregation.AggregationUtils.java
public static String generateAggregationName(String baseName, Type outputType, List<Type> inputTypes) { StringBuilder sb = new StringBuilder(); sb.append(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, outputType.getTypeSignature().toString())); for (Type inputType : inputTypes) { sb.append(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, inputType.getTypeSignature().toString())); }/*www . j a v a 2 s . c o m*/ sb.append(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, baseName.toLowerCase(ENGLISH))); return sb.toString(); }
From source file:org.abstractmeta.reflectify.plugin.ReflectifyGenerator.java
private void buildProvider(List<String> result, JavaTypeRegistry registry, Descriptor descriptor) { if (result.size() == 0) { return;// w ww.java 2 s. c o m } JavaTypeBuilder registryTypeBuilder = new JavaTypeBuilder(); registryTypeBuilder.addImportType(Arrays.class); String targetPackage = descriptor.getTargetPackage(); if (targetPackage == null) { targetPackage = StringUtil.substringBeforeLastIndexOf(descriptor.getSourcePackage(), "."); } int lastDotPosition = targetPackage.lastIndexOf('.'); int nextToLastDotPosition = targetPackage.lastIndexOf('.', lastDotPosition - 3); String parentPackage = targetPackage.substring(nextToLastDotPosition + 1, lastDotPosition); String providerTypeName = targetPackage + "." + StringUtil.format(CaseFormat.UPPER_CAMEL, parentPackage, "reflectifyProvider", CaseFormat.LOWER_CAMEL); Type resultType = new ParameterizedTypeImpl(null, Collection.class, Reflectify.class); registryTypeBuilder.addModifier("public").setTypeName(providerTypeName) .addSuperInterface(new ParameterizedTypeImpl(null, Provider.class, resultType)); JavaMethodBuilder methodBuilder = new JavaMethodBuilder().addModifier("public").setName("get") .setResultType(resultType); List<String> generatedTypes = new ArrayList<String>(); for (String generatedType : result) { registryTypeBuilder.addImportType(new TypeNameWrapper(generatedType)); generatedTypes.add("\n new " + JavaTypeUtil.getSimpleClassName(generatedType, true) + "()"); } methodBuilder.addBody(String.format("return Arrays.<%s>asList(%s);", Reflectify.class.getSimpleName(), Joiner.on(",").join(generatedTypes))); registryTypeBuilder.addMethod(methodBuilder.build()); registry.register(registryTypeBuilder.build()); result.add(registryTypeBuilder.getName()); }
From source file:com.cinchapi.concourse.server.http.EndpointContainer.java
/** * Given a {@link RoutingKey}, return the canonical namespace that should be * used as a prefix when referring to the container's classes. * /*from w w w. j av a 2 s. co m*/ * <p> * The namespace is instrumental for properly constructing the URI where the * container's functionality lives. * </p> * * @param id a {@link RoutingKey} * @return the canonical namespace to use when constructing the URI */ private static String getCanonicalNamespace(RoutingKey id) { String namespace; if (id.group.equals("com.cinchapi")) { if (id.module.equals("server")) { namespace = id.cls; } else { namespace = Strings.join('/', id.module, id.cls); } } else { namespace = Strings.join('/', id.group, id.module, id.cls); } namespace = namespace.replace("Router", ""); namespace = namespace.replace("Index", ""); namespace = namespace.replaceAll("\\.", "/"); namespace = namespace.replaceAll("_", "/"); namespace = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, namespace); namespace = namespace.replaceAll("/-", "/"); namespace = Strings.ensureStartsWith(namespace, "/"); namespace = Strings.ensureEndsWith(namespace, "/"); return namespace; }
From source file:com.github.jcustenborder.kafka.connect.utils.templates.model.Example.java
String transformKey() { StringBuilder builder = new StringBuilder(); if ("Key".equalsIgnoreCase(this.className.getSimpleName()) || "Value".equalsIgnoreCase(this.className.getSimpleName())) { builder.append(this.className.getSuperclass().getSimpleName()); builder.append(this.className.getSimpleName()); } else {/*from ww w . j ava2 s. c om*/ builder.append(this.className.getSimpleName()); } String result = builder.toString(); return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, result); }
From source file:com.amazonaws.util.awsclientgenerator.domainmodels.codegeneration.cpp.CppViewHelper.java
public static String convertToUpperCamel(String lowerCamel) { return CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, lowerCamel); }
From source file:com.tactfactory.harmony.generator.BundleGenerator.java
/** * Generate bundle's parser./*from w ww . j a va2s .c o m*/ * @param bundleOwnerName Owner name * @param bundleName Bundle name * @param bundleNameSpace Bundle namespace */ private void generateParser(final String bundleOwnerName, final String bundleName, final String bundleNameSpace) { final String tplPath = this.getAdapter().getParserBundleTemplatePath() + "/TemplateParser.java"; final String genPath = this.getAdapter().getParserBundlePath(bundleOwnerName, bundleNameSpace, bundleName) + "/" + CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, bundleName) + "Parser.java"; this.makeSource(tplPath, genPath, false); }
From source file:com.android.tools.idea.ui.properties.demo.CorePropertiesDemo.java
public CorePropertiesDemo() { final Person person = new Person(); for (Gender gender : Gender.values()) { myGenderCombo.addItem(gender);//from ww w . jav a2 s.co m } myGenderCombo.setSelectedItem(person.myGender.get()); /** * Hook up the first panel (which modifies the target person) */ myBindings.bindTwoWay(new TextProperty(myNameTextField), person.myName); myBindings.bindTwoWay(new SliderValueProperty(myAgeSlider), person.myAge); myBindings.bind(new TextProperty(myAgeLabel), new FormatExpression("%d", person.myAge)); myBindings.bindTwoWay(new SelectedProperty(myCitizenshipCheckBox), person.myIsCitizen); final TextProperty employerName = new TextProperty(myEmployerTextField); myBindings.bind(person.myEmployer, new Expression<Optional<String>>(employerName) { @NotNull @Override public Optional<String> get() { return employerName.get().trim().isEmpty() ? Optional.empty() : Optional.of(employerName.get()); } }); SelectedItemProperty<Gender> selectedGender = new SelectedItemProperty<>(myGenderCombo); myBindings.bind(person.myGender, new TransformOptionalExpression<Gender, Gender>(Gender.OTHER, selectedGender) { @NotNull @Override protected Gender transform(@NotNull Gender gender) { return gender; } }); /** * Hook up the second panel (which prints out useful information about the person) */ myBindings.bind(new TextProperty(myIsValidNameLabel), new YesNoExpression(person.myName.isEmpty().not())); myBindings.bind(new TextProperty(myGenderLabel), new StringExpression(person.myGender) { @NotNull @Override public String get() { return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, person.myGender.toString()); } }); myBindings.bind(new TextProperty(myCanVoteLabel), new YesNoExpression(person.myIsCitizen.and(person.myAge.isGreaterThanEqualTo(16)))); myBindings.bind(new TextProperty(myHasEmployerLabel), new TransformOptionalExpression<String, String>("No", person.myEmployer) { @NotNull @Override protected String transform(@NotNull String value) { return String.format("Yes (%s)", value.trim()); } }); }
From source file:com.tactfactory.harmony.meta.FieldMetadata.java
/** Add Component String of field. * @param componentName The component name *//*from w ww. ja v a 2 s. c om*/ public final void makeString(final String componentName) { if (!this.hidden && !this.internal && (this.owner instanceof EntityMetadata) && (!((EntityMetadata) this.owner).isCreateAction() || ((EntityMetadata) this.owner).isShowAction() || ((EntityMetadata) this.owner).isEditAction()) && !((EntityMetadata) this.owner).isInternal()) { final String key = this.owner.getName().toLowerCase() + "_" + this.getName().toLowerCase(); if (this.harmonyType != null) { final boolean isDate = this.harmonyType.equals(Type.DATE.getValue()); final boolean isTime = this.harmonyType.equals(Type.TIME.getValue()); final boolean isDateTime = this.harmonyType.equals(Type.DATETIME.getValue()); if (isDate || isDateTime || isTime) { final String formatKey = "%s_%s_title"; final String formatTitle = "Select %s %s"; if (isDate || isDateTime) { TranslationMetadata.addDefaultTranslation( String.format(formatKey, key, Type.DATE.getValue()), String.format(formatTitle, this.getName(), Type.DATE.getValue()), Group.MODEL); } if (isTime || isDateTime) { TranslationMetadata.addDefaultTranslation( String.format(formatKey, key, Type.TIME.getValue()), String.format(formatTitle, this.getName(), Type.TIME.getValue()), Group.MODEL); } } } TranslationMetadata.addDefaultTranslation(key + "_" + componentName.toLowerCase(Locale.ENGLISH), CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, this.getName()), Group.MODEL); if (!this.nullable && !this.harmonyType.equalsIgnoreCase("boolean") && !this.harmonyType.equalsIgnoreCase(Type.ENUM.getValue()) && !this.columnResult) { TranslationMetadata.addDefaultTranslation(key + "_invalid_field_error", "Field " + CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, this.getName()) + " is invalid.", Group.MODEL); } } }