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:org.zalando.jpa.eclipselink.customizer.databasemapping.support.EnumTypeConverter.java

protected void checkPgTypeName() {
    if (Strings.isNullOrEmpty(pgTypeName)) {
        pgTypeName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, enumClass.getSimpleName());
    }
}

From source file:edu.berkeley.ground.postgres.dao.version.PostgresItemDao.java

@Override
public T retrieveFromDatabase(long id) throws GroundException {
    return this.retrieve(
            String.format(SqlConstants.SELECT_STAR_ITEM_BY_ID,
                    CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, this.getType().getSimpleName()), id),
            id);/*from www. ja  v  a2s .c  om*/
}

From source file:datamine.storage.recordbuffers.idl.generator.RecordMetaWrapperGenerator.java

public static String getBaseClassSetterName(Field field) {
    return new StringBuilder().append("set")
            .append(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, field.getName())).toString();
}

From source file:com.facebook.buck.core.rules.impl.AbstractBuildRule.java

private String getTypeForClass() {
    Class<?> clazz = getClass();
    if (clazz.isAnonymousClass()) {
        clazz = clazz.getSuperclass();//from   ww  w.j ava  2 s  .  c o  m
    }
    return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, clazz.getSimpleName()).intern();
}

From source file:com.google.template.soy.basicdirectives.BasicEscapeDirective.java

@Override
public PyExpr applyForPySrc(PyExpr value, List<PyExpr> args) {
    String pyFnName = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, name.substring(1));
    return new PyExpr("sanitize." + pyFnName + "(" + value.getText() + ")", Integer.MAX_VALUE);
}

From source file:com.axelor.common.Inflector.java

/**
 * Convert the given word to camel case.
 * /*from ww  w  .ja v  a2s .c o  m*/
 * <pre>
 * inflection.camelcase(&quot;address_book&quot;, false); // &quot;AddressBook&quot;
 * inflection.camelcase(&quot;address-book&quot;, true); // &quot;addressBook&quot;
 * inflection.camelcase(&quot;Address book&quot;, false); // &quot;AddressBook&quot;
 * </pre>
 * 
 * @param word
 *            the word to convert
 * @param lower
 *            whether to create lower camel case
 * @return camel case string
 */
public String camelize(String word, boolean lower) {
    final CaseFormat target = lower ? CaseFormat.LOWER_CAMEL : CaseFormat.UPPER_CAMEL;
    return CaseFormat.LOWER_UNDERSCORE.to(target, underscore(word));
}

From source file:org.apache.phoenix.util.json.JsonUpsertExecutor.java

@Override
protected void execute(Map<?, ?> record) {
    int fieldIndex = 0;
    String colName = null;/*from www  .j  a  v a 2 s . c  om*/
    try {
        if (record.size() < conversionFunctions.size()) {
            String message = String.format("JSON record does not have enough values (has %d, but needs %d)",
                    record.size(), conversionFunctions.size());
            throw new IllegalArgumentException(message);
        }
        for (fieldIndex = 0; fieldIndex < conversionFunctions.size(); fieldIndex++) {
            colName = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_UNDERSCORE,
                    columnInfos.get(fieldIndex).getColumnName());
            if (colName.contains(".")) {
                StringBuilder sb = new StringBuilder();
                String[] parts = colName.split("\\.");
                // assume first part is the column family name; omita
                for (int i = 1; i < parts.length; i++) {
                    sb.append(parts[i]);
                    if (i != parts.length - 1) {
                        sb.append(".");
                    }
                }
                colName = sb.toString();
            }
            if (colName.contains("\"")) {
                colName = colName.replace("\"", "");
            }
            Object sqlValue = conversionFunctions.get(fieldIndex).apply(record.get(colName));
            if (sqlValue != null) {
                preparedStatement.setObject(fieldIndex + 1, sqlValue);
            } else {
                preparedStatement.setNull(fieldIndex + 1, dataTypes.get(fieldIndex).getSqlType());
            }
        }
        preparedStatement.execute();
        upsertListener.upsertDone(++upsertCount);
    } catch (Exception e) {
        if (LOG.isDebugEnabled()) {
            // Even though this is an error we only log it with debug logging because we're notifying the
            // listener, and it can do its own logging if needed
            LOG.debug("Error on record " + record + ", fieldIndex " + fieldIndex + ", colName " + colName, e);
        }
        upsertListener.errorOnRecord(record,
                new Exception("fieldIndex: " + fieldIndex + ", colName " + colName, e));
    }
}

From source file:com.gwtplatform.mvp.processors.bundle.BundleDetails.java

private String sanitizeBundleName(String name) {
    String sanitized = name.trim().replaceAll("[^\\w\\d]", "_");
    return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, sanitized);
}

From source file:com.google.template.soy.internal.proto.Field.java

private static String computeSoyName(FieldDescriptor field) {
    return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, field.getName()) + fieldSuffix(field);
}

From source file:com.github.jcustenborder.kafka.connect.cdc.SchemaGenerator.java

private static CaseFormat caseFormat(CDCSourceConnectorConfig.CaseFormat inputCaseFormat) {
    CaseFormat inputFormat;/* ww  w  .  j a  v  a 2s . c om*/
    switch (inputCaseFormat) {
    case LOWER_CAMEL:
        inputFormat = CaseFormat.LOWER_CAMEL;
        break;
    case LOWER_HYPHEN:
        inputFormat = CaseFormat.LOWER_HYPHEN;
        break;
    case LOWER_UNDERSCORE:
        inputFormat = CaseFormat.LOWER_UNDERSCORE;
        break;
    case UPPER_CAMEL:
        inputFormat = CaseFormat.UPPER_CAMEL;
        break;
    case UPPER_UNDERSCORE:
        inputFormat = CaseFormat.UPPER_UNDERSCORE;
        break;
    default:
        throw new UnsupportedOperationException(
                String.format("'%s' is not a supported case format.", inputCaseFormat));
    }
    return inputFormat;
}