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.facebook.buck.rules.ParamInfo.java

private String determinePythonName(String javaName, @Nullable Hint hint) {
    if (hint != null) {
        return hint.name();
    }//from www .j a v a 2  s  .  c o  m
    return CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, javaName);
}

From source file:com.puppycrawl.tools.checkstyle.checks.javadoc.ExpectedParseTreeGenerator.java

public String walk(ParseTree t, String parentObjectName) {
    final String className = t.getClass().getSimpleName();
    String id = null;//from w  w w  .ja va  2 s  . c  o  m

    if (t instanceof TerminalNode) {
        final TerminalNodeImpl terminal = (TerminalNodeImpl) t;
        final int type = terminal.symbol.getType();
        String tokenType = "";
        if (type == -1) {
            tokenType = "EOF";
        } else {
            tokenType = JavadocUtils.getTokenName(type);
        }
        String text = terminal.getText();
        if ("\n".equals(text)) {
            text = "\\n";
        } else if ("\t".equals(text)) {
            text = "\\t";
        } else {
            text = text.replace("\"", "\\\"");
        }

        final int number = getVariableCounter(tokenType);

        id = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, tokenType.toLowerCase()) + number;

        System.out.println("    CommonToken " + id + " = new CommonToken(JavadocTokenTypes." + tokenType
                + ", \"" + text + "\");");
    } else {
        int number = getVariableCounter(className);

        id = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, className) + number++;

        System.out.println(
                "    " + className + " " + id + " = new " + className + "(" + parentObjectName + ", 0);");

        final int n = t.getChildCount();
        for (int i = 0; i < n; i++) {
            final String childId = walk(t.getChild(i), id);
            System.out.println("    " + id + ".addChild(" + childId + ");");
        }
    }
    return id;
}

From source file:com.google.api.codegen.transformer.java.JavaGapicSamplesTransformer.java

private StaticLangSampleClassView generateSampleClass(InterfaceContext context, StaticLangApiMethodView method,
        MethodSampleView methodSample, String callingForm, String valueSet) {
    SurfaceNamer namer = context.getNamer();
    StaticLangSampleClassView.Builder sampleClass = StaticLangSampleClassView.newBuilder();
    sampleClass.name(namer.getApiSampleClassName(
            CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, method.name()), callingForm, valueSet))
            .libraryMethod(method.toBuilder().samples(Arrays.asList(methodSample)).build());

    return sampleClass.build();
}

From source file:com.google.template.soy.jssrc.internal.JavaScriptValueFactoryImpl.java

private Expression referenceModuleExport(String moduleName, String export) {
    Expression module;//from w  w w. j a va 2  s . c  om
    if (jsSrcOptions.shouldGenerateGoogModules()) {
        String alias = "$"
                + CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, moduleName.replace('.', '_'));
        module = GoogRequire.createWithAlias(moduleName, alias).reference();
    } else {
        module = GoogRequire.create(moduleName).googModuleGet();
    }
    return chainedDotAccess(module, export);
}

From source file:ninja.pebble.template.TemplateEnginePebble.java

/**
 * Getting an arbitrary Object, put that into the root of the template
 * properties map/*  ww w.j  av  a 2s . com*/
 *
 * If you are rendering something like Results.ok().render(new MyObject())
 * Assume MyObject has a public String name field.
 *
 * You can then access the fields in the template like that:
 * {myObject.publicField}
 *
 */
private Map createTemplatePropertiesMapAndInsert(Object renderableResult) {

    String realClassNameLowerCamelCase = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL,
            renderableResult.getClass().getSimpleName());

    Map map = Maps.newHashMap();
    map.put(realClassNameLowerCamelCase, renderableResult);

    return map;
}

From source file:com.tactfactory.harmony.generator.BundleGenerator.java

/**
 * Generate bundle's generator./*from   www .  ja v a  2s. com*/
 * @param bundleOwnerName Owner name
 * @param bundleName Bundle name
 * @param bundleNameSpace Bundle namespace
 */
private void generateTemplate(final String bundleOwnerName, final String bundleName,
        final String bundleNameSpace) {

    final String tplPath = this.getAdapter().getTemplateBundleTemplatePath() + "/TemplateGenerator.java";
    final String genPath = this.getAdapter().getTemplateBundlePath(bundleOwnerName, bundleNameSpace, bundleName)
            + "/" + CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, bundleName) + "Generator.java";

    this.makeSource(tplPath, genPath, false);
}

From source file:com.torodb.packaging.config.util.DescriptionFactoryWrapper.java

private void document(JsonPointer propPointer, BeanProperty prop) {
    JavaType type = prop.getType();//  www  .j ava  2  s  .  c  om

    if (hasDescription(prop) && !isPrimitive(type) && !type.isEnumType() && !type.isMapLikeType()) {
        console.println("");
    } else if (isPrimitive(type) || type.isEnumType()) {
        printTabs();
        console.print(propPointer.toString());
        console.print("=");
    } else if (type.isMapLikeType()) {
        printTabs();
        console.print(propPointer.append(JsonPointer.compile("/<string>")).toString());
        console.print("=");
        type = type.getContentType();
    }

    if (isPrimitive(type)) {
        console.print("<");
        console.print(CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, type.getRawClass().getSimpleName()));
        console.print(">");
    } else if (type.isEnumType()) {
        console.print("<enum:string>");
    }

    if (hasDescription(prop) && !isPrimitive(type) && !type.isEnumType()) {
        printTabs();
    }

    printDescription(prop);

    if (hasDescription(prop) || isPrimitive(type) || type.isEnumType()) {
        console.println("");
    }

    if (hasDescription(prop) && !isPrimitive(type) && !type.isEnumType()) {
        console.println("");
    }

    if (type.isEnumType()) {
        for (Field enumField : type.getRawClass().getDeclaredFields()) {
            if (!enumField.isEnumConstant()) {
                continue;
            }

            printTabs();
            console.print(" - ");
            console.print(enumField.getName());

            Description enumConstantConfigProperty = enumField.getAnnotation(Description.class);
            if (enumConstantConfigProperty != null && enumConstantConfigProperty.value() != null) {
                console.print(" # ");
                console.print(resourceBundle.getString(enumConstantConfigProperty.value()));
            }

            console.println("");
        }
    }
}

