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.jclouds.cloudstack.domain.TrafficType.java

@Override
public String toString() {
    return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
}

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

public void runPlugin() {
    URL pluginUrl = createPluginUrl();
    URL[] urls = { pluginUrl };//from  www .jav a  2s  . c o 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:pl.wavesoftware.wfirma.api.core.model.ApiModule.java

/**
 * Gets a request module path/*  w w  w  .  j  a  va2s. c om*/
 *
 * @param apiClass a domain class
 * @return a string for request
 */
@Nonnull
public static String getRequestModulePath(@Nonnull Class<? extends Api> apiClass) {
    checkNotNull(apiClass);
    String name = apiClass.getSimpleName().replaceAll("Api$", "");
    return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, name);
}

From source file:com.spectralogic.ds3autogen.utils.Helper.java

public static String underscoreToCamel(final String str) {
    return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, str);
}

From source file:com.facebook.buck.rules.Description.java

static BuildRuleType getBuildRuleType(String descriptionClassName) {
    descriptionClassName = MoreStrings.stripPrefix(descriptionClassName, "Abstract")
            .orElse(descriptionClassName);
    descriptionClassName = MoreStrings.stripSuffix(descriptionClassName, "Description")
            .orElse(descriptionClassName);
    return BuildRuleType.of(CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, descriptionClassName));
}

From source file:com.eucalyptus.auth.util.ClassPathSystemAccountProvider.java

private static String getResourceName(String name, String type) {
    return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, name + type) + ".json";
}

From source file:io.soliton.protobuf.plugin.TypeMap.java

/**
 * @param name// ww  w.  j  a v a2 s .  c  o  m
 * @return
 */
@VisibleForTesting
static String createOuterJavaClassname(String name) {
    if (name.endsWith(".proto")) {
        name = name.substring(0, name.length() - ".proto".length());
    }
    name = Iterables.getLast(Splitter.on('/').split(name));
    name = name.replace('-', '_');
    name = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name);
    return Character.toUpperCase(name.charAt(0)) + name.substring(1);
}

From source file:org.sonar.css.model.StandardCssObject.java

public StandardCssObject() {
    name = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, this.getClass().getSimpleName());
    obsolete = false;//from   w  w  w  .  j a va  2  s  .  c  o  m
    experimental = false;
    vendors = new HashSet<>();
    links = new ArrayList<>();
}

From source file:org.syncany.plugins.transfer.TransferPluginUtil.java

/**
 * Determines the {@link TransferSettings} class for a given
 * {@link TransferPlugin} class.//w w w  .jav a 2s  . c o  m
 */
public static Class<? extends TransferSettings> getTransferSettingsClass(
        Class<? extends TransferPlugin> transferPluginClass) {
    String pluginNameIdentifier = TransferPluginUtil.getPluginPackageName(transferPluginClass);

    if (pluginNameIdentifier == null) {
        throw new RuntimeException("There are no valid transfer settings attached to that plugin ("
                + transferPluginClass.getName() + ")");
    } else {
        try {
            String pluginPackageIdentifier = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE,
                    pluginNameIdentifier);
            String transferSettingsClassName = MessageFormat.format(PLUGIN_TRANSFER_SETTINGS_CLASS_NAME,
                    pluginPackageIdentifier, pluginNameIdentifier);

            return Class.forName(transferSettingsClassName).asSubclass(TransferSettings.class);
        } catch (Exception e) {
            throw new RuntimeException("Cannot find matching transfer settings class for plugin ("
                    + transferPluginClass.getName() + ")");
        }
    }
}

From source file:org.raml.v2.internal.utils.Inflector.java

private static CaseFormat detectFormat(String word) {
    boolean allUpper = word.toUpperCase().equals(word);
    boolean allLower = word.toLowerCase().equals(word);
    boolean mixedCase = !allUpper && !allLower;
    boolean firstCapital = word.substring(0, 1).toUpperCase().equals(word.substring(0, 1));
    if (mixedCase) {
        if (firstCapital) {
            return CaseFormat.UPPER_CAMEL;
        }//from w  w w. jav a2s.c o m
        return LOWER_CAMEL;
    }
    if (allUpper) {
        return CaseFormat.UPPER_UNDERSCORE;
    }
    return CaseFormat.LOWER_UNDERSCORE;
}