public void testInvertFrom() { ImmutableMultimap<Integer, String> empty = ImmutableMultimap.of(); // typical usage example - sad that ArrayListMultimap.create() won't work Multimap<String, Integer> multimap = Multimaps.invertFrom(empty, ArrayListMultimap.<String, Integer>create()); assertTrue(multimap.isEmpty()); ImmutableMultimap<Integer, String> single = new ImmutableMultimap.Builder<Integer, String>().put(1, "one").put(2, "two").build(); // copy into existing multimap assertSame(multimap, Multimaps.invertFrom(single, multimap)); ImmutableMultimap<String, Integer> expected = new ImmutableMultimap.Builder<String, Integer>().put("one", 1).put("two", 2).build(); assertEquals(expected, multimap); }
Multimaps.invertFrom(typesByAttribute, HashMultimap.<String, String>create());
SetMultimap<Long, Cell> cellsByTs = Multimaps.invertFrom( Multimaps.forMap(timestampByCell), HashMultimap.<Long, Cell>create()); Builder<Cell, Value> builder = ImmutableMap.builder();
public static <T> SetMultimap<T, T> reverseGraph(SetMultimap<T, T> graph) { return Multimaps.invertFrom(graph, HashMultimap.<T, T>create()); }
public void configure(List<String> containers, Multimap<String, URI> container2Uris) { this.containers = containers; this.container2URIs = HashMultimap.create(container2Uris); this.uri2container = Multimaps.invertFrom(HashMultimap.create(container2Uris), HashMultimap.<URI, String>create()); }
private static <T, S> Map<T, Collection<S>> invert(final Map<S, T> valueByKey) { return new TreeMap<>( Multimaps.invertFrom( Multimaps.forMap(valueByKey), ArrayListMultimap.<T, S>create() ).asMap() ); }
Multimaps.invertFrom(dependencies, invertedDependencies);
Multimap<String,String> compToFieldMap = (this.compositeToFieldMap != null) ? this.compositeToFieldMap.get(ingestDatatype) : null; if (compToFieldMap != null && !compToFieldMap.isEmpty()) { Multimap<String,String> inverted = Multimaps.invertFrom(compToFieldMap, ArrayListMultimap.create());
/** * <p>Produces a relation between {@link com.atlassian.jira.application.ApplicationRole}s and {@link com.atlassian.jira.user.ApplicationUser}s * indicating which users will gain access to which applications if they will be added to given groups.</p> * <p>This method is useful only in seating counting. There is one gotcha: if users are already (or eventually will be) added to some * application, and we want to give them CORE access it's dry-run. We won't count them as jira-core users as it will be implied.</p> * @param users users to be checked * @param groupsToBeAdded groups to be added * @return users grouped by applications in which number of occupied seats should be incremented */ public Map<ApplicationRole, Set<ApplicationUser>> rolesToBeAddedForSeatingCountPurpose(Set<ApplicationUser> users, Set<String> groupsToBeAdded) { final SetMultimap<ApplicationUser, ApplicationRole> userToRoles = HashMultimap.create(); for (ApplicationUser user : users) { userToRoles.putAll(user, calculateRolesToBeAdded(user, groupsToBeAdded)); } return ImmutableMaps.transformValue( Multimaps.invertFrom(userToRoles, HashMultimap.create()).asMap(), ImmutableSet::copyOf ); }
private Map<OWLIndividual, ? extends Collection<OWLIndividual>> getTargetIndividuals(OWLObjectPropertyExpression ope) { return ope.isAnonymous() ? Multimaps.invertFrom( MapUtils.createSortedMultiMap(opPos.get(ope.getNamedProperty())), TreeMultimap.create()).asMap() : opPos.get(ope.getNamedProperty()); }
Multimap<Node, Node> tmpBack = Multimaps.invertFrom(tmpMm, HashMultimap.<Node, Node>create());
SetMultimap<Long, Cell> cellsByTs = Multimaps.invertFrom( Multimaps.forMap(timestampByCell), HashMultimap.<Long, Cell>create()); Builder<Cell, Value> builder = ImmutableMap.builder();
Multimap<Noun,String> nounToEntity = Multimaps.invertFrom(dictionary.getNounsByEntity(), ArrayListMultimap.<Noun,String>create());
public void testInvertFrom() { ImmutableMultimap<Integer, String> empty = ImmutableMultimap.of(); // typical usage example - sad that ArrayListMultimap.create() won't work Multimap<String, Integer> multimap = Multimaps.invertFrom(empty, ArrayListMultimap.<String, Integer>create()); assertTrue(multimap.isEmpty()); ImmutableMultimap<Integer, String> single = new ImmutableMultimap.Builder<Integer, String>() .put(1, "one") .put(2, "two") .build(); // copy into existing multimap assertSame(multimap, Multimaps.invertFrom(single, multimap)); ImmutableMultimap<String, Integer> expected = new ImmutableMultimap.Builder<String, Integer>() .put("one", 1) .put("two", 2) .build(); assertEquals(expected, multimap); }
Multimaps.invertFrom( MapUtils.createSortedMultiMap(opPos.get(property.getNamedProperty())), TreeMultimap.create()).asMap() :