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:iterator.view.Details.java

public void setDetails() {
    StringBuilder html = new StringBuilder("<html>");
    String name = CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL,
            Optional.fromNullable(ifs.getName()).or(IFS.UNTITLED));
    String words = CharMatcher.JAVA_LETTER_OR_DIGIT.negate().replaceFrom(name, ' ');
    html.append("<a name=\"top\"></a>").append(String.format("<h1 id=\"title\">IFS %s</h1>", words));

    if (ifs.isEmpty()) {
        html.append("<h2>Empty</h2>");
    } else {//from w  w w .j a  v a2 s  .  c o  m
        int i = 0;
        int columns = (int) Math.floor((float) getWidth() / 350f);
        html.append("<table>");
        for (Transform t : Ordering.from(IFS.IDENTITY).immutableSortedCopy(ifs)) {
            if (i % columns == 0 && i != 0)
                html.append("</tr>");
            if (i % columns == 0)
                html.append("<tr>");
            html.append("<td>").append("<table class=\"ifs\" width=\"250px\">");

            double[] matrix = new double[6];
            t.getTransform().getMatrix(matrix);

            Color c = Color.WHITE;
            if (controller.isColour()) {
                if (controller.hasPalette()) {
                    c = controller.getColours().get(i % controller.getPaletteSize());
                } else {
                    c = Color.getHSBColor((float) i / (float) ifs.size(), 0.8f, 0.8f);
                }
            }

            String transform = String.format(
                    "<tr class=\"transform\">" + "<td class=\"id\">%02d</td>"
                            + "<td class=\"bracketl\" rowspan=\"2\">&nbsp;</td>"
                            + "<td class=\"matrixr1\" align=\"right\">%.3f</td>"
                            + "<td class=\"matrixr1\" align=\"right\">%.3f</td>"
                            + "<td class=\"matrixr1\" align=\"right\">%.3f</td>"
                            + "<td class=\"bracketr\" rowspan=\"2\">&nbsp;</td>" + "</tr>"
                            + "<tr class=\"transform\">" + "<td class=\"info\">%.1f%%"
                            + "<div style=\"width: 15px; height: 10px; border: 1px solid %s; "
                            + "background: #%02x%02x%02x; padding: 0; margin: 0;\">&nbsp;</div>" + "</td>"
                            + "<td class=\"matrixr2\" align=\"right\">%.3f</td>"
                            + "<td class=\"matrixr2\" align=\"right\">%.3f</td>"
                            + "<td class=\"matrixr2\" align=\"right\">%.3f</td>" + "</tr>"
                            + "<tr class=\"space\"><td colspan=\"6\">&nbsp;</td></tr>",
                    t.getId(), matrix[0], matrix[1], matrix[2], 100d * t.getDeterminant() / ifs.getWeight(),
                    controller.isColour() ? "black" : "white", c.getRed(), c.getGreen(), c.getBlue(), matrix[3],
                    matrix[4], matrix[5]);
            html.append(transform).append("</table>").append("</td>");

            i++;
        }
        html.append("</tr>").append("</table>");
    }

    html.append("</html>");
    setText(html.toString());

    repaint();

    scrollToReference("top");
}

From source file:com.robrit.moofluids.common.util.EntityHelper.java

public static ResourceLocation getLootTable(final String entityName) {
    final String entityNameLocalized = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, entityName);

    return new ResourceLocation(ModInformation.MOD_ID, "entities/" + entityNameLocalized);
}

From source file:com.github.jcustenborder.kafka.connect.cdc.SchemaGenerator.java

private static CaseFormat caseFormat(CDCSourceConnectorConfig.CaseFormat inputCaseFormat) {
    CaseFormat inputFormat;/*  www  .j a v  a 2 s  .co m*/
    switch (inputCaseFormat) {
    case LOWER_CAMEL:
        inputFormat = CaseFormat.LOWER_CAMEL;
        break;
    case LOWER_HYPHEN:
        inputFormat = CaseFormat.LOWER_HYPHEN;
        break;
    case LOWER_UNDERSCORE:
        inputFormat = CaseFormat.LOWER_UNDERSCORE;
        break;
    case UPPER_CAMEL:
        inputFormat = CaseFormat.UPPER_CAMEL;
        break;
    case UPPER_UNDERSCORE:
        inputFormat = CaseFormat.UPPER_UNDERSCORE;
        break;
    default:
        throw new UnsupportedOperationException(
                String.format("'%s' is not a supported case format.", inputCaseFormat));
    }
    return inputFormat;
}

From source file:com.zaradai.kunzite.trader.tools.EodDownloadOptionsParser.java

private String toCamelCase(String type) {
    return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, type.toLowerCase());
}

From source file:org.ow2.proactive.scheduling.api.graphql.fetchers.JobDataFetcher.java

