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

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

Introduction

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

Prototype

CaseFormat LOWER_HYPHEN

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

Click Source Link

Document

Hyphenated variable naming convention, e.g., "lower-hyphen".

Usage

From source file:com.facebook.buck.cxx.toolchain.HeaderMode.java

HeaderMode() {
    this.flavor = InternalFlavor.of(String.format("%s-%s",
            CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, getClass().getSimpleName()),
            CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, toString())));
}

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:org.jclouds.aws.ec2.domain.InstanceState.java

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

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

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

From source file:org.jclouds.cloudstack.domain.TemplateFilter.java

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

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

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

From source file:org.apache.brooklyn.location.basic.DeprecatedKeysMappingBuilder.java

private String toHyphen(String word) {
    return CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, word);
}

From source file:com.thinkbiganalytics.feedmgr.rest.support.SystemNamingService.java

public static String generateSystemName(String name) {
    //first trim it
    String systemName = StringUtils.trimToEmpty(name);
    if (StringUtils.isBlank(systemName)) {
        return systemName;
    }//w  w  w  .ja  v  a  2s  .  c  om
    systemName = systemName.replaceAll(" +", "_");
    systemName = systemName.replaceAll("[^\\w_]", "");

    int i = 0;

    StringBuilder s = new StringBuilder();
    CharacterIterator itr = new StringCharacterIterator(systemName);
    for (char c = itr.first(); c != CharacterIterator.DONE; c = itr.next()) {
        if (Character.isUpperCase(c)) {
            //if it is upper, not at the start and not at the end check to see if i am surrounded by upper then lower it.
            if (i > 0 && i != systemName.length() - 1) {
                char prevChar = systemName.charAt(i - 1);
                char nextChar = systemName.charAt(i + 1);

                if (Character.isUpperCase(prevChar) && (Character.isUpperCase(nextChar)
                        || CharUtils.isAsciiNumeric(nextChar) || '_' == nextChar || '-' == nextChar)) {
                    char lowerChar = Character.toLowerCase(systemName.charAt(i));
                    s.append(lowerChar);
                } else {
                    s.append(c);
                }
            } else if (i > 0 && i == systemName.length() - 1) {
                char prevChar = systemName.charAt(i - 1);
                if (Character.isUpperCase(prevChar) && !CharUtils.isAsciiNumeric(systemName.charAt(i))) {
                    char lowerChar = Character.toLowerCase(systemName.charAt(i));
                    s.append(lowerChar);
                } else {
                    s.append(c);
                }
            } else {
                s.append(c);
            }
        } else {
            s.append(c);
        }

        i++;
    }

    systemName = s.toString();
    systemName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, systemName);
    systemName = CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_UNDERSCORE, systemName);
    systemName = StringUtils.replace(systemName, "__", "_");
    // Truncate length if exceeds Hive limit
    systemName = (systemName.length() > 128 ? systemName.substring(0, 127) : systemName);
    return systemName;
}

From source file:com.googlesource.gerrit.plugins.kafka.config.KafkaProperties.java

private void applyConfig(PluginConfig config) {
    for (String name : config.getNames()) {
        Object value = config.getString(name);
        String propName = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, name).replaceAll("-", ".");
        put(propName, value);//from   w w w  . java  2  s  . com
    }
}

From source file:com.cinchapi.concourse.server.cli.ManagedOperationCli.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.// w w w.ja  v a2s  .c o m
 * 
 * @param options
 * @param args - these usually come from the main method
 */
public ManagedOperationCli(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()));
        if (!isReadyToRun()) {
            parser.usage();
            System.exit(1);
        }
        this.console = new ConsoleReader();
        console.setExpandEvents(false);
    } catch (ParameterException e) {
        die(e.getMessage());
    } catch (IOException e) {
        die(e.getMessage());
    }
}