Example usage for com.google.common.base CaseFormat LOWER_UNDERSCORE

List of usage examples for com.google.common.base CaseFormat LOWER_UNDERSCORE

Introduction

In this page you can find the example usage for com.google.common.base CaseFormat LOWER_UNDERSCORE.

Prototype

CaseFormat LOWER_UNDERSCORE

To view the source code for com.google.common.base CaseFormat LOWER_UNDERSCORE.

Click Source Link

Document

C++ variable naming convention, e.g., "lower_underscore".

Usage

From source file:com.noorq.casser.mapping.convert.CamelCaseToUnderscoreConverter.java

@Override
public String apply(String source) {

    if (source == null) {
        throw new IllegalArgumentException("empty parameter");
    }//w  w  w .  j  a va2 s .  c om

    return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, source);
}

From source file:fr.obeo.intent.spec2test.services.NamedElementUtils.java

/**
 * Returns the element name in camel case
 * /* w  ww  .j av  a 2s  . c om*/
 * @param namedElement
 *            Named element
 * @return the element name in camel case
 */
public String getCamelCaseName(NamedElement namedElement) {
    String name = namedElement.getName().replaceAll(" ", "_");
    return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name);
}

From source file:edu.berkeley.ground.postgres.util.PostgresUtils.java

public static String executeQueryToJson(Database dbSource, String sql) throws GroundException {
    Logger.debug("executeQueryToJson: {}", sql);

    try {//w ww  .j a  v a2  s  .co m
        Connection con = dbSource.getConnection();
        Statement stmt = con.createStatement();

        final ResultSet resultSet = stmt.executeQuery(sql);
        final long columnCount = resultSet.getMetaData().getColumnCount();
        final List<Map<String, Object>> objList = new ArrayList<>();

        while (resultSet.next()) {
            final Map<String, Object> rowData = new HashMap<>();

            for (int column = 1; column <= columnCount; column++) {
                String key = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL,
                        resultSet.getMetaData().getColumnLabel(column));
                rowData.put(key, resultSet.getObject(column));
            }

            objList.add(rowData);
        }

        stmt.close();
        con.close();
        return GroundUtils.listToJson(objList);
    } catch (SQLException e) {
        Logger.error("ERROR:  executeQueryToJson  SQL : {} Message: {} Trace: {}", sql, e.getMessage(),
                e.getStackTrace());
        throw new GroundException(e);
    }
}

From source file:com.google.api.codegen.LanguageUtil.java

public static String lowerUnderscoreToUpperCamel(String name) {
    return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name);
}

From source file:org.elasticsearch.plugin.readonlyrest.acl.blocks.rules.SyncRule.java

protected String mkKey(Class<? extends Rule> c) {
    return CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, c.getSimpleName().replace("SyncRule", ""));
}

From source file:com.spectralogic.ds3cli.command.CliCommandFactory.java

public static String listAllCommands() {
    final StringBuilder commandHelp = new StringBuilder("Installed Commands: ");

    final FluentIterable<String> commands = FluentIterable.from(getAllCommands())
            .transform(new Function<CliCommand, String>() {
                @Nullable/*  w  ww  .  ja  v  a 2s .  co  m*/
                @Override
                public String apply(@Nullable final CliCommand input) {
                    return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE,
                            input.getClass().getSimpleName());
                }
            });
    final Joiner joiner = Joiner.on(", ");
    commandHelp.append(joiner.join(commands));
    return commandHelp.toString();
}

From source file:com.netflix.paas.dao.astyanax.AstyanaxDao.java

private static String entityNameFromClass(Class<?> entityType) {
    return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE,
            StringUtils.removeEnd(StringUtils.substringAfterLast(entityType.getName(), "."), "Entity"));
}

From source file:com.google.api.codegen.LanguageUtil.java

public static String lowerUnderscoreToLowerCamel(String name) {
    return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name);
}

From source file:datamine.storage.idl.generator.metadata.MetadataFileGenerator.java

public static String getClassName(String tableName) {
    return new StringBuilder().append(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, tableName))
            .append("Metadata").toString();
}

From source file:org.zalando.jpa.eclipselink.customizer.NameUtils.java

/**
 * @param   name/*from   w  w w. j ava  2 s . com*/
 *
 * @return
 */
public static String camelCaseToUnderscore(final String name) {
    return CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, name);
}