@Override
protected Stream<Job> dataMapping(Stream<JobData> dataStream) {
    return dataStream.map(jobData -> Job.builder()
            .dataManagement(DataManagement.builder().globalSpaceUrl(jobData.getGlobalSpace())
                    .inputSpaceUrl(jobData.getInputSpace()).outputSpaceUrl(jobData.getOutputSpace())
                    .userSpaceUrl(jobData.getUserSpace()).build())
            .description(jobData.getDescription()).finishedTime(jobData.getFinishedTime())
            .genericInformation(jobData.getGenericInformation()).id(jobData.getId())
            .inErrorTime(jobData.getInErrorTime()).lastUpdatedTime(jobData.getLastUpdatedTime())
            .maxNumberOfExecution(jobData.getMaxNumberOfExecution()).name(jobData.getJobName())
            .numberOfFailedTasks(jobData.getNumberOfFailedTasks())
            .numberOfFaultyTasks(jobData.getNumberOfFaultyTasks())
            .numberOfFinishedTasks(jobData.getNumberOfFinishedTasks())
            .numberOfInErrorTasks(jobData.getNumberOfInErrorTasks())
            .numberOfPendingTasks(jobData.getNumberOfPendingTasks())
            .numberOfRunningTasks(jobData.getNumberOfRunningTasks())
            .onTaskError(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, jobData.getOnTaskErrorString()))
            .owner(jobData.getOwner()).priority(jobData.getPriority().name())
            .projectName(jobData.getProjectName()).removedTime(jobData.getRemovedTime())
            .status(jobData.getStatus().name()).startTime(jobData.getStartTime())
            .submittedTime(jobData.getSubmittedTime()).totalNumberOfTasks(jobData.getTotalNumberOfTasks())
            // TODO Currently map the JobVariable object to a simple string (its value).
            // Need to map the whole object later
            .variables(getVariables(jobData)).build());
}

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

/**
 * Validates the class definition and if valid, destructively extracts the class definition from
 * the AST./* ww  w  .java 2  s  .c  o m*/
 */
@Nullable
static PolymerClassDefinition extractFromCallNode(Node callNode, AbstractCompiler compiler,
        GlobalNamespace globalNames) {
    Node descriptor = NodeUtil.getArgumentForCallOrNew(callNode, 0);
    if (descriptor == null || !descriptor.isObjectLit()) {
        // report bad class definition
        compiler.report(JSError.make(callNode, PolymerPassErrors.POLYMER_DESCRIPTOR_NOT_VALID));
        return null;
    }

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

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

    Node target;
    if (NodeUtil.isNameDeclaration(callNode.getGrandparent())) {
        target = IR.name(callNode.getParent().getString());
    } else if (callNode.getParent().isAssign()) {
        target = callNode.getParent().getFirstChild().cloneTree();
    } else {
        String elNameStringBase = elName.isQualifiedName() ? elName.getQualifiedName().replace('.', '$')
                : elName.getString();
        String elNameString = CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, elNameStringBase);
        elNameString += "Element";
        target = IR.name(elNameString);
    }

    JSDocInfo classInfo = NodeUtil.getBestJSDocInfo(target);

    JSDocInfo ctorInfo = null;
    Node constructor = NodeUtil.getFirstPropMatchingKey(descriptor, "factoryImpl");
    if (constructor == null) {
        constructor = NodeUtil.emptyFunction();
        compiler.reportChangeToChangeScope(constructor);
        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");
    PolymerBehaviorExtractor behaviorExtractor = new PolymerBehaviorExtractor(compiler, globalNames);
    ImmutableList<BehaviorDefinition> behaviors = behaviorExtractor.extractBehaviors(behaviorArray);
    List<MemberDefinition> allProperties = new ArrayList<>();
    for (BehaviorDefinition behavior : behaviors) {
        overwriteMembersIfPresent(allProperties, behavior.props);
    }
    overwriteMembersIfPresent(allProperties,
            PolymerPassStaticUtils.extractProperties(descriptor, DefinitionType.ObjectLiteral, compiler,
                    /** constructor= */
                    null));

    FeatureSet newFeatures = null;
    if (!behaviors.isEmpty()) {
        newFeatures = behaviors.get(0).features;
        for (int i = 1; i < behaviors.size(); i++) {
            newFeatures = newFeatures.union(behaviors.get(i).features);
        }
    }

    List<MemberDefinition> methods = new ArrayList<>();
    for (Node keyNode : descriptor.children()) {
        boolean isFunctionDefinition = keyNode.isMemberFunctionDef()
                || (keyNode.isStringKey() && keyNode.getFirstChild().isFunction());
        if (isFunctionDefinition) {
            methods.add(
                    new MemberDefinition(NodeUtil.getBestJSDocInfo(keyNode), keyNode, keyNode.getFirstChild()));
        }
    }

    return new PolymerClassDefinition(DefinitionType.ObjectLiteral, callNode, target, descriptor, classInfo,
            new MemberDefinition(ctorInfo, null, constructor), nativeBaseElement, allProperties, methods,
            behaviors, newFeatures);
}

