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.idea.blaze.base.lang.projectview.language.ProjectViewKeywords.java
private static ImmutableMap<String, ItemType> getItemTypes() { ImmutableMap.Builder<String, ItemType> builder = ImmutableMap.builder(); for (SectionParser parser : Sections.getParsers()) { builder.put(parser.getName(), parser.getItemType()); }//from ww w . j av a2 s .co m return builder.build(); }
From source file:com.preferanser.shared.util.GameUtils.java
public static Map<Hand, Set<Card>> copyDefensive(Multimap<Hand, Card> handCardMultimap) { ImmutableMap.Builder<Hand, Set<Card>> builder = ImmutableMap.builder(); if (handCardMultimap.containsKey(Hand.EAST)) builder.put(Hand.EAST, ImmutableSet.copyOf(handCardMultimap.get(Hand.EAST))); else/* www .jav a 2s . co m*/ builder.put(Hand.EAST, ImmutableSet.<Card>of()); if (handCardMultimap.containsKey(Hand.SOUTH)) builder.put(Hand.SOUTH, ImmutableSet.copyOf(handCardMultimap.get(Hand.SOUTH))); else builder.put(Hand.SOUTH, ImmutableSet.<Card>of()); if (handCardMultimap.containsKey(Hand.WEST)) builder.put(Hand.WEST, ImmutableSet.copyOf(handCardMultimap.get(Hand.WEST))); else builder.put(Hand.WEST, ImmutableSet.<Card>of()); return builder.build(); }
From source file:com.facebook.buck.jvm.java.DirectToJarOutputSettingsSerializer.java
public static ImmutableMap<String, Object> serialize(DirectToJarOutputSettings settings) { ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder(); builder.put(OUTPUT_PATH, settings.getDirectToJarOutputPath().toString()); ImmutableList.Builder<ImmutableMap<String, Object>> serializedPatterns = ImmutableList.builder(); for (Pattern pattern : settings.getClassesToRemoveFromJar()) { serializedPatterns.add(ImmutableMap.<String, Object>of(CLASSES_TO_REMOVE_PATTERN, pattern.pattern(), CLASSES_TO_REMOVE_PATTERN_FLAGS, pattern.flags())); }/*ww w . ja va2 s.co m*/ builder.put(CLASSES_TO_REMOVE, serializedPatterns.build()); ImmutableList.Builder<String> serializedEntries = ImmutableList.builder(); for (Path entry : settings.getEntriesToJar()) { serializedEntries.add(entry.toString()); } builder.put(ENTRIES, serializedEntries.build()); if (settings.getMainClass().isPresent()) { builder.put(MAIN_CLASS, settings.getMainClass().get()); } if (settings.getManifestFile().isPresent()) { builder.put(MANIFEST_FILE, settings.getManifestFile().get().toString()); } return builder.build(); }
From source file:org.zanata.sync.util.CronType.java
public static Map<String, CronType> toMapWithDisplayAsKey() { ImmutableMap.Builder<String, CronType> builder = ImmutableMap.builder(); for (CronType cronType : values()) { builder.put(cronType.getDisplay(), cronType); }/*from w ww . ja v a 2 s . c o m*/ 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 w w w . ja v a2 s .c om*/ * @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:com.google.gcloud.datastore.BatchOption.java
static Map<Class<? extends BatchOption>, BatchOption> asImmutableMap(BatchOption... options) { ImmutableMap.Builder<Class<? extends BatchOption>, BatchOption> builder = ImmutableMap.builder(); for (BatchOption option : options) { builder.put(option.getClass(), option); }/*from ww w . ja v a 2 s.co m*/ return builder.build(); }
From source file:com.jgaap.backend.Languages.java
private static Map<String, Language> loadLanguagesMap() { // Load the classifiers dynamically ImmutableMap.Builder<String, Language> builder = ImmutableMap.builder(); for (Language language : LANGUAGES) { builder.put(language.displayName().toLowerCase().trim(), language); }//from w w w .ja v a 2 s . c om return builder.build(); }
From source file:com.facebook.buck.jvm.java.JavacExecutionContextSerializer.java
public static ImmutableMap<String, Object> serialize(JavacExecutionContext context) { ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder(); builder.put(VERBOSITY, context.getVerbosity().toString()); builder.put(CELL_PATH_RESOLVER, CellPathResolverSerializer.serialize(context.getCellPathResolver())); builder.put(JAVA_PACKAGE_FINDER, JavaPackageFinderSerializer.serialize(context.getJavaPackageFinder())); builder.put(PROJECT_FILE_SYSTEM_ROOT, context.getProjectFilesystem().getRootPath().toString()); builder.put(CLASS_USAGE_FILE_WRITER, ClassUsageFileWriterSerializer.serialize(context.getUsedClassesFileWriter())); builder.put(ENVIRONMENT, context.getEnvironment()); builder.put(PROCESS_EXECUTOR, ProcessExecutorSerializer.serialize(context.getProcessExecutor())); builder.put(ABSOLUTE_PATHS_FOR_INPUTS, ImmutableList.copyOf(context.getAbsolutePathsForInputs().stream().map(Path::toString).iterator())); if (context.getDirectToJarOutputSettings().isPresent()) { builder.put(DIRECT_TO_JAR_SETTINGS, DirectToJarOutputSettingsSerializer.serialize(context.getDirectToJarOutputSettings().get())); }/*from w w w .j a va 2s . c o m*/ return builder.build(); }
From source file:com.facebook.presto.sql.planner.DomainUtils.java
public static <T> Map<Symbol, T> columnHandleToSymbol(Map<ColumnHandle, T> columnMap, Map<Symbol, ColumnHandle> assignments) { Map<ColumnHandle, Symbol> inverseAssignments = ImmutableBiMap.copyOf(assignments).inverse(); Preconditions.checkArgument(inverseAssignments.keySet().containsAll(columnMap.keySet()), "assignments does not contain all required column handles"); ImmutableMap.Builder<Symbol, T> builder = ImmutableMap.builder(); for (Map.Entry<ColumnHandle, T> entry : columnMap.entrySet()) { builder.put(inverseAssignments.get(entry.getKey()), entry.getValue()); }/*from ww w.jav a 2 s .c om*/ return builder.build(); }
From source file:com.facebook.buck.testutil.FakeFileHashCache.java
public static FakeFileHashCache createFromStrings(Map<String, String> pathsToHashes) { ImmutableMap.Builder<Path, HashCode> builder = ImmutableMap.builder(); for (Map.Entry<String, String> entry : pathsToHashes.entrySet()) { builder.put(Paths.get(entry.getKey()), HashCode.fromString(entry.getValue())); }/*from w w w . j a v a2 s.co m*/ return new FakeFileHashCache(builder.build()); }