From source file:jp.atr.unr.pf.roboearth.RoboEarthInterface.java

/**
 * Sends a 'semantic query' to the RoboEarth DB to search for an environment model
 * // ww w.  j a  v  a  2 s . c o m
 * @param roomNumber Environment for which to search (currently: room number)
 * @return Array of URL strings pointing to the recipe specifications
 * @throws IOException
 * @throws ParserConfigurationException
 * @throws SAXException
 */
public static String[] searchEnvironmentMapsFor(String[][] roomQuery)
        throws IOException, ParserConfigurationException, SAXException {

    String q = "SELECT source FROM CONTEXT source\n" + "{A} kr:describedInMap {Z} ,\n";

    ArrayList<String> constr = new ArrayList<String>();
    ArrayList<String> where = new ArrayList<String>();

    char idx = 'A';
    for (String[] constraint : roomQuery) {

        if (idx != 'A') {
            constr.add("{" + idx + "} kr:properPhysicalParts {" + (char) (idx - 1) + "}");
        }

        String var = constraint[0].split(":")[1];
        var = CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, var);
        var = "V" + var; // avoid problems with reserved words like 'label' 

        constr.add("{" + idx + "} " + constraint[0] + " {" + var + "}");
        where.add(var + " LIKE \"" + constraint[1] + "\"");

        idx++;
    }

    q += Joiner.on(" , \n").join(constr);
    q += "\nWHERE\n" + Joiner.on("\nAND ").join(where);

    q += "\nUSING NAMESPACE\n" + "re=<http://www.roboearth.org/kb/roboearth.owl#>,\n"
            + "rdfs=<http://www.w3.org/2000/01/rdf-schema#>,\n" + "kr=<http://ias.cs.tum.edu/kb/knowrob.owl#> ";

    //CommunicationVisApplet.visualizeCommunication("Requesting map from RoboEarth..." + q, "", "pr2.jpg", "roboearth.png");

    String res;
    REConnectionHadoop conn = new REConnectionHadoop(API_KEY);

    res = conn.queryEnvironmentDB(q);

    res = res.replace("\\n", "").replace("\\t", "");
    res = res.substring(1, res.length() - 1);

    ArrayList<String> env_urls = new ArrayList<String>();
    SAXParserFactory factory = SAXParserFactory.newInstance();
    factory.setValidating(false);
    factory.newSAXParser().parse(new InputSource(new StringReader(res)), new SparqlReader(env_urls));

    //      String map_names = "";

    ArrayList<String> maps = new ArrayList<String>();
    for (String url : env_urls) {
        maps.add(getFilenameFromURL(url));

        //         map_names += getFilenameFromURL(url) + ", ";
    }
    //CommunicationVisApplet.visualizeCommunication(null, "Received environment maps "+ map_names, "pr2.jpg", "roboearth.png");

    return maps.toArray(new String[0]);

}

From source file:com.torodb.config.util.DescriptionFactoryWrapper.java

private void document(JsonPointer propPointer, BeanProperty prop) {
    JavaType type = prop.getType();/*from   w  w  w . j a  v a 2  s .  c om*/

    if (hasDescription(prop) && !isPrimitive(type) && !type.isEnumType() && !type.isMapLikeType()) {
        console.println("");
    } else if (isPrimitive(type) || type.isEnumType()) {
        printTabs();
        console.print(propPointer.toString());
        console.print("=");
    } else if (type.isMapLikeType()) {
        printTabs();
        console.print(propPointer.append(JsonPointer.compile("/<string>")).toString());
        console.print("=");
        type = type.getContentType();
    }

    if (isPrimitive(type)) {
        console.print("<");
        console.print(CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, type.getRawClass().getSimpleName()));
        console.print(">");
    } else if (type.isEnumType()) {
        console.print("<enum:string>");
    }

    if (hasDescription(prop) && !isPrimitive(type) && !type.isEnumType()) {
        printTabs();
    }

    printDescription(prop);

    if (hasDescription(prop) || isPrimitive(type) || type.isEnumType()) {
        console.println("");
    }

    if (hasDescription(prop) && !isPrimitive(type) && !type.isEnumType()) {
        console.println("");
    }

    if (type.isEnumType()) {
        for (Field enumField : type.getRawClass().getDeclaredFields()) {
            if (!enumField.isEnumConstant()) {
                continue;
            }

            printTabs();
            console.print(" - ");
            console.print(enumField.getName());

            Description enumConstantConfigProperty = enumField.getAnnotation(Description.class);
            if (enumConstantConfigProperty != null && enumConstantConfigProperty.value() != null) {
                console.print(" # ");
                console.print(enumConstantConfigProperty.value());
            }

            console.println("");
        }
    }
}

From source file:com.facebook.buck.rules.coercer.ParamInfo.java

public String getPythonName() {
    return CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, getName());
}