Example usage for com.google.common.collect ImmutableMap entrySet

List of usage examples for com.google.common.collect ImmutableMap entrySet

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableMap entrySet.

Prototype

public final ImmutableSet<Entry<K, V>> entrySet() 

Source Link

Usage

From source file:com.google.api.ads.adwords.keywordoptimizer.AbstractSeedGenerator.java

@Override
public final KeywordCollection generate() throws KeywordOptimizerException {
    ImmutableMap<String, IdeaEstimate> keywordsAndEstimates = getKeywordsAndEstimates();

    KeywordCollection keywordCollection = new KeywordCollection(campaignConfiguration);

    for (Entry<String, IdeaEstimate> keywordEntry : keywordsAndEstimates.entrySet()) {
        for (KeywordMatchType matchType : matchTypes) {
            Keyword keyword = KeywordOptimizerUtil.createKeyword(keywordEntry.getKey(), matchType);
            keywordCollection.add(new KeywordInfo(keyword, keywordEntry.getValue(), null, null));
        }/*  w  w w.j  a v  a2 s.  c o m*/
    }

    return keywordCollection;
}

From source file:com.facebook.buck.parser.implicit.PackageImplicitIncludesFinder.java

private PackageImplicitIncludesFinder(ImmutableMap<String, ImplicitInclude> packageToInclude) {
    IncludeNodeBuilder rootBuilder = new IncludeNodeBuilder();
    for (Map.Entry<String, ImplicitInclude> entry : packageToInclude.entrySet()) {
        Path path = Paths.get(entry.getKey());
        IncludeNodeBuilder currentBuilder = rootBuilder;
        for (Path component : path) {
            if (component.toString().isEmpty()) {
                continue;
            }//w ww . j  a v  a2s .c o m
            currentBuilder = currentBuilder.getOrCreateIncludeNodeForPath(component);
        }
        currentBuilder.setInclude(entry.getValue());
    }
    node = rootBuilder.build();
}

From source file:com.github.jtse.puzzle.util.ScriptModule.java

@Override
protected void configure() {
    List<Map<String, String>> maps = Scripts.read(scriptFile, repeatableKeys);
    bind(new TypeLiteral<List<Map<String, String>>>() {
    }).annotatedWith(Names.named("@script-repeatable"))
            .toInstance(ImmutableList.copyOf(maps.subList(1, maps.size())));

    HashMap<String, String> map = new HashMap<String, String>();
    map.putAll(DEFAULTS);//from   w  w  w  .j  a  va2 s .  c  o  m
    map.putAll(maps.get(0));

    ImmutableMap<String, String> config = ImmutableMap.copyOf(map);

    bind(new TypeLiteral<Map<String, String>>() {
    }).annotatedWith(Names.named("@script-config")).toInstance(config);

    for (Entry<String, String> entry : config.entrySet()) {
        bind(String.class).annotatedWith(Names.named(entry.getKey())).toInstance(entry.getValue());
    }
}

From source file:com.liveramp.megadesk.recipes.aggregator.InterProcessMultiTaskKeyedAggregator.java

private AGGREGATE aggregateAttempts(KEY key, ImmutableMap<TASK, ImmutableMap<KEY, AGGREGATE>> attempts) {
    // Aggregate attempts on the fly
    AGGREGATE result = null;/*from ww w.  j a  v a  2  s .c  o m*/
    for (Map.Entry<TASK, ImmutableMap<KEY, AGGREGATE>> entry : attempts.entrySet()) {
        if (entry.getValue().containsKey(key)) {
            if (result == null) {
                result = aggregator.initialValue();
            }
            result = aggregator.merge(result, entry.getValue().get(key));
        }
    }
    return result;
}

From source file:org.gradle.internal.execution.history.impl.DefaultPreviousExecutionStateSerializer.java

public void writeInputProperties(Encoder encoder, ImmutableMap<String, ValueSnapshot> properties)
        throws Exception {
    encoder.writeSmallInt(properties.size());
    for (Map.Entry<String, ValueSnapshot> entry : properties.entrySet()) {
        encoder.writeString(entry.getKey());
        writeValueSnapshot(encoder, entry.getValue());
    }/* w w  w  .  j a  va  2 s  .  co m*/
}

From source file:com.google.devtools.build.lib.query2.ActionGraphTextOutputFormatterCallback.java

