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

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

Introduction

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

Prototype

CaseFormat UPPER_UNDERSCORE

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

Click Source Link

Document

Java and C++ constant naming convention, e.g., "UPPER_UNDERSCORE".

Usage

From source file:com.facebook.buck.jvm.java.AnnotationProcessingEvent.java

public String getCategory() {
    return annotationProcessorName + "."
            + CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, operation.toString());
}

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

private static JsonElement serializeField(Descriptors.FieldDescriptor field, Object value) {
    switch (field.getType()) {
    case DOUBLE:/*from w w w. j  a va2 s .  co  m*/
        return new JsonPrimitive((Double) value);
    case FLOAT:
        return new JsonPrimitive((Float) value);
    case INT64:
    case UINT64:
    case FIXED64:
    case SINT64:
    case SFIXED64:
        return new JsonPrimitive((Long) value);
    case INT32:
    case UINT32:
    case FIXED32:
    case SINT32:
    case SFIXED32:
        return new JsonPrimitive((Integer) value);
    case BOOL:
        return new JsonPrimitive((Boolean) value);
    case STRING:
        return new JsonPrimitive((String) value);
    case GROUP:
    case MESSAGE:
        return toJson((Message) value);
    case BYTES:
        return new JsonPrimitive(BaseEncoding.base64().encode(((ByteString) value).toByteArray()));
    case ENUM:
        String protoEnumName = ((Descriptors.EnumValueDescriptor) value).getName();
        return new JsonPrimitive(CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, protoEnumName));
    }
    return null;
}

From source file:com.google.errorprone.bugpatterns.ConstantField.java

@Override
public Description matchVariable(VariableTree tree, VisitorState state) {
    Symbol.VarSymbol sym = ASTHelpers.getSymbol(tree);
    if (sym == null || sym.getKind() != ElementKind.FIELD) {
        return Description.NO_MATCH;
    }//  w  w  w .  j  a va  2 s  . c o  m
    String name = sym.getSimpleName().toString();
    if (sym.isStatic() && sym.getModifiers().contains(Modifier.FINAL)) {
        return checkImmutable(tree, state, sym, name);
    }
    if (!name.equals(name.toUpperCase())) {
        return Description.NO_MATCH;
    }
    return buildDescription(tree)
            .addFix(SuggestedFixes.addModifiers(tree, state, Modifier.FINAL, Modifier.STATIC))
            .addFix(SuggestedFixes.renameVariable(tree,
                    CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name), state))
            .build();
}

From source file:com.dopsun.msg4j.tools.JavaGenerator.java

/**
 * AbcXyz to ABC_XYZ
 * 
 * @param name
 * @return
 */
public String nameToConst(String name) {
    return CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, name);
}

From source file:uk.submergedcode.SubmergedCore.serialization.AchievementSerializer.java

public AchievementSerializer() {
    ImmutableMap<String, Achievement> specialCases = ImmutableMap.<String, Achievement>builder()
            .put("achievement.buildWorkBench", Achievement.BUILD_WORKBENCH)
            .put("achievement.diamonds", Achievement.GET_DIAMONDS)
            .put("achievement.portal", Achievement.NETHER_PORTAL)
            .put("achievement.ghast", Achievement.GHAST_RETURN)
            .put("achievement.theEnd", Achievement.END_PORTAL).put("achievement.theEnd2", Achievement.THE_END)
            .put("achievement.blazeRod", Achievement.GET_BLAZE_ROD)
            .put("achievement.potion", Achievement.BREW_POTION).build();

    ImmutableBiMap.Builder<String, Achievement> builder = ImmutableBiMap.<String, Achievement>builder();
    for (Achievement achievement : Achievement.values()) {
        if (specialCases.values().contains(achievement)) {
            continue;
        }/*from   ww w .j a  va2 s.c o  m*/
        builder.put("achievement." + CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, achievement.name()),
                achievement);
    }

    builder.putAll(specialCases);

    achievements = builder.build();
}

From source file:com.cloudera.csd.descriptors.CsdLoggingType.java

@JsonValue
public String toJson() {
    return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name());
}

From source file:org.apache.brooklyn.api.objs.BrooklynObjectType.java

public String toCamelCase() {
    return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, this.name());
}

From source file:com.android.build.gradle.internal.profile.RecordingBuildListener.java

@Override
public void afterExecute(Task task, TaskState taskState) {

    // find the right ExecutionType.
    String taskImpl = task.getClass().getSimpleName();
    if (taskImpl.endsWith("_Decorated")) {
        taskImpl = taskImpl.substring(0, taskImpl.length() - "_Decorated".length());
    }/*from  w w w . ja  v  a 2 s .co m*/
    String potentialExecutionTypeName = "TASK_"
            + CaseFormat.LOWER_CAMEL.converterTo(CaseFormat.UPPER_UNDERSCORE).convert(taskImpl);
    ExecutionType executionType;
    try {
        executionType = ExecutionType.valueOf(potentialExecutionTypeName);
    } catch (IllegalArgumentException ignored) {
        executionType = ExecutionType.GENERIC_TASK_EXECUTION;
    }

    List<Recorder.Property> properties = new ArrayList<Recorder.Property>();
    properties.add(new Recorder.Property("project", task.getProject().getName()));
    properties.add(new Recorder.Property("task", task.getName()));

    if (task instanceof DefaultAndroidTask) {
        String variantName = ((DefaultAndroidTask) task).getVariantName();
        if (variantName == null) {
            throw new IllegalStateException(
                    "Task with type " + task.getClass().getName() + " does not include a variantName");
        }
        if (!variantName.isEmpty()) {
            properties.add(new Recorder.Property("variant", variantName));
        }
    }

    TaskRecord taskRecord = taskRecords.get(task.getName());
    mRecorder.closeRecord(new ExecutionRecord(taskRecord.recordId, 0 /* parentId */, taskRecord.startTime,
            System.currentTimeMillis() - taskRecord.startTime, executionType, properties));
}

From source file:com.dopsun.msg4j.tools.JavaGenerator.java

/**
 * @param fieldInfo//from w  w w .j  a v a2s.co  m
 * @return
 */
public String getFieldInfoString(FieldInfo fieldInfo) {
    String upperCamelName = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, fieldInfo.getType().name());

    return upperCamelName + "FieldInfo";
}

From source file:org.jclouds.sqs.domain.Action.java

public String value() {
    return this == ALL ? "*" : CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
}