Example usage for java.util EnumMap put

List of usage examples for java.util EnumMap put

Introduction

In this page you can find the example usage for java.util EnumMap put.

Prototype

public V put(K key, V value) 

Source Link

Document

Associates the specified value with the specified key in this map.

Usage

From source file:org.graphwalker.restful.Util.java

private static EnumMap<Statistics, Integer> getStatistics(Context context) {
    EnumMap<Statistics, Integer> map = new EnumMap<>(Statistics.class);
    map.put(Statistics.TOTAL_NUMBER_OF_VERTICES, context.getModel().getVertices().size());
    map.put(Statistics.TOTAL_NUMBER_OF_UNVISITED_VERTICES,
            context.getProfiler().getUnvisitedVertices(context).size());
    map.put(Statistics.TOTAL_NUMBER_OF_EDGES, context.getModel().getEdges().size());
    map.put(Statistics.TOTAL_NUMBER_OF_UNVISITED_EDGES,
            context.getProfiler().getUnvisitedEdges(context).size());
    map.put(Statistics.TOTAL_NUMBER_OF_REQUIREMENTS, context.getRequirements().size());
    map.put(Statistics.TOTAL_NUMBER_OF_REQUIREMENTS_NOT_COVERED,
            context.getRequirements(RequirementStatus.NOT_COVERED).size());
    map.put(Statistics.TOTAL_NUMBER_OF_REQUIREMENTS_PASSED,
            context.getRequirements(RequirementStatus.PASSED).size());
    map.put(Statistics.TOTAL_NUMBER_OF_REQUIREMENTS_FAILED,
            context.getRequirements(RequirementStatus.FAILED).size());
    return map;//from w  ww  . ja  v  a  2s. c om
}

From source file:org.apache.metron.dataloads.nonbulk.flatfile.LoadOptions.java

public static EnumMap<LoadOptions, Optional<Object>> createConfig(CommandLine cli) {
    EnumMap<LoadOptions, Optional<Object>> ret = new EnumMap<>(LoadOptions.class);
    for (LoadOptions option : values()) {
        ret.put(option, option.handler.getValue(option, cli));
    }// w  w w.jav  a 2 s  .  c  o m
    return ret;
}

From source file:org.gradle.jvm.toolchain.internal.JavaInstallationProbe.java

private static EnumMap<SysProp, String> current() {
    EnumMap<SysProp, String> result = new EnumMap<SysProp, String>(SysProp.class);
    for (SysProp type : SysProp.values()) {
        result.put(type, System.getProperty(type.sysProp, UNKNOWN));
    }/*from  w  w w .  j av a  2  s.  c  o m*/
    return result;
}

From source file:org.gradle.jvm.toolchain.internal.JavaInstallationProbe.java

private static EnumMap<SysProp, String> error(String message) {
    EnumMap<SysProp, String> result = new EnumMap<SysProp, String>(SysProp.class);
    for (SysProp type : SysProp.values()) {
        result.put(type, UNKNOWN);
    }/*from  w w  w  .  ja v a 2 s .co m*/
    result.put(SysProp.Z_ERROR, message);
    return result;
}

From source file:org.gradle.jvm.toolchain.internal.JavaInstallationProbe.java

private static EnumMap<SysProp, String> parseExecOutput(String probeResult) {
    String[] split = probeResult.split(System.getProperty("line.separator"));
    if (split.length != SysProp.values().length - 1) { // -1 because of Z_ERROR
        return error("Unexpected command output: \n" + probeResult);
    }//from  ww  w  .  j  a v a  2s .  c  o m
    EnumMap<SysProp, String> result = new EnumMap<SysProp, String>(SysProp.class);
    for (SysProp type : SysProp.values()) {
        if (type != SysProp.Z_ERROR) {
            result.put(type, split[type.ordinal()]);
        }
    }
    return result;
}

From source file:org.zanata.client.commands.FileMappingRuleHandler.java

