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

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

Introduction

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

Prototype

CaseFormat LOWER_CAMEL

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

Click Source Link

Document

Java variable naming convention, e.g., "lowerCamel".

Usage

From source file:com.google.template.soy.types.proto.JsQualifiedNameHelper.java

/** Performs camelcase translation. */
private static String computeSoyName(FieldDescriptor field) {
    return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, field.getName());
}

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

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

From source file:org.ambraproject.wombat.feed.FeedMetadataField.java

private String getKey() {
    return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name());
}

From source file:org.pz.platypus.PluginLoader.java

public void runPlugin() {
    URL pluginUrl = createPluginUrl();
    URL[] urls = { pluginUrl };//from w w  w .  j a  va 2 s  .  co m
    URLClassLoader pluginLoader = new URLClassLoader(urls);
    Thread.currentThread().setContextClassLoader(pluginLoader);

    try {
        String className;
        String jarName = checkNotNull(Filename.getBaseName(location));

        // The class loaded is the name of the JAR with the first letter capitalized pdf.jar -> Pdf.class
        final String capitalizedClass = CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, jarName);
        className = "org.pz.platypus.plugin." + jarName.toLowerCase() + "." + capitalizedClass;

        //-- due to bug in JDK 1.6, must use Class.forName(), rather than code above.
        //   see: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6434149
        Class pluginStart = Class.forName(className, false, pluginLoader);

        Object plugin = pluginStart.newInstance();

        Class[] classParams = { GDD.class };
        Method method1;

        // call process( GDD ) in the class identified above.
        try {
            gdd.diag("Calling process() in:" + " " + className);
            method1 = pluginStart.getMethod("process", classParams);
        } catch (NoSuchMethodException nsme) {
            gdd.log.severe(gdd.getLit("ERROR.INVALID_PLUGIN_NO_PROCESS_METHOD"));
            throw new StopExecutionException(null);
        }

        try {
            method1.invoke(plugin, gdd);
        } catch (InvalidConfigFileException icfe) {
            return; //error message has already been displayed
        } catch (InvocationTargetException ite) {
            System.err.println("Invocation target exception " + ite);
            ite.printStackTrace();
        }
    } catch (ClassNotFoundException cnf) {
        gdd.log.severe("Plugin class not found " + cnf);
        throw new StopExecutionException(null);
    } catch (InstantiationException ie) {
        System.err.println(ie);
    } catch (IllegalAccessException ie) {
        System.err.println(ie);
    }
}

From source file:com.netflix.spinnaker.clouddriver.ecs.cache.Keys.java

public static Map<String, String> parse(String key) {
    String[] parts = key.split(SEPARATOR);

    if (parts.length < 3 || !parts[0].equals(ID)) {
        return null;
    }/* www . jav a  2s  .co m*/

    Map<String, String> result = new HashMap<>();
    result.put("provider", parts[0]);
    result.put("type", parts[1]);
    result.put("account", parts[2]);

    if (!canParse(parts[1]) && parts[1].equals(HEALTH.getNs())) {
        result.put("region", parts[3]);
        result.put("taskId", parts[4]);
        return result;
    }

    Namespace namespace = Namespace.valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, parts[1]));

    if (!namespace.equals(Namespace.IAM_ROLE)) {
        result.put("region", parts[3]);
    }

    switch (namespace) {
    case SERVICES:
        result.put("serviceName", parts[4]);
        break;
    case ECS_CLUSTERS:
        result.put("clusterName", parts[4]);
        break;
    case TASKS:
        result.put("taskId", parts[4]);
        break;
    case CONTAINER_INSTANCES:
        result.put("containerInstanceArn", parts[4]);
        break;
    case TASK_DEFINITIONS:
        result.put("taskDefinitionArn", parts[4]);
        break;
    case ALARMS:
        result.put("alarmArn", parts[4]);
        break;
    case IAM_ROLE:
        result.put("roleName", parts[3]);
        break;
    case SCALABLE_TARGETS:
        result.put("resource", parts[4]);
        break;
    default:
        break;
    }

    return result;
}

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