From source file:org.ow2.proactive.scheduling.api.graphql.fetchers.TaskDataFetcher.java

@Override
protected Stream<Task> dataMapping(Stream<TaskData> dataStream) {
    // TODO Task progress not accessible from DB. It implies to establish a connection with
    // the SchedulerFrontend active object to get the value that is in the Scheduler memory

    return dataStream.map(taskData -> {
        TaskData.DBTaskId id = taskData.getId();

        return Task.builder().additionalClasspath(taskData.getAdditionalClasspath())
                .description(taskData.getDescription()).executionDuration(taskData.getExecutionDuration())
                .executionHostname(taskData.getExecutionHostName()).finishedTime(taskData.getFinishedTime())
                .genericInformation(taskData.getGenericInformation()).id(id.getTaskId())
                .inErrorTime(taskData.getInErrorTime()).javaHome(taskData.getJavaHome()).jobId(id.getJobId())
                .jvmArguments(taskData.getJvmArguments())
                .maxNumberOfExecution(taskData.getMaxNumberOfExecution()).name(taskData.getTaskName())
                .numberOfExecutionLeft(taskData.getNumberOfExecutionLeft())
                .numberOfExecutionOnFailureLeft(taskData.getNumberOfExecutionOnFailureLeft())
                .onTaskError(// ww  w.ja va2  s.co  m
                        CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, taskData.getOnTaskErrorString()))
                .preciousLogs(taskData.isPreciousLogs()).preciousResult(taskData.isPreciousResult())
                .restartMode(RestartMode.getMode(taskData.getRestartModeId()).getDescription().toUpperCase())
                .resultPreview(taskData.getResultPreview()).runAsMe(taskData.isRunAsMe())
                .scheduledTime(taskData.getScheduledTime()).startTime(taskData.getStartTime())
                .status(taskData.getTaskStatus().name()).tag(taskData.getTag())
                .variables(taskData.getVariables().values().stream()
                        .map(taskDataVariable -> Maps.immutableEntry(taskDataVariable.getName(),
                                taskDataVariable.getValue()))
                        .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)))
                .workingDir(taskData.getWorkingDir()).walltime(taskData.getWallTime()).build();
    });
}

From source file:com.thoughtworks.go.spark.spa.spring.InitialContextProvider.java

private String humanizedControllerName(Class<? extends SparkController> controller) {
    return CaseFormat.UPPER_CAMEL.converterTo(CaseFormat.LOWER_UNDERSCORE)
            .convert(controller.getSimpleName().replaceAll("(Delegate|Controller)", ""));
}

From source file:com.spectralogic.ds3cli.Ds3Cli.java

private String listAllCommands() {
    final StringBuilder commands = new StringBuilder("Installed Commands: ");
    final Iterator<CliCommand> implementations = getAllCommands();
    while (implementations.hasNext()) {
        final CliCommand implementation = implementations.next();
        commands.append(CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE,
                implementation.getClass().getSimpleName()));
        if (implementations.hasNext()) {
            commands.append(", ");
        }//from w ww  .j a v  a2  s .  com
    }
    return commands.toString();
}

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

public static ImmutableMap<Path, SourcePath> getModules(BuildTarget target, ActionGraphBuilder graphBuilder,
        SourcePathRuleFinder ruleFinder, SourcePathResolver pathResolver, PythonPlatform pythonPlatform,
        CxxPlatform cxxPlatform, String parameter, Path baseModule, SourceSortedSet items,
        PatternMatchedCollection<SourceSortedSet> platformItems,
        Optional<VersionMatchedCollection<SourceSortedSet>> versionItems,
        Optional<ImmutableMap<BuildTarget, Version>> versions) {
    return CxxGenruleDescription.fixupSourcePaths(graphBuilder, ruleFinder, cxxPlatform, ImmutableMap
            .<Path, SourcePath>builder()
            .putAll(PythonUtil.toModuleMap(target, pathResolver, parameter, baseModule,
                    ImmutableList.of(items)))
            .putAll(PythonUtil.toModuleMap(target, pathResolver,
                    "platform" + CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, parameter), baseModule,
                    Iterables.concat(platformItems.getMatchingValues(pythonPlatform.getFlavor().toString()),
                            platformItems.getMatchingValues(cxxPlatform.getFlavor().toString()))))
            .putAll(PythonUtil.toModuleMap(target, pathResolver,
                    "versioned" + CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, parameter), baseModule,
                    versions.isPresent() && versionItems.isPresent()
                            ? versionItems.get().getMatchingValues(versions.get())
                            : ImmutableList.of()))
            .build());/* ww  w .  ja  va  2  s.  c om*/
}