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:org.jooby.assets.AssetAggregator.java

/**
 * @return Aggregator's name.
 */
public String name() {
    return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, getClass().getSimpleName());
}

From source file:cake.bootstrap.spi.CakeSourcePackages.java

static void createEnums(String directory, Iterable<Path> paths) throws IOException {
    for (Path pp : paths) {
        for (String str : Files.readAllLines(pp, Charset.defaultCharset())) {
            if (str.contains("kind=\"src\"") && (str.contains("main") || str.contains("test"))
                    && !str.contains("combineaccessrules") && !str.contains("private")) {
                String p = str.split("\"")[3];
                String v = p.substring(0, p.indexOf("/src"));
                if (v.contains("/")) {
                    v = v.substring(v.lastIndexOf("/") + 1);
                }//from w w w  .  j av a2 s. co m
                v = CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, v);
                p = "../" + directory + "/" + p;
                System.out.println("    " + v + (str.contains("main") ? "" : "_TEST") + "(\"" + p + "\"),");
            } else if (str.contains("bootstrap")) {
                String p = str.split("\"")[3];
                String v = CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, p.split("/")[0]);
                System.out.println("    " + v + "(\"" + p + "\"),");
            }
        }
    }
}

From source file:org.jooby.assets.AssetProcessor.java

public String name() {
    return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, getClass().getSimpleName());
}

From source file:com.android.utils.SdkUtils.java

/**
 * Translates an XML name (e.g. xml-name) into a Java / C++ constant name (e.g. XML_NAME)
 * @param xmlName the hyphen separated lower case xml name.
 * @return the equivalent constant name.
 *//*from ww  w . j a  v  a  2  s  . co m*/
public static String xmlNameToConstantName(String xmlName) {
    return CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, xmlName);
}

From source file:com.google.javascript.jscomp.PolymerPass.java

/**
 * Validates the class definition and if valid, destructively extracts the class definition from
 * the AST.//from ww  w . jav  a 2 s.  co  m
 */
private ClassDefinition extractClassDefinition(Node callNode) {
    Node descriptor = NodeUtil.getArgumentForCallOrNew(callNode, 0);
    if (descriptor == null || !descriptor.isObjectLit()) {
        // report bad class definition
        compiler.report(JSError.make(callNode, POLYMER_DESCRIPTOR_NOT_VALID));
        return null;
    }

    int paramCount = callNode.getChildCount() - 1;
    if (paramCount != 1) {
        compiler.report(JSError.make(callNode, POLYMER_UNEXPECTED_PARAMS));
        return null;
    }

    Node elName = NodeUtil.getFirstPropMatchingKey(descriptor, "is");
    if (elName == null) {
        compiler.report(JSError.make(callNode, POLYMER_MISSING_IS));
        return null;
    }

    String elNameString = CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, elName.getString());
    elNameString += "Element";

    Node target;
    if (NodeUtil.isNameDeclaration(callNode.getParent().getParent())) {
        target = IR.name(callNode.getParent().getString());
    } else if (callNode.getParent().isAssign()) {
        target = callNode.getParent().getFirstChild().cloneTree();
    } else {
        target = IR.name(elNameString);
    }

    target.useSourceInfoIfMissingFrom(callNode);
    JSDocInfo classInfo = NodeUtil.getBestJSDocInfo(target);

    JSDocInfo ctorInfo = null;
    Node constructor = NodeUtil.getFirstPropMatchingKey(descriptor, "factoryImpl");
    if (constructor == null) {
        constructor = IR.function(IR.name(""), IR.paramList(), IR.block());
        constructor.useSourceInfoFromForTree(callNode);
    } else {
        ctorInfo = NodeUtil.getBestJSDocInfo(constructor);
    }

    Node baseClass = NodeUtil.getFirstPropMatchingKey(descriptor, "extends");
    String nativeBaseElement = baseClass == null ? null : baseClass.getString();

    Node behaviorArray = NodeUtil.getFirstPropMatchingKey(descriptor, "behaviors");
    List<BehaviorDefinition> behaviors = extractBehaviors(behaviorArray);
    List<MemberDefinition> allProperties = new LinkedList<>();
    for (BehaviorDefinition behavior : behaviors) {
        overwriteMembersIfPresent(allProperties, behavior.props);
    }
    overwriteMembersIfPresent(allProperties, extractProperties(descriptor));

    ClassDefinition def = new ClassDefinition(target, descriptor, classInfo,
            new MemberDefinition(ctorInfo, null, constructor), nativeBaseElement, allProperties, behaviors);
    return def;
}