public static String lowerCamelToUpperUnderscore(String name) {
    return CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, name);
}

From source file:com.contentful.vault.compiler.FieldsInjection.java

private FieldSpec createFieldSpec(FieldMeta field) {
    String name = CaseFormat.LOWER_CAMEL.converterTo(CaseFormat.UPPER_UNDERSCORE).convert(field.name());
    if (name == null) {
        throw new IllegalArgumentException("Invalid field with ID '" + field.id() + "' for generated class '"
                + className.simpleName() + "', has no name.");
    }//w w w  .  ja v a2 s.c  o  m
    return FieldSpec.builder(String.class, name, Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL)
            .initializer("$S", field.name()).build();
}

From source file:org.apache.beam.runners.core.construction.PipelineOptionsTranslation.java

/** Converts the provided {@link PipelineOptions} to a {@link Struct}. */
public static Struct toProto(PipelineOptions options) {
    Struct.Builder builder = Struct.newBuilder();

    try {/*from w  ww . j  av  a2 s  .co m*/
        // TODO: Officially define URNs for options and their scheme.
        TreeNode treeNode = MAPPER.valueToTree(options);
        TreeNode rootOptions = treeNode.get("options");
        Iterator<String> optionsKeys = rootOptions.fieldNames();
        Map<String, TreeNode> optionsUsingUrns = new HashMap<>();
        while (optionsKeys.hasNext()) {
            String optionKey = optionsKeys.next();
            TreeNode optionValue = rootOptions.get(optionKey);
            optionsUsingUrns.put(
                    "beam:option:" + CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, optionKey) + ":v1",
                    optionValue);
        }

        // The JSON format of a Protobuf Struct is the JSON object that is equivalent to that struct
        // (with values encoded in a standard json-codeable manner). See Beam PR 3719 for more.
        JsonFormat.parser().merge(MAPPER.writeValueAsString(optionsUsingUrns), builder);
        return builder.build();
    } catch (IOException e) {
        throw new RuntimeException("Failed to convert PipelineOptions to Protocol", e);
    }
}

From source file:org.jclouds.vcloud.domain.network.FenceMode.java

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

From source file:com.commonsware.android.staticizer.Staticizer.java

void generate(File input, File outputDir, String packageName) throws IOException {
    Type type = new TypeToken<LinkedHashMap<String, Object>>() {
    }.getType();/*from ww  w  .  j a v  a2 s.  co m*/
    LinkedHashMap<String, Object> data = new Gson().fromJson(new FileReader(input), type);
    String basename = removeExtension(input.getAbsolutePath());
    TypeSpec.Builder builder = TypeSpec.classBuilder(basename).addModifiers(Modifier.PUBLIC, Modifier.FINAL);

    for (Map.Entry<String, Object> entry : data.entrySet()) {
        String fieldName = CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, entry.getKey());
        FieldSpec.Builder field;

        if (entry.getValue() instanceof Float) {
            field = FieldSpec.builder(TypeName.FLOAT, fieldName).initializer("$L", entry.getValue());
        } else if (entry.getValue() instanceof Double) {
            field = FieldSpec.builder(TypeName.DOUBLE, fieldName).initializer("$L", entry.getValue());
        } else if (entry.getValue() instanceof Integer) {
            field = FieldSpec.builder(TypeName.INT, fieldName).initializer("$L", entry.getValue());
        } else if (entry.getValue() instanceof Long) {
            field = FieldSpec.builder(TypeName.LONG, fieldName).initializer("$L", entry.getValue());
        } else if (entry.getValue() instanceof Boolean) {
            field = FieldSpec.builder(TypeName.BOOLEAN, fieldName).initializer("$L", entry.getValue());
        } else {
            field = FieldSpec.builder(String.class, fieldName).initializer("$S", entry.getValue().toString());
        }

        field.addModifiers(Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL).build();

        builder.addField(field.build());
    }

    JavaFile.builder(packageName, builder.build()).build().writeTo(outputDir);
}