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:com.github.jcustenborder.kafka.connect.utils.config.AnnotationHelper.java

public static String title(Package p) {
    Title annotation = p.getAnnotation(Title.class);
    return (null != annotation) ? annotation.value()
            : CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, p.getName());
}

From source file:datamine.storage.idl.generator.java.JavaTypeConvertor.java

private String convert(GroupFieldType type) {
    String javaType = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, type.getGroupName());

    // Note that the STRUCT is always accessed through its interface
    return new StringBuilder().append(javaType).append("Interface").toString();
}

From source file:org.spongepowered.common.registry.provider.BlockPropertyIdProvider.java

public static String getIdAndTryRegistration(IProperty<?> property, Block block, String blockId) {
    BlockPropertyIdProvider instance = getInstance();
    checkNotNull(property, "Property is null! Cannot retrieve a registration for a null property!");
    checkNotNull(block, "Block cannot be null!");
    checkNotNull(blockId, "Block id cannot be null!");
    checkArgument(!blockId.isEmpty(), "Block id cannot be empty!");
    if (instance.isRegistered(property)) {
        return instance.propertyIdMap.get(property);
    } else {//w  w  w .  j av  a2s  .  co m
        final String lowerCasedBlockId = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, blockId);
        final String modId = lowerCasedBlockId.split(":")[0];
        final String propertyName = property.getName();
        final String lastAttemptId = lowerCasedBlockId + "_" + property.getName();
        try { // Seriously, don't look past this try state. just continue on with your day...
              // I warned you...
            final String originalClass = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE,
                    block.getClass().getSimpleName());
            Class<?> blockClass = block.getClass();
            while (true) {
                if (blockClass == Object.class) {
                    final String propertyId = modId + ":" + originalClass + "_" + property.getName();
                    LogManager.getLogger("Sponge").warn(
                            "Could not find {} owning class, assigning fallback id: {}", property.getName(),
                            propertyId);
                    instance.register(property, propertyId);
                    return propertyId;
                }
                // Had enough?
                for (Field field : blockClass.getDeclaredFields()) {
                    field.setAccessible(true);

                    final boolean isStatic = Modifier.isStatic(field.getModifiers());
                    final Object o = isStatic ? field.get(null) : field.get(block);

                    if (property != o) {
                        continue;
                    }
                    final String className = field.getDeclaringClass().getSimpleName().replace("Block", "")
                            .replace("block", "");
                    final String classNameId = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE,
                            className);
                    final String propertyClassName = isStatic ? classNameId : originalClass;
                    final String combinedId = modId + ":" + propertyClassName + "_"
                            + propertyName.toLowerCase(Locale.ENGLISH);
                    if (instance.idPropertyMap.containsKey(combinedId)) {
                        // in this case, we really do have to fall back on the full block id...
                        if (instance.idPropertyMap.containsKey(lastAttemptId)) {
                            // we really are screwed...
                            throw new IllegalArgumentException(
                                    "Sorry! Someone is trying to re-register a block with the same property instances of"
                                            + "block: " + blockId + " , with property: " + propertyName);
                        } else {
                            instance.register((IProperty<?>) o, lastAttemptId);
                            return lastAttemptId;
                        }
                    }
                    instance.register(((IProperty<?>) o), combinedId);
                    return combinedId;
                }
                blockClass = blockClass.getSuperclass();
            }

        } catch (Exception e) {
            LogManager.getLogger("Sponge").warn("An exception was thrown while trying to resolve the property "
                    + property.getName() + "'s owning class, assigning " + "fallback id: " + lastAttemptId, e);
            instance.register(property, lastAttemptId);
            return lastAttemptId;
        }
    }
}

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

/**
 * Construct a new instance./*from w  w  w.j av  a  2  s  .  c  om*/
 * 
 * @param args - these usually come from the main method
 */
