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.edgar.jdbc.codegen.gen.Field.java

public static Field create(Column column) {
    Field field = new Field();
    field.setHumpName(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, column.getName()));
    field.setColName(column.getName());//from w w w .j av  a 2s.c  o  m
    field.setNullable(column.isNullable());
    field.setAutoInc(column.isAutoInc());
    field.setDefaultValue(column.getDefaultValue());
    field.setPrimary(column.isPrimary());
    field.setSize(column.getSize());
    //TODO
    field.setType(field.getType(column));
    return field;
}

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

public static String upperCamelToLowerUnderscore(String name) {
    name = CommonAcronyms.camelizeUpperAcronyms(name);
    return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, name);
}

From source file:org.springframework.data.cassandra.util.CassandraNamingUtils.java

/**
 * Converts upper-camel field name to lower-underscore format.
 *
 * @param fieldName//from ww  w .  j  ava 2s . c o  m
 * @return
 */
public static String guessColumnName(String fieldName) {
    return CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, fieldName);
}

From source file:io.soliton.protobuf.json.Messages.java

/**
 * Converts a proto-message into an equivalent JSON representation.
 *
 * @param output/* ww w  .  ja  v a2s  .c o  m*/
 */
public static JsonObject toJson(Message output) {
    JsonObject object = new JsonObject();
    for (Map.Entry<Descriptors.FieldDescriptor, Object> field : output.getAllFields().entrySet()) {
        String jsonName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, field.getKey().getName());
        if (field.getKey().isRepeated()) {
            JsonArray array = new JsonArray();
            List<?> items = (List<?>) field.getValue();
            for (Object item : items) {
                array.add(serializeField(field.getKey(), item));
            }
            object.add(jsonName, array);
        } else {
            object.add(jsonName, serializeField(field.getKey(), field.getValue()));
        }
    }
    return object;
}

From source file:org.freedesktop.wayland.generator.impl.StringUtil.java

public static String upperCamelName(final String lowerUnderScoreName) {
    return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, lowerUnderScoreName);
}

From source file:com.google.api.codegen.util.Name.java

/**
 * Creates a Name from a sequence of lower-underscore strings.
 *
 * @throws IllegalArgumentException if any of the strings contain any characters that are not
 *     lower case or underscores.// w  ww .j  ava 2  s .  co m
 */
public static Name from(String... pieces) {
    List<NamePiece> namePieces = new ArrayList<>();
    for (String piece : pieces) {
        if (Strings.isNullOrEmpty(piece)) {
            continue;
        }
        validateLowerUnderscore(piece);
        namePieces.add(new NamePiece(piece, CaseFormat.LOWER_UNDERSCORE));
    }
    return new Name(namePieces);
}

From source file:org.zalando.problem.spring.web.advice.ExceptionHandling.java

@Override
public String formatFieldName(String fieldName) {
    return CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, fieldName);
}

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

public static String lowerUnderscoreToUpperUnderscore(String name) {
    return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_UNDERSCORE, name);
}

From source file:org.freedesktop.wayland.generator.impl.StringUtil.java

public static String lowerCamelName(final String lowerUnderScoreName) {
    return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, lowerUnderScoreName);
}

From source file:com.google.gerrit.server.project.RepositoryStatistics.java

public RepositoryStatistics(Properties p) {
    for (Entry<Object, Object> e : p.entrySet()) {
        put(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, e.getKey().toString()), e.getValue());
    }//from  www.ja  v a  2  s .c  om
}