Example usage for com.google.common.collect ImmutableMap.Builder putAll

List of usage examples for com.google.common.collect ImmutableMap.Builder putAll

Introduction

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

Prototype

public final void putAll(Map<? extends K, ? extends V> map) 

Source Link

Usage

From source file:org.lealone.cluster.net.MessageOut.java

public MessageOut<T> withParameter(String key, byte[] value) {
    ImmutableMap.Builder<String, byte[]> builder = ImmutableMap.builder();
    builder.putAll(parameters).put(key, value);
    return new MessageOut<T>(verb, payload, serializer, builder.build());
}

From source file:com.publictransitanalytics.scoregenerator.distance.CompositeDistanceStoreManager.java

@Override
public Map<PointLocation, WalkingCosts> get(final PointLocation location, final Duration duration)
        throws InterruptedException {
    final ImmutableMap.Builder<PointLocation, WalkingCosts> builder = ImmutableMap.builder();
    builder.putAll(defaultStore.get(location, duration));
    for (final DistanceStoreManager store : supplementalStores.values()) {
        builder.putAll(store.get(location, duration));
    }/*from ww  w .  java2 s  . com*/
    return builder.build();
}

From source file:org.zanata.async.AsyncTaskHandleManager.java

public Map<String, AsyncTaskHandle<?>> getAllTasks() {
    ImmutableMap.Builder<String, AsyncTaskHandle<?>> builder = ImmutableMap.builder();
    builder.putAll(handlesByKey);
    builder.putAll(finishedTasks.asMap());
    return builder.build();
}

From source file:edu.cmu.lti.oaqa.baseqa.answer.yesno.scorers.ExpectedAnswerOverlapYesNoScorer.java

@Override
public Map<String, Double> score(JCas jcas) throws AnalysisEngineProcessException {
    // assume the last concept mention in the question as the expected answer
    ConceptMention lastCmention = TypeUtil.getOrderedConceptMentions(jcas).stream().min(Comparator
            .comparingInt(ConceptMention::getEnd).reversed().thenComparingInt(ConceptMention::getBegin))
            .orElse(null);// w w  w  .  j  a v a  2 s  .  com
    if (lastCmention == null)
        return ImmutableMap.of();
    // find all concepts that correspond to the offsets of the last cmention
    int begin = lastCmention.getBegin();
    int end = lastCmention.getEnd();
    Set<Concept> lastConcepts = TypeUtil.getOrderedConceptMentions(jcas).stream()
            .filter(cmention -> cmention.getBegin() == begin && cmention.getEnd() == end)
            .map(ConceptMention::getConcept).collect(toSet());
    Set<String> expectedAnswerNames = lastConcepts.stream().map(TypeUtil::getConceptNames)
            .flatMap(Collection::stream).map(String::toLowerCase).collect(toSet());
    LOG.info("Expected answer names: {}", expectedAnswerNames);
    List<JCas> views = ViewType.listViews(jcas, viewNamePrefix);
    List<Integer> containsExpectedAnswerNames = new ArrayList<>();
    List<Integer> containsLastConcepts = new ArrayList<>();
    for (JCas view : views) {
        String text = view.getDocumentText().toLowerCase();
        boolean containsExpectedAnswerName = expectedAnswerNames.stream().anyMatch(text::contains);
        containsExpectedAnswerNames.add(containsExpectedAnswerName ? 1 : 0);
        boolean containsLastConcept = TypeUtil.getConceptMentions(view).stream().map(ConceptMention::getConcept)
                .anyMatch(lastConcepts::contains);
        containsLastConcepts.add(containsLastConcept ? 1 : 0);
    }
    ImmutableMap.Builder<String, Double> features = ImmutableMap.builder();
    features.putAll(YesNoScorer.aggregateFeatures(containsExpectedAnswerNames, "expected-answer-overlap"));
    features.putAll(YesNoScorer.aggregateFeatures(containsLastConcepts, "last-concept-overlap"));
    return features.build();
}

From source file:org.jooby.internal.RouteChain.java

public RouteChain(final RequestImpl req, final ResponseImpl rsp, final List<Route> routes) {
    this.routes = routes;
    this.rreq = req;
    this.rrsp = rsp;

    // eager decision if we need to wrap a route to get all the attrs within the change.
    ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();
    routes.forEach(r -> builder.putAll(r.attributes()));
    this.hasAttrs = builder.build().size() > 0;
}

From source file:org.gradle.api.internal.tasks.compile.AntDependsStaleClassCleaner.java

public void execute() {
    ImmutableMap.Builder<String, Object> options = ImmutableMap.builder();
    options.put("destDir", getDestinationDir());
    options.putAll(compileOptions.getDependOptions().optionMap());
    if (compileOptions.getDependOptions().isUseCache()) {
        options.put("cache", dependencyCacheDir);
    }// w  w  w .  j a va2  s.  c  om

    final AntBuilder ant = antBuilderFactory.create();
    ant.getProject().addTaskDefinition("gradleDepend", AntDepend.class);
    ant.invokeMethod("gradleDepend", new Object[] { options.build(), new Closure<Object>(this, this) {
        @SuppressWarnings("UnusedDeclaration")
        public void doCall(Object ignore) {
            getSource().addToAntBuilder(ant, "src", FileCollection.AntType.MatchingTask);
        }
    } });
}

From source file:io.appium.java_client.screenrecording.BaseScreenRecordingOptions.java

/**
 * Builds a map, which is ready to be passed to the subordinated
 * Appium API.//from  w  ww.  ja  v  a  2  s  .co  m
 *
 * @return arguments mapping.
 */
public Map<String, Object> build() {
    final ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();
    //noinspection unchecked
    ofNullable(uploadOptions).map(x -> builder.putAll(x.build()));
    return builder.build();
}

From source file:io.appium.java_client.ios.IOSStartScreenRecordingOptions.java

@Override
public Map<String, Object> build() {
    final ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();
    builder.putAll(super.build());
    ofNullable(videoType).map(x -> builder.put("videoType", x));
    ofNullable(videoQuality).map(x -> builder.put("videoQuality", x));
    ofNullable(videoScale).map(x -> builder.put("videoScale", x));
    ofNullable(fps).map(x -> builder.put("videoFps", x));
    return builder.build();
}

From source file:com.btmatthews.atlas.core.domain.i18n.Localized.java

/**
 * Construct a localized value with the values.
 *
 * @param vals Maps locales to values.// w ww. jav  a 2  s  . c om
 */
public Localized(final Map<Locale, T> vals) {
    final ImmutableMap.Builder<Locale, T> builder = ImmutableMap.builder();
    values = builder.putAll(vals).build();
}

From source file:com.facebook.buck.skylark.parser.AbstractBuckGlobals.java

/**
 * Returns a native module with built-in functions and Buck rules.
 *
 * <p>It's the module that handles method calls like {@code native.glob} or {@code
 * native.cxx_library}./* w ww  .ja  v  a  2s  . co  m*/
 */
@Lazy
ClassObject getNativeModule() {
    ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>();
    builder.putAll(getBuckRuleFunctions());
    addNativeModuleFunctions(builder);
    return StructProvider.STRUCT.create(builder.build(), "no native function or rule '%s'");
}