List of usage examples for com.google.common.collect ImmutableMap builder
public static <K, V> Builder<K, V> builder()
From source file:org.gradle.internal.operations.trace.BuildOperationTree.java
BuildOperationTree(List<BuildOperationRecord> roots) { ImmutableMap.Builder<Long, BuildOperationRecord> records = ImmutableMap.builder(); for (BuildOperationRecord record : roots) { visit(records, record);/* ww w. j a v a 2s.c o m*/ } this.roots = BuildOperationRecord.ORDERING.immutableSortedCopy(roots); this.records = records.build(); }
From source file:com.proofpoint.configuration.ConfigurationLoader.java
private static ImmutableMap<String, String> toMap(Properties properties) { ImmutableMap.Builder<String, String> result = ImmutableMap.builder(); for (Map.Entry<Object, Object> entry : properties.entrySet()) { result.put(entry.getKey().toString(), entry.getValue().toString()); }/*www . j a va 2 s . com*/ return result.build(); }
From source file:com.google.devtools.build.lib.rules.java.JavaToolchainDataParser.java
/** * Parse a {@link com.google.devtools.build.lib.query2.proto.proto2api.Build.QueryResult} as * returned by a bazel query and look for the list of target containing a {@code java_toolchain} * rule. These rules are then parsed into {@link JavaToolchainData}'s and returned as map with the * name of the target as key and the {@link JavaToolchainData} as value. *//* ww w . j ava 2 s . c o m*/ public static ImmutableMap<String, JavaToolchainData> parse(QueryResult queryResult) { ImmutableMap.Builder<String, JavaToolchainData> builder = ImmutableMap.builder(); for (Build.Target target : queryResult.getTargetList()) { Build.Rule rule = target.getRule(); if (target.hasRule() && rule.getRuleClass().equals("java_toolchain")) { builder.put(rule.getName(), parseBuildRuleProto(rule)); } } return builder.build(); }
From source file:com.google.devtools.build.lib.skylarkbuildapi.apple.AppleBootstrap.java
@Override public void addBindingsToBuilder(ImmutableMap.Builder<String, Object> builder) { builder.put("apple_common", appleCommon); }
From source file:com.google.cloud.datastore.ReadOption.java
static Map<Class<? extends ReadOption>, ReadOption> asImmutableMap(ReadOption... options) { ImmutableMap.Builder<Class<? extends ReadOption>, ReadOption> builder = ImmutableMap.builder(); for (ReadOption option : options) { builder.put(option.getClass(), option); }//from w w w .j av a 2 s . co m return builder.build(); }
From source file:com.google.devtools.build.lib.skylarkbuildapi.platform.PlatformBootstrap.java
@Override public void addBindingsToBuilder(ImmutableMap.Builder<String, Object> builder) { builder.put("platform_common", platformCommon); }
From source file:com.google.auto.factory.processor.Mirrors.java
/** * Returns an annotation value map with {@link String} keys instead of {@link ExecutableElement} * instances./*from w w w. j a v a2 s .com*/ */ static ImmutableMap<String, AnnotationValue> simplifyAnnotationValueMap( Map<? extends ExecutableElement, ? extends AnnotationValue> annotationValueMap) { ImmutableMap.Builder<String, AnnotationValue> builder = ImmutableMap.builder(); for (Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : annotationValueMap.entrySet()) { builder.put(entry.getKey().getSimpleName().toString(), entry.getValue()); } return builder.build(); }
From source file:org.tensorics.core.iterable.operations.IterableOperations.java
/** * Reduces all the collection-values of the multimap by the use of the given operation and returns a map containing * the result of the respective operation. * /*from ww w . j a va2s . c o m*/ * @param values a map containg K->values, for which the values shall be treated by the operation * @param operation the operation which shall be applied to the collection-values * @return a mapt K->value, where value is the result of the operation */ private static <K, V> Map<K, V> reduce(Map<K, Collection<V>> values, IterableOperation<V> operation) { ImmutableMap.Builder<K, V> resultBuilder = ImmutableMap.builder(); for (Entry<K, Collection<V>> entry : values.entrySet()) { resultBuilder.put(entry.getKey(), operation.apply(entry.getValue())); } return resultBuilder.build(); }
From source file:io.sidecar.query.StatsAnswer.java
public StatsAnswer(Map<String, Map<String, Double>> statsKeys) { if (statsKeys == null) { keys = ImmutableMap.of();//from w w w .j a va 2 s .co m } else { Builder<String, ImmutableMap<String, Double>> imb = ImmutableMap.builder(); for (Map.Entry<String, Map<String, Double>> e : statsKeys.entrySet()) { imb.put(e.getKey(), ImmutableMap.copyOf(e.getValue())); } keys = imb.build(); } }
From source file:co.cask.cdap.internal.app.runtime.distributed.ProgramRunnableResourceReporter.java
/** * Returns the metric context. A metric context is of the form * {applicationId}.{programTypeId}.{programId}.{componentId}. So for flows, it will look like * appX.f.flowY.flowletZ. For mapreduce jobs, appX.b.mapredY.{optional m|r}. *//* w w w .j ava 2s .c o m*/ private static Map<String, String> getMetricContext(Program program, TwillContext context) { ImmutableMap.Builder<String, String> builder = ImmutableMap.<String, String>builder() .put(Constants.Metrics.Tag.NAMESPACE, program.getNamespaceId()) .put(Constants.Metrics.Tag.RUN_ID, context.getRunId().getId()) .put(Constants.Metrics.Tag.APP, program.getApplicationId()); if (program.getType() == ProgramType.FLOW) { builder.put(Constants.Metrics.Tag.FLOW, program.getName()); builder.put(Constants.Metrics.Tag.FLOWLET, context.getSpecification().getName()); } else { builder.put(ProgramTypeMetricTag.getTagName(program.getType()), context.getSpecification().getName()); } return builder.build(); }