protected CommandLineInterface(String... args) {
    try {
        this.options = getOptions();
        this.parser = new JCommander(options, args);
        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);
        }
        if (!Strings.isNullOrEmpty(options.prefs)) {
            options.prefs = FileOps.expandPath(options.prefs, getLaunchDirectory());
            ConcourseClientPreferences prefs = ConcourseClientPreferences.open(options.prefs);
            options.username = prefs.getUsername();
            options.password = new String(prefs.getPasswordExplicit());
            options.host = prefs.getHost();
            options.port = prefs.getPort();
            options.environment = prefs.getEnvironment();
        }
        if (Strings.isNullOrEmpty(options.password)) {
            options.password = console.readLine("password for [" + options.username + "]: ", '*');
        }
        int attemptsRemaining = 5;
        while (concourse == null && attemptsRemaining > 0) {
            try {
                concourse = Concourse.connect(options.host, options.port, options.username, options.password,
                        options.environment);
            } catch (Exception e) {
                System.err.println("Error processing login. Please check "
                        + "username/password combination and try again.");
                concourse = null;
                options.password = console.readLine("password for [" + options.username + "]: ", '*');
                attemptsRemaining--;
            }
        }
        if (concourse == null) {
            System.err.println("Unable to connect to Concourse. Is the server running?");
            System.exit(1);
        }
    } catch (ParameterException e) {
        System.exit(die(e.getMessage()));
    } catch (IOException e) {
        System.exit(die(e.getMessage()));
    }
}

From source file:com.google.api.codegen.viewmodel.CallingForm.java

/**
 * Returns the {@code String} representation of this enum, but in lower camelcase.
 *
 * @return the lower camelcase name of this enum value
 *//*from w  ww. java  2  s.  com*/
public String toLowerCamel() {
    return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, toString());
}

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

/**
 * @param fieldInfo/*  w w w . java2  s. c  o 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());
}

From source file:dk.dma.enumgenerator.Generator.java

public CodegenClass generateClass() {
    CodegenClass c = new CodegenClass();
    c.setPackage("dk.dma.enumgenerator.test");
    c.setDefinition("public final class " + unit.name);

    c.addField("private final ", unit.type(), " ", v, ";");
    c.addField("private final ", unit.name, "Unit unit;");

    CodegenMethod con = c.addMethod("(", unit.type(), " ", v, ", ", unit.name, "Unit unit)");
    con.add("this.", v, " = ", v, ";");
    con.add("this.unit = unit;");

    // c.newMethod(")
    CodegenMethod getUnit = c.addMethod("public ", u, " getUnit()");
    getUnit.add("return unit;");

    for (Val val : unit.vals.values()) {
        CodegenMethod m = c.addMethod("public ", unit.type(), " to", val.name, "()");
        m.add("return unit.to" + val.name, "(", v, ");");
        m.javadoc().set("Returns the " + v + " in "
                + CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, val.name).replace("_", " ") + ".");
        m.javadoc().addParameter(v, "the " + v + " to convert");
        m.javadoc().addReturn("the converted " + v);
        // m.throwNewUnsupportedOperationException("fuckoff");
    }//from www .  j av a 2s .  co m

    // Generate Serializer

    // c.addInnerClass("static final class Serializer implements ", ValueSerializer.class, "<", unit.name, ">");

    return c;
}

From source file:es.sm2.openppm.api.converter.common.SettingGroupDTOConverter.java

/**
 * Conver DTO model into BD model//  w ww .j a  v  a 2s .co m
 *
 * @param modelDTO
 * @return
 */
@Override
public Class<? extends ApplicationSetting> toModel(SettingGroupDTO modelDTO) {

    Class<? extends ApplicationSetting> applicationSetting = null;

    if (modelDTO != null && ValidateUtil.isNotNull(modelDTO.getName())) {

        String name = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, modelDTO.getName());

        Set<Class<? extends ApplicationSetting>> applicationSettingList = CacheStatic
                .getApplicationSettingList();

        Iterator<Class<? extends ApplicationSetting>> iterator = applicationSettingList.iterator();
        while (applicationSetting == null && iterator.hasNext()) {
            Class<? extends ApplicationSetting> setting = iterator.next();

            if (setting.getSimpleName().equals(name)) {
                applicationSetting = setting;
            }
        }
    }

    return applicationSetting;
}

From source file:datamine.storage.recordbuffers.idl.generator.RecordMetaWrapperGenerator.java

public static String getWrapperClassName(String tableName) {
    return new StringBuilder().append(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, tableName))
            .append("Record").toString();
}