From source file:com.android.utils.SdkUtils.java

/**
 * Translates a Java / C++ constant name (e.g. XML_NAME) into a XML case name (e.g. xml-name)
 * @param constantName the constant name.
 * @return the equivalent XML name.//from  www.j  ava  2  s  .  c  om
 */
public static String constantNameToXmlName(String constantName) {
    return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, constantName);
}

From source file:org.jooby.Renderer.java

/**
 * @return Renderer's name./*w  ww.ja  v  a2  s  . c  o m*/
 */
default String name() {
    String name = getClass().getSimpleName().replace("renderer", "").replace("render", "");
    return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, name);
}

From source file:brooklyn.util.task.BasicExecutionManager.java

/** invoked in a task's thread when a task is starting to run (may be some time after submitted), 
 * but before doing any of the task's work, so that we can update bookkeeping and notify callbacks */
protected void internalBeforeStart(Map<?, ?> flags, Task<?> task) {
    activeTaskCount.incrementAndGet();//w  w w  .j a  va  2s .  co  m

    //set thread _before_ start time, so we won't get a null thread when there is a start-time
    if (log.isTraceEnabled())
        log.trace("" + this + " beforeStart, task: " + task);
    if (!task.isCancelled()) {
        Thread thread = Thread.currentThread();
        ((TaskInternal<?>) task).setThread(thread);
        if (RENAME_THREADS) {
            threadOriginalName.set(thread.getName());
            String newThreadName = "brooklyn-"
                    + CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL, task.getDisplayName().replace(" ", ""))
                    + "-" + task.getId().substring(0, 8);
            thread.setName(newThreadName);
        }
        PerThreadCurrentTaskHolder.perThreadCurrentTask.set(task);
        ((TaskInternal<?>) task).setStartTimeUtc(System.currentTimeMillis());
    }
    ExecutionUtils.invoke(flags.get("newTaskStartCallback"), task);
}

From source file:com.android.build.gradle.internal2.incremental.InstantRunBuildContext.java

private Element toXml(Document document, PersistenceMode persistenceMode) {
    Element instantRun = document.createElement(TAG_INSTANT_RUN);
    document.appendChild(instantRun);/*from  ww  w  . ja v a2s  .c om*/

    for (TaskType taskType : TaskType.values()) {
        Element taskTypeNode = document.createElement(TAG_TASK);
        taskTypeNode.setAttribute(ATTR_NAME,
                CaseFormat.UPPER_UNDERSCORE.converterTo(CaseFormat.LOWER_HYPHEN).convert(taskType.name()));
        taskTypeNode.setAttribute(ATTR_DURATION, String.valueOf(taskDurationInMs[taskType.ordinal()]));
        instantRun.appendChild(taskTypeNode);
    }

    currentBuild.toXml(document, instantRun);
    instantRun.setAttribute(ATTR_API_LEVEL, String.valueOf(getFeatureLevel()));
    if (density != null) {
        instantRun.setAttribute(ATTR_DENSITY, density);
    }
    if (abi != null) {
        instantRun.setAttribute(ATTR_ABI, abi);
    }
    if (token != null) {
        instantRun.setAttribute(ATTR_TOKEN, token.toString());
    }
    instantRun.setAttribute(ATTR_FORMAT, CURRENT_FORMAT);
    instantRun.setAttribute(ATTR_PLUGIN_VERSION, Version.ANDROID_GRADLE_PLUGIN_VERSION);

    switch (persistenceMode) {
    case FULL_BUILD:
        // only include the last build.
        if (!previousBuilds.isEmpty()) {
            instantRun.appendChild(previousBuilds.lastEntry().getValue().toXml(document));
        }
        break;
    case INCREMENTAL_BUILD:
        for (Build build : previousBuilds.values()) {
            instantRun.appendChild(build.toXml(document));
        }
        break;
    case TEMP_BUILD:
        break;
    default:
        throw new RuntimeException("PersistenceMode not handled" + persistenceMode);
    }
    return instantRun;
}

From source file:org.jooby.assets.AssetCompiler.java

private static Map<String, String> bind(final Config conf, final List<String> names) {
    Map<String, String> map = new LinkedHashMap<>();
    names.forEach(name -> {//from   w  ww .j av  a  2  s . c om
        String clazz = AssetCompiler.class.getPackage().getName() + "."
                + CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, name);
        if (conf.hasPath(name + ".class")) {
            clazz = conf.getString(name + ".class");
        }
        map.put(name, clazz);
    });

    return map;
}