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.cinchapi.concourse.cli.CommandLineInterface.java

/**
 * Construct a new instance.//from w  w w . j  a va  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:org.gradle.integtests.fixtures.executer.IntegrationTestBuildContext.java

public String getCurrentSubprojectName() {
    return CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL,
            getGradleHomeDir().getParentFile().getParentFile().getName());
}

From source file:org.jclouds.s3.domain.CannedAccessPolicy.java

/**
 * @param capHeader//from   ww w .  ja  va2s  .c  om
 * The value of the x-amz-acl HTTP Header returned by S3 when an
 * object has a canned access policy.
 * 
 * @return
 * the canned access policy object corresponding to the header value,
 * or null if the given header value does not represent a valid canned 
 * policy.
 */
public static CannedAccessPolicy fromHeader(String capHeader) {
    return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, capHeader));
}

From source file:org.apache.brooklyn.util.javalang.coerce.EnumTypeCoercions.java

public static <E extends Enum<E>> Maybe<E> tryCoerce(String input, Class<E> targetType) {
    if (input == null)
        return null;
    if (targetType == null)
        return Maybe.absent("Null enum type");
    if (!targetType.isEnum())
        return Maybe.absent("Type '" + targetType + "' is not an enum");

    List<String> options = ImmutableList.of(input,
            CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, input),
            CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_UNDERSCORE, input),
            CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, input),
            CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, input));
    for (String value : options) {
        try {/*from  ww  w  . j a va  2  s .  com*/
            return Maybe.of(Enum.valueOf(targetType, value));
        } catch (IllegalArgumentException iae) {
            continue;
        }
    }
    Maybe<E> result = Enums.valueOfIgnoreCase(targetType, input);
    if (result.isPresent())
        return result;
    return Maybe.absent(new ClassCoercionException(
            "Invalid value '" + input + "' for " + JavaClassNames.simpleClassName(targetType)
                    + "; expected one of " + Arrays.asList(Enums.values(targetType))));
}

From source file:com.facebook.buck.python.PythonUtil.java

public static ImmutableMap<Path, SourcePath> getModules(BuildTarget target, SourcePathResolver resolver,
        String parameter, Path baseModule, SourceList items, PatternMatchedCollection<SourceList> platformItems,
        PythonPlatform pythonPlatform, Optional<VersionMatchedCollection<SourceList>> versionItems,
        Optional<ImmutableMap<BuildTarget, Version>> versions) {
    return ImmutableMap.<Path, SourcePath>builder()
            .putAll(PythonUtil.toModuleMap(target, resolver, parameter, baseModule, ImmutableList.of(items)))
            .putAll(PythonUtil.toModuleMap(target, resolver,
                    "platform" + CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, parameter), baseModule,
                    platformItems.getMatchingValues(pythonPlatform.getFlavor().toString())))
            .putAll(PythonUtil.toModuleMap(target, resolver,
                    "versioned" + CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, parameter), baseModule,
                    versions.isPresent() && versionItems.isPresent()
                            ? versionItems.get().getMatchingValues(versions.get())
                            : ImmutableList.of()))
            .build();/*  w w  w.  jav a  2  s  .  c  o m*/
}

From source file:fr.putnami.pwt.core.widget.client.util.StyleUtils.java

public static void initStyle(Widget w) {
    if (w != null && w.getElement() != null) {
        String widgetClassName = "p-"
                + CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, w.getClass().getSimpleName());
        w.getElement().addClassName(widgetClassName);
    }//from  w  ww.j a  v  a  2 s  . co m
}

From source file:brooklyn.entity.basic.Lifecycle.java

/**
 * Creates a {@link Lifecycle} from a text representation.
 *
 * This accepts the text representations output by the {@link #value()} method for each entry.
 *
 * @see #value()//from ww w.  ja v  a  2s .  com
 */
public static Lifecycle fromValue(String v) {
    try {
        return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, v));
    } catch (IllegalArgumentException iae) {
        return ON_FIRE;
    }
}

From source file:com.google.template.soy.passes.ResolvePackageRelativeCssNamesVisitor.java

private static String toCamelCase(String packageName) {
    String packageNameWithDashes = packageName.replace('.', '-');
    return CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL, packageNameWithDashes);
}

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.//ww  w. j  av 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:org.fenixedu.start.ProjectRequest.java

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