List of usage examples for com.google.common.collect Multimap putAll
boolean putAll(@Nullable K key, Iterable<? extends V> values);
From source file:me.lucko.luckperms.common.storage.backing.utils.NodeDataHolder.java
public static NodeDataHolder of(String permission, boolean value, String server, String world, long expiry, String contexts) {// www . j av a 2s . c o m Map<String, Collection<String>> deserializedContexts = GSON.fromJson(contexts, CONTEXT_TYPE); Multimap<String, String> map = HashMultimap.create(); for (Map.Entry<String, Collection<String>> e : deserializedContexts.entrySet()) { map.putAll(e.getKey(), e.getValue()); } return new NodeDataHolder(permission, value, server, world, expiry, map); }
From source file:org.dllearner.utilities.MapUtils.java
/** * Creates a Guava sorted multimap using the input map. * * @param input the input map/*from w w w. j a v a2 s .c o m*/ * @return the multimap */ public static <K extends Comparable, V extends Comparable> Multimap<K, V> createSortedMultiMap( Map<K, ? extends Iterable<V>> input) { Multimap<K, V> multimap = TreeMultimap.create(); for (Map.Entry<K, ? extends Iterable<V>> entry : input.entrySet()) { multimap.putAll(entry.getKey(), entry.getValue()); } return multimap; }
From source file:org.dllearner.utilities.MapUtils.java
/** * Constructs a multimap with the same mappings as the specified map. * * @param input the input map//from w w w.ja v a 2 s .co m * @return the multimap */ public static <K, V> Multimap<K, V> createMultiMap(Map<K, ? extends Iterable<V>> input) { Multimap<K, V> multimap = ArrayListMultimap.create(); for (Map.Entry<K, ? extends Iterable<V>> entry : input.entrySet()) { multimap.putAll(entry.getKey(), entry.getValue()); } return multimap; }
From source file:io.scigraph.services.jersey.MultivaluedMapUtils.java
/*** * Converts a {@link MultivaluedMap} to a {@link Multimap}. * //from w ww . j av a2 s .co m * @param map the original map * @param separator an optional separator to further split the values in the map * @return the new multimap */ public static Multimap<String, Object> multivaluedMapToMultimap(MultivaluedMap<String, String> map, Optional<Character> separator) { Multimap<String, Object> merged = ArrayListMultimap.create(); for (Entry<String, List<String>> entry : map.entrySet()) { for (String value : entry.getValue()) { if (separator.isPresent()) { merged.putAll(entry.getKey(), Splitter.on(separator.get()).split(value)); } else { merged.put(entry.getKey(), value); } } } return merged; }
From source file:de.iteratec.iteraplan.elasticeam.derived.DerivedMetamodelFactory.java
private static Multimap<Integer, List<RelationshipEndExpression>> collectPathCandidates( SubstantialTypeExpression startClass, int length) { Multimap<Integer, List<RelationshipEndExpression>> pathsAndPrefixes = HashMultimap.create(); for (RelationshipEndExpression relationshipEnd : startClass.getRelationshipEnds()) { pathsAndPrefixes.putAll(Integer.valueOf(2), expandByOneStep(Collections.singletonList(relationshipEnd))); }/*from w w w . ja va2 s. c om*/ for (int i = 3; i <= length; i++) { for (List<RelationshipEndExpression> prefix : pathsAndPrefixes.get(Integer.valueOf(i - 1))) { pathsAndPrefixes.putAll(Integer.valueOf(i), expandByOneStep(prefix)); } } return pathsAndPrefixes; }
From source file:gobblin.util.PublisherUtils.java
/** * Given a {@link Multimap} of {@link Extract}s to {@link WorkUnitState}s, filter out any {@link Extract}s where all * of the corresponding {@link WorkUnitState}s do not meet the given {@link Predicate}. *///from w ww . j a v a 2 s . co m public static Multimap<Extract, WorkUnitState> getExtractsForPredicate( Multimap<Extract, WorkUnitState> extractToWorkUnitStateMap, Predicate<WorkUnitState> predicate) { Multimap<Extract, WorkUnitState> successfulExtracts = ArrayListMultimap.create(); for (Map.Entry<Extract, Collection<WorkUnitState>> entry : extractToWorkUnitStateMap.asMap().entrySet()) { if (Iterables.all(entry.getValue(), predicate)) { successfulExtracts.putAll(entry.getKey(), entry.getValue()); } } return successfulExtracts; }
From source file:gobblin.util.PublisherUtils.java
/** * Given a {@link Multimap} of {@link Extract}s to {@link WorkUnitState}s, filter out any {@link Extract}s where all * of the corresponding {@link WorkUnitState}s do not meet the given {@link Predicate}. * <ul>/*from ww w . j av a 2s .c o m*/ * <li> The filtered {@link Extract}s will be available in {@link SplitExtractsResult#getFiltered()}</li> * <li> The {@link Extract}s satisfying the predicated will be available in {@link SplitExtractsResult#getRetained()}</li> * </ul> * */ public static SplitExtractsResult splitExtractsByPredicate( Multimap<Extract, WorkUnitState> extractToWorkUnitStateMap, Predicate<WorkUnitState> predicate) { Multimap<Extract, WorkUnitState> retained = ArrayListMultimap.create(); Multimap<Extract, WorkUnitState> filtered = ArrayListMultimap.create(); for (Map.Entry<Extract, Collection<WorkUnitState>> entry : extractToWorkUnitStateMap.asMap().entrySet()) { if (Iterables.all(entry.getValue(), predicate)) { retained.putAll(entry.getKey(), entry.getValue()); } else { filtered.putAll(entry.getKey(), entry.getValue()); } } return new SplitExtractsResult(retained, filtered); }
From source file:com.twitter.common.collections.Multimaps.java
/** * Prunes a multimap based on a predicate, returning the pruned values. The input map will be * modified./* w w w.jav a2 s .co m*/ * * @param map The multimap to prune. * @param filterRule The pruning rule. When the predicate returns {@code false} for an entry, it * will be pruned, otherwise it will be retained. * @param <K> The key type in the multimap. * @param <V> The value type in the multimap. * @return A new multimap, containing the pruned keys/values. */ public static <K, V> Multimap<K, V> prune(Multimap<K, V> map, Predicate<? super Collection<V>> filterRule) { Preconditions.checkNotNull(map); Preconditions.checkNotNull(filterRule); Multimap<K, V> pruned = ArrayListMultimap.create(); Iterator<Map.Entry<K, Collection<V>>> asMapItr = map.asMap().entrySet().iterator(); while (asMapItr.hasNext()) { Map.Entry<K, Collection<V>> asMapEntry = asMapItr.next(); if (!filterRule.apply(asMapEntry.getValue())) { pruned.putAll(asMapEntry.getKey(), asMapEntry.getValue()); asMapItr.remove(); } } return pruned; }
From source file:eu.itesla_project.cases.EntsoeCaseRepositoryConfig.java
static EntsoeCaseRepositoryConfig load(String moduleConfigName, PlatformConfig platformConfig, Collection<String> supportedFormats) { ModuleConfig config = platformConfig.getModuleConfig(moduleConfigName); Path rootDir = config.getPathProperty("rootDir"); Multimap<UcteGeographicalCode, String> forbiddenFormatsByCountry = HashMultimap.create(); for (UcteGeographicalCode geographicalCode : UcteGeographicalCode.values()) { List<String> forbiddenFormats = config.getStringListProperty("forbiddenFormats_" + geographicalCode, Collections.emptyList()); if (forbiddenFormats.size() > 0) { forbiddenFormatsByCountry.putAll(geographicalCode, forbiddenFormats); }/*from w w w . jav a 2 s .c om*/ } return new EntsoeCaseRepositoryConfig(rootDir, checkedFormats(forbiddenFormatsByCountry, supportedFormats)); }
From source file:eu.itesla_project.entsoe.cases.EntsoeCaseRepositoryConfig.java
static EntsoeCaseRepositoryConfig load(String moduleConfigName, PlatformConfig platformConfig, Collection<String> supportedFormats) { ModuleConfig config = platformConfig.getModuleConfig(moduleConfigName); Path rootDir = config.getPathProperty("rootDir"); Multimap<EntsoeGeographicalCode, String> forbiddenFormatsByCountry = HashMultimap.create(); for (EntsoeGeographicalCode geographicalCode : EntsoeGeographicalCode.values()) { List<String> forbiddenFormats = config.getStringListProperty("forbiddenFormats_" + geographicalCode, Collections.emptyList()); if (forbiddenFormats.size() > 0) { forbiddenFormatsByCountry.putAll(geographicalCode, forbiddenFormats); }//from w w w .j av a 2 s .c o m } return new EntsoeCaseRepositoryConfig(rootDir, checkedFormats(forbiddenFormatsByCountry, supportedFormats)); }