List of usage examples for com.google.common.collect ImmutableMap builder
public static <K, V> Builder<K, V> builder()
From source file:com.publictransitanalytics.scoregenerator.environment.NodeMappingExporter.java
public NodeMappingExporter() { builder = ImmutableMap.builder(); }
From source file:com.wrmsr.neurosis.util.ImmutableCollectors.java
public static <I, K, V> Collector<I, ImmutableMap.Builder<K, V>, ImmutableMap<K, V>> toImmutableMap( Function<I, K> keyMapper, Function<I, V> valueMapper) { return Collector.of(ImmutableMap::builder, (builder, in) -> builder.put(keyMapper.apply(in), valueMapper.apply(in)), (ImmutableMap.Builder<K, V> left, ImmutableMap.Builder<K, V> right) -> left.putAll(right.build()), ImmutableMap.Builder<K, V>::build); }
From source file:com.facebook.buck.rules.DefaultKnownBuildRuleTypes.java
protected static ImmutableMap<ProcessExecutorParams, FakeProcess> getPythonProcessMap(List<String> paths) { Set<String> uniquePaths = new HashSet<>(paths); ImmutableMap.Builder<ProcessExecutorParams, FakeProcess> processMap = ImmutableMap.builder(); for (Map.Entry<String, String> python : PYTHONS.entrySet()) { for (String path : uniquePaths) { for (String extension : new String[] { "", ".exe", ".EXE" }) { processMap.put(//from w ww .j ava 2 s . co m ProcessExecutorParams.builder() .setCommand(ImmutableList .of(path + File.separator + python.getKey() + extension, "-V")) .build(), new FakeProcess(0, "Python " + python.getValue(), "")); } } } return processMap.build(); }
From source file:com.google.errorprone.refaster.UPlaceholderExpression.java
static UPlaceholderExpression create(PlaceholderMethod placeholder, Iterable<? extends UExpression> arguments) { ImmutableList<UVariableDecl> placeholderParams = placeholder.parameters().asList(); ImmutableList<UExpression> argumentsList = ImmutableList.copyOf(arguments); ImmutableMap.Builder<UVariableDecl, UExpression> builder = ImmutableMap.builder(); for (int i = 0; i < placeholderParams.size(); i++) { builder.put(placeholderParams.get(i), argumentsList.get(i)); }//from w w w. java 2 s. co m return new AutoValue_UPlaceholderExpression(placeholder, builder.build()); }
From source file:ratpack.handlebars.Template.java
public static Template handlebarsTemplate(String name, String contentType, Consumer<? super ImmutableMap.Builder<String, Object>> modelBuilder) { if (modelBuilder == null) { return handlebarsTemplate(name, null, contentType); } else {/* ww w.j av a2 s. c o m*/ ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder(); modelBuilder.accept(builder); return handlebarsTemplate(builder.build(), name, contentType); } }
From source file:org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardUtils.java
public static Registration scheduleWithFixedDelay(Whiteboard whiteboard, Runnable runnable, long delayInSeconds, boolean runOnSingleClusterNode) { ImmutableMap.Builder<String, Object> builder = ImmutableMap.<String, Object>builder() .put("scheduler.period", delayInSeconds).put("scheduler.concurrent", false); if (runOnSingleClusterNode) { //Make use of feature while running in Sling SLING-2979 builder.put("scheduler.runOn", "SINGLE"); }//from ww w .jav a2 s . co m return whiteboard.register(Runnable.class, runnable, builder.build()); }
From source file:com.google.devtools.build.lib.runtime.GCStatsRecorder.java
public GCStatsRecorder(Iterable<GarbageCollectorMXBean> mxBeans) { this.mxBeans = mxBeans; ImmutableMap.Builder<String, GCStat> initialData = ImmutableMap.builder(); for (GarbageCollectorMXBean mxBean : mxBeans) { String name = mxBean.getName(); initialData.put(name, new GCStat(name, mxBean.getCollectionCount(), mxBean.getCollectionTime())); }/* w w w . j a v a 2s .c om*/ this.initialData = initialData.build(); }
From source file:com.facebook.buck.rules.DependencyGraph.java
public BuildRule findBuildRuleByTarget(BuildTarget buildTarget) { if (index == null) { ImmutableMap.Builder<BuildTarget, BuildRule> builder = ImmutableMap.builder(); for (BuildRule rule : getNodes()) { builder.put(rule.getBuildTarget(), rule); }// www.jav a2 s . co m index = builder.build(); } return index.get(buildTarget); }
From source file:net.techcable.pineapple.collect.ImmutableMaps.java
@Nonnull public static <K, V, T, U> ImmutableMap<T, U> transform(ImmutableMap<K, V> original, Function<K, T> keyTransformer, Function<V, U> valueTransformer) { ImmutableMap.Builder<T, U> resultBuilder = builder(checkNotNull(original, "Null map").size()); forEach(original, (originalKey, originalValue) -> { T newKey = checkNotNull(keyTransformer, "Null key transformer").apply(originalKey); U newValue = checkNotNull(valueTransformer, "Null value transformer").apply(originalValue); resultBuilder.put(newKey, newValue); });/*from ww w . j a v a2 s .c o m*/ return resultBuilder.build(); }
From source file:org.terasology.entitysystem.component.ComponentPropertyInfo.java
/** * Constructs the property info/*from www. j a v a 2s. c o m*/ * @param accessors */ public ComponentPropertyInfo(Collection<PropertyAccessor<T, ?>> accessors) { ImmutableMap.Builder<String, PropertyAccessor<T, ?>> builder = ImmutableMap.builder(); accessors.forEach(x -> builder.put(x.getName(), x)); this.properties = builder.build(); }