List of usage examples for com.google.common.base CaseFormat LOWER_CAMEL
CaseFormat LOWER_CAMEL
To view the source code for com.google.common.base CaseFormat LOWER_CAMEL.
Click Source Link
From source file:com.github.benmanes.caffeine.cache.Specifications.java
/** Returns the offset constant to this variable. */ public static String offsetName(String varName) { return CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, varName) + "_OFFSET"; }
From source file:com.tactfactory.harmony.meta.FieldMetadata.java
/** Add Component String of field. * @param componentName The component name *//*from w ww. j a v a 2 s . c o m*/ 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); } } }
From source file:com.google.api.tools.framework.model.FieldSelector.java
/** * Returns the HTTP parameter name of this selector. This is the sequence of proto field names * lower-cameled and joined by '.'.//from w ww . j av a 2 s . c om */ public String getParamName() { if (paramName != null) { return paramName; } return paramName = Joiner.on('.').join(FluentIterable.from(fields).transform(new Function<Field, String>() { @Override public String apply(Field field) { return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, field.getSimpleName()); } })); }
From source file:dagger.internal.codegen.SourceFiles.java
private static String fieldNameForDependency(ImmutableSet<DependencyRequest> dependencyRequests) { // collect together all of the names that we would want to call the provider ImmutableSet<String> dependencyNames = FluentIterable.from(dependencyRequests) .transform(new DependencyVariableNamer()).toSet(); if (dependencyNames.size() == 1) { // if there's only one name, great! use it! return Iterables.getOnlyElement(dependencyNames); } else {/*from ww w. j a va 2 s . c om*/ // in the event that a field is being used for a bunch of deps with different names, // add all the names together with "And"s in the middle. E.g.: stringAndS Iterator<String> namesIterator = dependencyNames.iterator(); String first = namesIterator.next(); StringBuilder compositeNameBuilder = new StringBuilder(first); while (namesIterator.hasNext()) { compositeNameBuilder.append("And") .append(CaseFormat.LOWER_CAMEL.to(UPPER_CAMEL, namesIterator.next())); } return compositeNameBuilder.toString(); } }
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 {/*from w w w.ja v a2 s .co 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.atteo.moonshine.ConfigurationReader.java
/** * Generate auto-config.xml.//from w w w . j ava 2s . c om */ public void generateAutoConfiguration() throws IncorrectConfigurationException, IOException { Iterable<Class<? extends Service>> services = ClassFilter.only().topLevel() .withoutModifiers(Modifier.ABSTRACT).satisfying(TopLevelService.class::isAssignableFrom) .satisfying((Class<?> type) -> !containsRequiredFieldWithoutDefault(type)) .satisfying((Class<?> type) -> { ServiceConfiguration annotation = type.getAnnotation(ServiceConfiguration.class); return annotation == null || annotation.auto(); }).from(ClassIndex.getSubclasses(Service.class)); StringBuilder builder = new StringBuilder(); builder.append("<config xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" + " xsi:noNamespaceSchemaLocation=\"" + SCHEMA_FILE_NAME + "\">\n"); for (Class<? extends Service> service : services) { ServiceConfiguration annotation = service.getAnnotation(ServiceConfiguration.class); String name = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, service.getSimpleName()); XmlRootElement xmlRootElement = service.getAnnotation(XmlRootElement.class); if (xmlRootElement != null && !"##default".equals(xmlRootElement.name())) { name = xmlRootElement.name(); } builder.append("\t<").append(name); builder.append(" combine.self='").append(CombineSelf.OVERRIDABLE_BY_TAG.name()); if (annotation == null || annotation.autoConfiguration().isEmpty()) { builder.append("'/>\n"); } else { builder.append("'>\n"); builder.append(annotation.autoConfiguration()); builder.append("\n</").append(name).append(">\n"); } } builder.append("</config>\n"); Path autoConfigPath = fileAccessor.getWritableConfigFile(AUTO_CONFIG_FILE_NAME); try (Writer writer = Files.newBufferedWriter(autoConfigPath, Charsets.UTF_8)) { writer.write(builder.toString()); } }
From source file:com.jedi.metadata.DatabaseMetadataUtil.java
public static List<ArgumentMetadata> getProcedureArguments(Connection connection, ProcedureMetadata procedureMetadata) throws SQLException { List<ArgumentMetadata> result = new ArrayList<ArgumentMetadata>(); String sql = "SELECT ARGUMENT_NAME," + " POSITION," + " SEQUENCE," + " DATA_TYPE," + " IN_OUT," + " DATA_LENGTH," + " DATA_PRECISION," + " DATA_SCALE," + " RADIX," + " TYPE_OWNER," + " TYPE_NAME," + " PLS_TYPE" + " FROM ALL_ARGUMENTS" + " WHERE OBJECT_ID = " + procedureMetadata.getPackageId() + " AND SUBPROGRAM_ID = " + procedureMetadata.getId() + " AND DATA_LEVEL=0"; Statement statement = connection.createStatement(); ResultSet resultSet = statement.executeQuery(sql); while (resultSet.next()) { ArgumentMetadata argumentMetadata = new ArgumentMetadata(); String argumentName = resultSet.getString("ARGUMENT_NAME"); argumentMetadata.setName(argumentName); argumentMetadata.setPosition(resultSet.getInt("POSITION")); argumentMetadata.setSequence(resultSet.getInt("SEQUENCE")); String datatype = resultSet.getString("DATA_TYPE"); argumentMetadata.setDataType(datatype); argumentMetadata.setInOut(resultSet.getString("IN_OUT")); argumentMetadata.setLength(resultSet.getInt("DATA_LENGTH")); argumentMetadata.setPrecision(resultSet.getInt("DATA_PRECISION")); argumentMetadata.setScale(resultSet.getInt("DATA_SCALE")); argumentMetadata.setRadix(resultSet.getInt("RADIX")); argumentMetadata.setCustomTypeOwner(resultSet.getString("TYPE_OWNER")); argumentMetadata.setCustomTypeName(resultSet.getString("TYPE_NAME")); argumentMetadata.setPlsType(resultSet.getString("PLS_TYPE")); if (argumentName != null && !argumentName.isEmpty()) { argumentName = argumentName.toUpperCase(); if (argumentName.startsWith("P_")) { argumentName = argumentName.substring(2); }/*from ww w .j a v a 2s .co m*/ String fieldName = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, argumentName); argumentMetadata.setFieldName(fieldName); } else { String fieldName = "result"; argumentMetadata.setFieldName(fieldName); } String javaType = getJavaType(datatype); argumentMetadata.setFieldType(javaType); result.add(argumentMetadata); } return result; }
From source file:com.google.gcloud.Identity.java
/** * Converts a string to an {@code Identity}. Used primarily for converting protobuf-generated * policy identities to {@code Identity} objects. *//*from w w w . j a v a 2s. c om*/ public static Identity valueOf(String identityStr) { String[] info = identityStr.split(":"); Type type = Type.valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, info[0])); switch (type) { case ALL_USERS: return Identity.allUsers(); case ALL_AUTHENTICATED_USERS: return Identity.allAuthenticatedUsers(); case USER: return Identity.user(info[1]); case SERVICE_ACCOUNT: return Identity.serviceAccount(info[1]); case GROUP: return Identity.group(info[1]); case DOMAIN: return Identity.domain(info[1]); default: throw new IllegalStateException("Unexpected identity type " + type); } }
From source file:co.leugim.jade4ninja.template.JadeModelParamsBuilder.java
protected Map<String, Object> getRenderableResult() { Object object = result.getRenderable(); Map<String, Object> model; if (object == null) { model = Maps.newHashMap();/* w w w. ja v a2 s . co m*/ } else if (object instanceof Map) { @SuppressWarnings("unchecked") Map<String, Object> map = (Map<String, Object>) object; model = map; } else { model = Maps.newHashMap(); String realClassNameLowerCamelCase = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, object.getClass().getSimpleName()); model.put(realClassNameLowerCamelCase, object); } return model; }
From source file:com.tactfactory.harmony.generator.BundleGenerator.java
/** * Generate command file for empty bundle. * @param bundleOwnerName Owner name/*from www.j av a 2 s . com*/ * @param bundleName Bundle name * @param bundleNameSpace Bundle namespace */ private void generateCommand(final String bundleOwnerName, final String bundleName, final String bundleNameSpace) { final String tplPath = this.getAdapter().getCommandBundleTemplatePath() + "/TemplateCommand.java"; final String genPath = this.getAdapter().getCommandBundlePath(bundleOwnerName, bundleNameSpace, bundleName) + "/" + CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, bundleName) + "Command.java"; this.makeSource(tplPath, genPath, false); }