List of usage examples for com.google.common.collect ImmutableMap.Builder put
public final V put(K k, V v)
From source file:com.google.devtools.build.lib.analysis.Dependency.java
/** * Creates a new {@link Dependency} with the given configuration and aspects, suitable for * static configuration builds. The configuration is also applied to all aspects. * * <p>The configuration and aspects must not be {@code null}. *///from www . j a va 2 s. c om public static Dependency withConfigurationAndAspects(Label label, BuildConfiguration configuration, Iterable<AspectDescriptor> aspects) { ImmutableMap.Builder<AspectDescriptor, BuildConfiguration> aspectBuilder = new ImmutableMap.Builder<>(); for (AspectDescriptor aspect : aspects) { aspectBuilder.put(aspect, configuration); } return new StaticConfigurationDependency(label, configuration, aspectBuilder.build()); }
From source file:appeng.core.PluginLoader.java
private static Map<Class<?>, Object> mapInjectables(Collection<Object> injectables) { ImmutableMap.Builder<Class<?>, Object> builder = ImmutableMap.builder(); for (Object injectable : injectables) { // Get all super-interfaces that were annotated with @AEInjectable Set<Class<?>> injectableIfs = getInjectableInterfaces(injectable.getClass()); for (Class<?> injectableIf : injectableIfs) { builder.put(injectableIf, injectable); }/*from w w w . ja va2 s . com*/ } return builder.build(); }
From source file:com.opengamma.collect.named.ExtendedEnum.java
private static ImmutableMap<String, String> parseAlternates(IniFile config) { if (!config.contains(ALTERNATES_SECTION)) { return ImmutableMap.of(); }//from www. j a va 2 s .c om ImmutableMap.Builder<String, String> builder = ImmutableMap.builder(); PropertySet section = config.getSection(ALTERNATES_SECTION); for (String key : section.keys()) { builder.put(key, section.getValue(key)); } return builder.build(); }
From source file:com.facebook.presto.sql.planner.iterative.rule.AddIntermediateAggregations.java
/** * Rewrite assignments so that inputs are in terms of the output symbols. * <p>/* w w w.ja va 2s . co m*/ * Example: * 'a' := sum('b') => 'a' := sum('a') * 'a' := count(*) => 'a' := count('a') */ private static Map<Symbol, AggregationNode.Aggregation> outputsAsInputs( Map<Symbol, AggregationNode.Aggregation> assignments) { ImmutableMap.Builder<Symbol, AggregationNode.Aggregation> builder = ImmutableMap.builder(); for (Map.Entry<Symbol, AggregationNode.Aggregation> entry : assignments.entrySet()) { Symbol output = entry.getKey(); AggregationNode.Aggregation aggregation = entry.getValue(); builder.put(output, new AggregationNode.Aggregation( new FunctionCall(QualifiedName.of(aggregation.getSignature().getName()), ImmutableList.of(output.toSymbolReference())), aggregation.getSignature(), Optional.empty())); // No mask for INTERMEDIATE } return builder.build(); }
From source file:eu.trentorise.opendata.semtext.SemTexts.java
/** * Returns a copy of provided metadata with {@code newMetadata} set under * the given namespace./* w w w . j ava 2 s . c om*/ * * @param newMetadata Must be an immutable object. */ static ImmutableMap<String, ?> replaceMetadata(ImmutableMap<String, ?> metadata, String namespace, Object newMetadata) { ImmutableMap.Builder<String, Object> mapb = ImmutableMap.builder(); for (String ns : metadata.keySet()) { if (!ns.equals(namespace)) { mapb.put(ns, metadata.get(ns)); } } mapb.put(namespace, newMetadata); return mapb.build(); }
From source file:org.apache.beam.runners.flink.translation.functions.FlinkStreamingSideInputHandlerFactory.java
/** * Creates a new state handler for the given stage. Note that this requires a traversal of the * stage itself, so this should only be called once per stage rather than once per bundle. *///from w ww .j a v a 2 s. com public static FlinkStreamingSideInputHandlerFactory forStage(ExecutableStage stage, Map<SideInputId, PCollectionView<?>> viewMapping, org.apache.beam.runners.core.SideInputHandler runnerHandler) { ImmutableMap.Builder<SideInputId, PCollectionView<?>> sideInputBuilder = ImmutableMap.builder(); for (SideInputReference sideInput : stage.getSideInputs()) { SideInputId sideInputId = SideInputId.newBuilder().setTransformId(sideInput.transform().getId()) .setLocalName(sideInput.localName()).build(); sideInputBuilder.put(sideInputId, checkNotNull(viewMapping.get(sideInputId), "No side input for %s/%s", sideInputId.getTransformId(), sideInputId.getLocalName())); } FlinkStreamingSideInputHandlerFactory factory = new FlinkStreamingSideInputHandlerFactory( sideInputBuilder.build(), runnerHandler); return factory; }
From source file:com.facebook.buck.apple.project_generator.CxxPlatformXcodeConfigGenerator.java
private static void setCxxLibraryValue(List<String> notProcessedCxxFlags, Map<String, String> notProcessedAppendedConfig, ImmutableMap.Builder<String, String> configBuilder) { String clangCxxLibraryValue = getConfigValueForKey(CLANG_CXX_LIBRARY, notProcessedCxxFlags, "-stdlib=", Optional.empty(), notProcessedAppendedConfig); if (clangCxxLibraryValue != null) { configBuilder.put(CLANG_CXX_LIBRARY, clangCxxLibraryValue); notProcessedAppendedConfig.remove(CLANG_CXX_LIBRARY); }/*from ww w. j a va 2 s .co m*/ }
From source file:ealvatag.tag.id3.ID3Mapping.java
private static ImmutableMap<String, String> makeConvertV23ToV22() { ImmutableMap.Builder<String, String> builder = ImmutableMap.builder(); final ImmutableMap<String, String> convertv22Tov23 = getConvertv22Tov23(); for (Map.Entry<String, String> entry : convertv22Tov23.entrySet()) { builder.put(entry.getValue(), entry.getKey()); }//w w w. j av a 2 s. co m //This one way translation allows us to convert XSOT to TST, but in the other direction gets converted to TSOT builder.put(ID3v23Frames.FRAME_ID_V3_TITLE_SORT_ORDER_MUSICBRAINZ, ID3v22Frames.FRAME_ID_V2_TITLE_SORT_ORDER_ITUNES) .put(ID3v23Frames.FRAME_ID_V3_ARTIST_SORT_ORDER_MUSICBRAINZ, ID3v22Frames.FRAME_ID_V2_ARTIST_SORT_ORDER_ITUNES) .put(ID3v23Frames.FRAME_ID_V3_ALBUM_SORT_ORDER_MUSICBRAINZ, ID3v22Frames.FRAME_ID_V2_ALBUM_SORT_ORDER_ITUNES); return builder.build(); }
From source file:com.google.javascript.jscomp.VariableMap.java
/** * Deserializes the variable map from a byte array returned by * {@link #toBytes()}./*from w w w. j a v a2 s. co m*/ */ public static VariableMap fromBytes(byte[] bytes) throws ParseException { Iterable<String> lines = LINE_SPLITTER.split(new String(bytes, UTF_8)); ImmutableMap.Builder<String, String> map = ImmutableMap.builder(); for (String line : lines) { int pos = findIndexOfChar(line, SEPARATOR); if (pos <= 0 || pos == line.length() - 1) { throw new ParseException("Bad line: " + line, 0); } map.put(unescape(line.substring(0, pos)), unescape(line.substring(pos + 1))); } return new VariableMap(map.build()); }
From source file:com.google.firebase.messaging.WebpushNotification.java
private static void addNonNull(ImmutableMap.Builder<String, Object> fields, String key, Object value) { if (value != null) { fields.put(key, value); }//from w w w. ja v a 2 s.c o m }