List of usage examples for com.google.common.collect Multimaps newListMultimap
public static <K, V> ListMultimap<K, V> newListMultimap(Map<K, Collection<V>> map, final Supplier<? extends List<V>> factory)
From source file:org.eclipse.osee.orcs.db.internal.search.util.LoadDataBuffer.java
private static <K, V> ListMultimap<K, V> newLinkedHashListMultimap(int fetchSize) { Map<K, Collection<V>> map = new LinkedHashMap<K, Collection<V>>(fetchSize); return Multimaps.newListMultimap(map, new Supplier<List<V>>() { @Override//ww w . j av a2 s. c om public List<V> get() { return Lists.newArrayList(); } }); }
From source file:hudson.plugins.openid.Identity.java
public Identity(AuthSuccess authSuccess) throws OpenIDException { openId = authSuccess.getIdentity();/*from w w w .ja v a 2 s.c om*/ teams = Lists.newArrayList(); properties = Multimaps.newListMultimap(new TreeMap<String, Collection<String>>(), new Supplier<List<String>>() { public List<String> get() { return new ArrayList<String>(); } }); OpenIdExtension.processResponse(authSuccess, this); }
From source file:de.kitsunealex.projectx.api.recipe.EngineeringRecipe.java
private void processIngredients(Object... params) { List<String> rows = Lists.newArrayList(); Multimap<Character, ItemStack> ingredientMap = Multimaps.newListMultimap(Maps.newHashMap(), Lists::newArrayList);/*from w w w . ja va 2s. c o m*/ boolean isPatternDefined = false; for (int i = 0; i < params.length; i++) { Object param = params[i]; if (param instanceof String) { if (!isPatternDefined) { rows.add((String) param); } } else if (param instanceof Character) { if (!isPatternDefined) { isPatternDefined = true; } Object nextParam = params[i + 1]; if (nextParam instanceof Item) { ingredientMap.put((Character) param, new ItemStack((Item) nextParam, 1, OreDictionary.WILDCARD_VALUE)); } else if (nextParam instanceof Block) { ingredientMap.put((Character) param, new ItemStack((Block) nextParam, 1, OreDictionary.WILDCARD_VALUE)); } else if (nextParam instanceof ItemStack) { ingredientMap.put((Character) param, (ItemStack) nextParam); } else if (nextParam instanceof String) { NonNullList<ItemStack> items = OreDictionary.getOres((String) nextParam); items.forEach(item -> ingredientMap.put((Character) param, item)); } else { String message = String.format("Unknown ingredient type '%s'!", nextParam.getClass().getName()); throw new RuntimeException(message); } } } for (String row : rows) { for (int i = 0; i < row.length(); i++) { if (row.charAt(i) != ' ') { Collection<ItemStack> stacks = ingredientMap.get(row.charAt(i)); if (stacks != null && !stacks.isEmpty()) { ingredients.add(Ingredient.fromStacks(stacks.toArray(new ItemStack[stacks.size()]))); } else { hasMissingIngredients = true; } } else { ingredients.add(Ingredient.EMPTY); } } } }
From source file:org.apache.isis.viewer.wicket.viewer.registries.components.ComponentFactoryRegistryDefault.java
@javax.inject.Inject public ComponentFactoryRegistryDefault(final ComponentFactoryRegistrar componentFactoryList) { componentFactoriesByType = Multimaps.newListMultimap( new HashMap<ComponentType, Collection<ComponentFactory>>(), new Supplier<List<ComponentFactory>>() { @Override//ww w . j av a2 s . c o m public List<ComponentFactory> get() { return Lists.newArrayList(); } }); registerComponentFactories(componentFactoryList); }
From source file:com.github.autermann.yaml.nodes.YamlPairsNode.java
/** * Creates a new {@link YamlPairsNode}./*from w ww . j ava 2 s . c om*/ * * @param factory the factory to create children with */ public YamlPairsNode(YamlNodeFactory factory) { super(factory); LinkedHashMap<YamlNode, Collection<YamlNode>> map = Maps.newLinkedHashMap(); Supplier<List<YamlNode>> supplier = LinkedListSupplier.instance(); this.multiMap = Multimaps.newListMultimap(map, supplier); this.value = Lists.newLinkedList(); }
From source file:com.opengamma.bbg.referencedata.statistics.Snapshot.java
private ListMultimap<Long, String> index(Map<String, Long> forward) { ListMultimap<Long, String> index = Multimaps .newListMultimap(new TreeMap<Long, Collection<String>>(DESCENDING_COMPARATOR), ARRAY_LIST_SUPPLIER); for (Entry<String, Long> e : forward.entrySet()) { index.put(e.getValue(), e.getKey()); }/*from ww w. ja v a2s. c om*/ return index; }
From source file:org.eclipse.osee.orcs.db.internal.sql.join.JoinCleanerCallable.java
private static <K, V> ListMultimap<K, V> newListMultimap() { Map<K, Collection<V>> map = Maps.newLinkedHashMap(); return Multimaps.newListMultimap(map, new Supplier<List<V>>() { @Override//from w ww. j av a 2s .co m public List<V> get() { return Lists.newArrayList(); } }); }
From source file:org.eclipse.incquery.viewers.runtime.model.ViewerStateSet.java
private Multimap<Object, Item> initializeItemMap() { Map<Object, Collection<Item>> map = Maps.newHashMap(); /*/* w w w .ja v a2 s . c o m*/ return Multimaps.newSetMultimap(map, new Supplier<Set<Item>>() { @SuppressWarnings("unchecked") @Override public Set<Item> get() { HashSet<Item> Set = Sets.newHashSet(); return new WritableSet(Set, Item.class); } }); */ return Multimaps.newListMultimap(map, new Supplier<List<Item>>() { @SuppressWarnings("unchecked") @Override public List<Item> get() { ArrayList<Item> list = Lists.newArrayList(); return new WritableList(list, Item.class); } }); }
From source file:io.janusproject.kernel.services.jdk.distributeddata.StandardDistributedDataStructureService.java
@Override public <K, V> DMultiMap<K, V> getMultiMap(String name) { Map<K, Collection<V>> map = Maps.newHashMap(); Multimap<K, V> multimap = Multimaps.newListMultimap(map, new ArrayListSupplier<V>()); return new DMultiMapView<>(name, multimap); }
From source file:io.github.carrknight.schedule.ScheduleServer.java
public ScheduleServer() { //create the channel holding the commands channel = new LinkedBlockingQueue<>(); //create the thread unsafe lists actions = Multimaps.newListMultimap(new EnumMap<>(DAY_PHASES.class), LinkedList::new); //create map of effects pendingEffects = Multimaps.newListMultimap(new HashMap<>(), LinkedList::new); //now create and start the dispatch thread //create a simple thread dispatch = new Thread(() -> { //very simple runnable: keep grabbing commands from the channel and execute them try {/*from w w w .j a va 2s . c o m*/ while (active) { channel.take().run(); } } catch (InterruptedException e) { /*end of the game*/} }); dispatch.setDaemon(true); //doesn't stop the program from quitting dispatch.start(); //create the workhorse threadPool = new ForkJoinPool(); }