private void writeAction(ActionAnalysisMetadata action, PrintStream printStream)
        throws IOException, CommandLineExpansionException {
    ActionOwner actionOwner = action.getOwner();
    StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append(action.prettyPrint()).append('\n').append("  Mnemonic: ").append(action.getMnemonic())
            .append('\n');

    if (actionOwner != null) {
        BuildEvent configuration = actionOwner.getConfiguration();
        BuildEventStreamProtos.Configuration configProto = configuration.asStreamProto(/*context=*/ null)
                .getConfiguration();/*from w  w  w  . ja v  a  2  s  .  com*/
        stringBuilder.append("  Owner: ").append(actionOwner.getLabel().toString()).append('\n')
                .append("  Configuration: ").append(configProto.getMnemonic()).append('\n');
    }

    if (action instanceof ActionExecutionMetadata) {
        ActionExecutionMetadata actionExecutionMetadata = (ActionExecutionMetadata) action;
        stringBuilder.append("  ActionKey: ").append(actionExecutionMetadata.getKey(actionKeyContext))
                .append('\n');
    }

    stringBuilder.append("  Inputs: [")
            .append(Streams.stream(action.getInputs()).map(input -> input.getExecPathString()).sorted()
                    .collect(Collectors.joining(", ")))
            .append("]\n").append("  Outputs: [").append(Streams.stream(action.getOutputs())
                    .map(input -> input.getExecPathString()).sorted().collect(Collectors.joining(", ")))
            .append("]\n");

    if (action instanceof SpawnAction) {
        SpawnAction spawnAction = (SpawnAction) action;
        // TODO(twerth): This handles the fixed environment. We probably want to output the inherited
        // environment as well.
        ImmutableMap<String, String> fixedEnvironment = spawnAction.getEnvironment().getFixedEnv();
        stringBuilder.append("  Environment: [").append(Streams.stream(fixedEnvironment.entrySet())
                .map(environmentVariable -> environmentVariable.getKey() + "=" + environmentVariable.getValue())
                .sorted().collect(Collectors.joining(", "))).append("]\n")

                // TODO(twerth): Add option to only optionally include the command line.
                .append("  Command Line: ")
                .append(CommandFailureUtils.describeCommand(CommandDescriptionForm.COMPLETE,
                        /* prettyPrintArgs= */ true, spawnAction.getArguments(), /* environment= */ null,
                        /* cwd= */ null))
                .append("\n");
    }

    stringBuilder.append('\n');

    printStream.write(stringBuilder.toString().getBytes(UTF_8));
}

From source file:com.facebook.buck.rage.DefaultDefectReporter.java

private void addStringsAsFilesToArchive(CustomZipOutputStream out, ImmutableMap<String, String> files)
        throws IOException {
    for (Map.Entry<String, String> file : files.entrySet()) {
        out.putNextEntry(new CustomZipEntry(file.getKey()));
        out.write(file.getValue().getBytes(Charsets.UTF_8));
        out.closeEntry();/*from  w ww  . ja  va2 s .c  o m*/
    }
}

From source file:uk.q3c.krail.core.navigate.sitemap.DefaultSitemapChecker.java

private void redirectCheck() {
    DynamicDAG<String> dag = new DynamicDAG<>();
    ImmutableMap<String, String> redirectMap = sitemap.getRedirects();
    for (Entry<String, String> entry : redirectMap.entrySet()) {
        try {//from   w  w w .  j  a  va2 s  .  com
            dag.addChild(entry.getKey(), entry.getValue());
        } catch (CycleDetectedException cde) {
            String msg = MessageFormat.format("Redirecting {0} to {1} would cause a loop", entry.getKey(),
                    entry.getValue());
            redirectLoops.add(msg);
            // throw new CycleDetectedException(msg);
        }

    }

}

From source file:google.registry.backup.CommitLogCheckpointStrategy.java

/**
 * Returns a threshold value defined as the latest timestamp that is before all new commit logs,
 * where "new" means having a commit time after the per-bucket timestamp in the given map.
 * When no such commit logs exist, the threshold value is set to END_OF_TIME.
 *//*from   www .ja  v  a2 s.  c o m*/
@VisibleForTesting
DateTime readNewCommitLogsAndFindThreshold(ImmutableMap<Integer, DateTime> bucketTimes) {
    DateTime timeBeforeAllNewCommits = END_OF_TIME;
    for (Entry<Integer, DateTime> entry : bucketTimes.entrySet()) {
        Key<CommitLogBucket> bucketKey = getBucketKey(entry.getKey());
        DateTime bucketTime = entry.getValue();
        // Add 1 to handle START_OF_TIME since 0 isn't a valid id - filter then uses >= instead of >.
        Key<CommitLogManifest> keyForFilter = Key
                .create(CommitLogManifest.create(bucketKey, bucketTime.plusMillis(1), null));
        List<Key<CommitLogManifest>> manifestKeys = ofy.load().type(CommitLogManifest.class).ancestor(bucketKey)
                .filterKey(">=", keyForFilter).limit(1).keys().list();
        if (!manifestKeys.isEmpty()) {
            timeBeforeAllNewCommits = earliestOf(timeBeforeAllNewCommits,
                    CommitLogManifest.extractCommitTime(getOnlyElement(manifestKeys)).minusMillis(1));
        }
    }
    return timeBeforeAllNewCommits;
}

From source file:org.ow2.proactive.workflow_catalog.rest.service.WorkflowRevisionService.java

protected List<Variable> createEntityVariable(ImmutableMap<String, String> variables) {
    return variables.entrySet().stream().map(entry -> new Variable(entry.getKey(), entry.getValue()))
            .collect(Collectors.toList());
}