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

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

Introduction

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

Prototype

CaseFormat UPPER_CAMEL

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

Click Source Link

Document

Java and C++ class naming convention, e.g., "UpperCamel".

Usage

From source file:org.cinchapi.concourse.cli.CommandLineInterface.java

/**
 * Construct a new instance that is seeded with an object containing options
 * metadata. The {@code options} will be parsed by {@link JCommander} to
 * configure them appropriately.//from  w  w w .  j a v  a 2  s . c o m
 * <p>
 * The subclass should NOT override this constructor. If the subclass
 * defines a custom {@link Options} class, then it only needs to pass those
 * to this super constructor from {@link #CommandLineInterface(String...)}.
 * </p>
 * 
 * @param options
 * @param args - these usually come from the main method
 */
protected CommandLineInterface(Options options, String... args) {
    try {
        this.parser = new JCommander(options, args);
        this.options = options;
        parser.setProgramName(
                CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, this.getClass().getSimpleName()));
        this.console = new ConsoleReader();
        this.console.setExpandEvents(false);
        if (options.help) {
            parser.usage();
            System.exit(1);
        }
        // must get creds in constructor in case subclass tries to connect
        // to Concourse in its constructor
        if (!Strings.isNullOrEmpty(options.prefs)) {
            ConcourseClientPreferences prefs = ConcourseClientPreferences.load(options.prefs);
            options.username = prefs.getUsername();
            options.password = new String(prefs.getPassword());
            options.host = prefs.getHost();
            options.port = prefs.getPort();
            options.environment = prefs.getEnvironment();
        } else if (Strings.isNullOrEmpty(options.password)) {
            options.password = console.readLine("Password [" + options.username + "]: ", '*');
        }
    } catch (ParameterException e) {
        die(e.getMessage());
    } catch (IOException e) {
        die(e.getMessage());
    }
}

From source file:com.tactfactory.harmony.platform.android.updater.EntityImplementationAndroid.java

/**
 * Generate the necessary getters and setters for the class.
 * @param fileString The stringbuffer containing the class java code
 * @param classMeta The Metadata containing the infos on the java class
 *//*from ww w. j a  va  2 s.c  o m*/
private final void generateGetterAndSetters(final SourceFileManipulator manipulator,
        final EntityMetadata classMeta) {

    final Collection<FieldMetadata> fields = classMeta.getFields().values();
    final boolean childClass = MetadataUtils.inheritsFromEntity(classMeta, ApplicationMetadata.INSTANCE);
    for (final FieldMetadata field : fields) {
        final boolean isInheritedId = childClass && classMeta.getIds().containsKey(field.getName());
        if (!field.isInternal() && !isInheritedId) {
            // Getter
            if (!this.alreadyImplementsGet(field, classMeta)) {
                ConsoleUtils.displayDebug("Add implements getter of " + field.getName(),
                        " => get" + CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, field.getName()));

                manipulator.generateFieldAccessor(field, "itemGetter.java");
            }

            // Setter
            if (!this.alreadyImplementsSet(field, classMeta)) {
                ConsoleUtils.displayDebug("Add implements setter of " + field.getName(),
                        " => set" + CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, field.getName()));

                manipulator.generateFieldAccessor(field, "itemSetter.java");
            }
        }
    }

    manipulator.addImport(classMeta, "ArrayList", "java.util.ArrayList");

    manipulator.addImport(classMeta, "List", "java.util.List");
}

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

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

From source file:net.simonvt.schematic.compiler.DatabaseWriter.java

public DatabaseWriter(ProcessingEnvironment env, Elements elements, Element database) {
    this.processingEnv = env;
    this.elementUtils = env.getElementUtils();

    this.database = database;

    String databaseSchematicName = database.getSimpleName().toString();

    Database db = database.getAnnotation(Database.class);
    this.version = db.version();

    this.className = db.className();
    if (className.trim().isEmpty()) {
        this.className = databaseSchematicName;
    }//www  . jav a 2 s .  co m

    this.outPackage = db.packageName();
    if (outPackage.trim().isEmpty()) {
        this.outPackage = elements.getPackageOf(database).getQualifiedName() + ".generated";
    }

    this.fileName = db.fileName();
    if (fileName.trim().isEmpty()) {
        this.fileName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, databaseSchematicName) + ".db";
    }

    clazzName = ClassName.get(outPackage, className);

    findAnnotations(database);
}

From source file:com.thinkbiganalytics.nifi.provenance.util.SpringApplicationContext.java

/**
 * get a Spring bean by the Class type// ww w.  ja v  a2 s  .c  om
 */
public <T> T getBean(Class<T> requiredType) throws BeansException {
    T bean = null;
    try {
        bean = this.applicationContext.getBean(requiredType);
    } catch (Exception e) {
        //try to find it by the name
        String name = requiredType.getSimpleName();
        name = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, name);
        bean = (T) getBean(name);
    }
    return bean;
}

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

/**
 * Convert the given word to camel case.
 * /*from   w  w  w .j  a  va  2s  . 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: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:org.fenixedu.start.ProjectRequest.java

public String getUpperCamelCaseName() {
    return CaseFormat.LOWER_HYPHEN.converterTo(CaseFormat.UPPER_CAMEL).convert(artifactId);
}

From source file:com.spotify.hamcrest.pojo.IsPojo.java

public IsPojo<A> withProperty(String property, Matcher<?> valueMatcher) {
    return where("get" + CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, property), valueMatcher);
}

From source file:dagger.internal.codegen.DependencyVariableNamer.java

private String toLowerCamel(String name) {
    return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, name);
}