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:com.marvinformatics.querydsl.HardcodedSchemaGenerator.java
public static void main(String[] args) throws Exception { Cluster cluster = Cluster.builder().addContactPoints("localhost").withPort(9042).build(); Metadata metadata = cluster.getMetadata(); List<KeyspaceMetadata> keyspaces = metadata.getKeyspaces(); for (KeyspaceMetadata keyspace : keyspaces) { Collection<TableMetadata> tables = keyspace.getTables(); for (TableMetadata table : tables) { String keyspaceName = keyspace.getName(); String packageName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, keyspaceName) .toLowerCase();/* www .j a va 2 s .com*/ String tableName = table.getName(); String className = "Q" + CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, tableName); File directory = new File("src/main/java/com/marvinformatics/test", packageName); directory.mkdirs(); File file = new File(directory, className + ".java"); file.delete(); try (PrintWriter pw = new PrintWriter(file);) { pw.println("package com.marvinformatics.test." + packageName + ";"); pw.println(); String variableName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, tableName); pw.println("@javax.annotation.Generated(\"HardcodedSchemaGenerator\")"); pw.println("public class " + className + " extends com.querydsl.core.types.dsl.BeanPath<" + className + "> {"); pw.println(); pw.println(" public static final " + className + " " + variableName + " = new " + className + "(\"" + variableName + "\");"); List<ColumnMetadata> columns = table.getColumns(); for (ColumnMetadata column : columns) { String columnName = column.getName(); String fieldName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, columnName); Optional<Class<? extends Path>> pathType = getPathType(column.getType()); if (pathType.isPresent()) { pw.println(); pw.println(" public final " + toString(pathType, column.getType()) + " " + fieldName + " = " + create(columnName, column.getType()) + ";"); } else { pw.println(); pw.println(" // public final " + column.getType() + " " + fieldName + " = null\");"); } } pw.println(" public " + className + "(String variable) {\n" + " super(" + className + ".class, variable);\n" + " }"); pw.println(); pw.println("}"); } } } cluster.close(); }
From source file:org.assertj.assertions.generator.util.StringUtil.java
public static String camelCaseToWords(String camleCaseString) { return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, camleCaseString).replace('_', ' '); }
From source file:com.facebook.buck.core.rules.type.impl.RuleTypeFactory.java
public static RuleType fromClassName(Class<?> cls) { String result = cls.getSimpleName(); result = MoreStrings.stripPrefix(result, "Abstract").orElse(result); result = MoreStrings.stripSuffix(result, "Description").orElse(result); return RuleType.of(CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, result)); }
From source file:org.zalando.baigan.proxy.ProxyUtils.java
public static String dottify(final String text) { if (Strings.isNullOrEmpty(text)) { return NAMESPACE_SEPARATOR; }/*from w w w . jav a 2s . c o m*/ return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, text).replace("_", NAMESPACE_SEPARATOR); }
From source file:com.facebook.buck.core.model.impl.RuleTypeFactory.java
public static RuleType create(Class<?> cls, RuleType.Kind ruleKind) { String result = cls.getSimpleName(); result = MoreStrings.stripPrefix(result, "Abstract").orElse(result); result = MoreStrings.stripSuffix(result, "Description").orElse(result); return RuleType.of(CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, result), ruleKind); }
From source file:aeon.compiler.utils.SqliteUtils.java
/** * Converts a camelCase class or field name into an entity name with underscore-notation for use as a SQLite * table or column name.// w ww. ja va 2 s . c o m * * @param name camelCase class or field name * @return Entity name in underscore-notation */ @NotNull public static String entityName(@NotNull final String name) { checkNotNull(name); return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, name); }
From source file:com.google.api.tools.framework.importers.swagger.NameConverter.java
static String getFieldName(String jsonName) { return CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, sanitizeStringValue(jsonName)); }
From source file:com.google.api.tools.framework.importers.swagger.aspects.utils.NameConverter.java
public static String getFieldName(String jsonName) { return CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, sanitizeStringValue(jsonName)); }
From source file:org.springframework.data.cassandra.util.CassandraNamingUtils.java
/** * Obtains the table name to use for the provided class. * Converts upper-camel org.springframework.data.cassandra.entity name to lower-underscore format. * // ww w .j a v a 2 s. co m * @param entityClass The class to determine the preferred table name for * @return The preferred collection name */ public static String guessTableName(Class<?> entityClass) { return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, entityClass.getSimpleName()); }
From source file:com.cinchapi.common.base.CaseFormats.java
/** * Detect the {@link CaseFormat} that describes the {@code string}. * /*from w ww . j a v a2s. c o m*/ * @param string * @return the best fit {@link CaseFormat} description */ public static CaseFormat detect(String string) { if (string.contains("-")) { return CaseFormat.LOWER_HYPHEN; } else if (string.contains("_")) { for (char c : string.toCharArray()) { if (Character.isUpperCase(c)) { return CaseFormat.UPPER_UNDERSCORE; } } return CaseFormat.LOWER_UNDERSCORE; } else if (Character.isLowerCase(string.toCharArray()[0])) { return CaseFormat.LOWER_CAMEL; } else { return CaseFormat.UPPER_CAMEL; } }