@VisibleForTesting
protected static EnumMap<Placeholders, String> parseToMap(@Nonnull String sourceFile,
        @Nonnull LocaleMapping localeMapping, Optional<String> translationFileExtension) {
    EnumMap<Placeholders, String> parts = new EnumMap<Placeholders, String>(Placeholders.class);
    File file = new File(sourceFile);

    String extension = translationFileExtension.isPresent() ? translationFileExtension.get()
            : FilenameUtils.getExtension(sourceFile);
    String filename = FilenameUtils.removeExtension(file.getName());
    parts.put(Placeholders.extension, extension);
    parts.put(Placeholders.filename, filename);
    parts.put(Placeholders.locale, localeMapping.getLocalLocale());
    parts.put(Placeholders.localeWithUnderscore, localeMapping.getLocalLocale().replaceAll("\\-", "_"));
    String pathname = Strings.nullToEmpty(file.getParent());
    parts.put(Placeholders.path, FileUtil.simplifyPath(pathname));
    log.debug("parsed parts: {}", parts);
    return parts;
}

From source file:org.janusgraph.graphdb.database.log.TransactionLogHeader.java

public static Entry parse(StaticBuffer buffer, Serializer serializer, TimestampProvider times) {
    ReadBuffer read = buffer.asReadBuffer();
    Instant txTimestamp = times.getTime(read.getLong());
    TransactionLogHeader header = new TransactionLogHeader(VariableLong.readPositive(read), txTimestamp, times);
    LogTxStatus status = serializer.readObjectNotNull(read, LogTxStatus.class);
    EnumMap<LogTxMeta, Object> metadata = new EnumMap<LogTxMeta, Object>(LogTxMeta.class);
    int metaSize = VariableLong.unsignedByte(read.getByte());
    for (int i = 0; i < metaSize; i++) {
        LogTxMeta meta = LogTxMeta.values()[VariableLong.unsignedByte(read.getByte())];
        metadata.put(meta, serializer.readObjectNotNull(read, meta.dataType()));
    }/*from   w w w  .  j a  v a 2s .com*/
    if (read.hasRemaining()) {
        StaticBuffer content = read.subrange(read.getPosition(), read.length() - read.getPosition());
        return new Entry(header, content, status, metadata);
    } else {
        return new Entry(header, null, status, metadata);
    }
}

From source file:org.sonar.java.checks.verifier.CheckVerifier.java

private static void updateEndLine(int expectedLine, EnumMap<IssueAttribute, String> attr) {
    if (attr.containsKey(IssueAttribute.END_LINE)) {
        String endLineStr = attr.get(IssueAttribute.END_LINE);
        if (endLineStr.charAt(0) == '+') {
            int endLine = Integer.parseInt(endLineStr);
            attr.put(IssueAttribute.END_LINE, Integer.toString(expectedLine + endLine));
        } else {/*from   ww w  .j a va 2 s . c  o m*/
            Fail.fail("endLine attribute should be relative to the line and must be +N with N integer");
        }
    }
}

From source file:org.apache.hadoop.hdfs.server.namenode.FSImageTestUtil.java

/**
 * @see #countEditLogOpTypes(File)//  w  ww. j a v  a2s  . c o  m
 */
public static EnumMap<FSEditLogOpCodes, Holder<Integer>> countEditLogOpTypes(EditLogInputStream elis)
        throws IOException {
    EnumMap<FSEditLogOpCodes, Holder<Integer>> opCounts = new EnumMap<FSEditLogOpCodes, Holder<Integer>>(
            FSEditLogOpCodes.class);

    FSEditLogOp op;
    while ((op = elis.readOp()) != null) {
        Holder<Integer> i = opCounts.get(op.opCode);
        if (i == null) {
            i = new Holder<Integer>(0);
            opCounts.put(op.opCode, i);
        }
        i.held++;
    }
    return opCounts;
}

From source file:fr.avianey.androidsvgdrawable.QualifiedResource.java

public File getOutputFor(final Density density, final File to, final OutputType outputType) {
    StringBuilder builder = new StringBuilder(outputType.name());
    EnumMap<Type, String> qualifiers = new EnumMap<>(typedQualifiers);
    qualifiers.remove(Type.density);
    qualifiers.put(Type.density, density.name());
    builder.append(Qualifier.toQualifiedString(qualifiers));
    return new File(to, builder.toString());
}