List of usage examples for com.google.common.collect ImmutableListMultimap copyOf
@Beta public static <K, V> ImmutableListMultimap<K, V> copyOf( Iterable<? extends Entry<? extends K, ? extends V>> entries)
From source file:com.opengamma.strata.engine.marketdata.ScenarioCalculationEnvironment.java
/** * Creates an instance./*from ww w . j a va2 s.c om*/ * @param sharedData the value of the property, not null * @param scenarioCount the value of the property * @param valuationDates the value of the property, not null * @param values the value of the property, not null * @param globalValues the value of the property, not null * @param singleValueFailures the value of the property, not null */ ScenarioCalculationEnvironment(CalculationEnvironment sharedData, int scenarioCount, List<LocalDate> valuationDates, ListMultimap<? extends MarketDataId<?>, ?> values, Map<? extends MarketDataId<?>, Object> globalValues, Map<? extends MarketDataId<?>, Failure> singleValueFailures) { JodaBeanUtils.notNull(sharedData, "sharedData"); ArgChecker.notNegativeOrZero(scenarioCount, "scenarioCount"); JodaBeanUtils.notNull(valuationDates, "valuationDates"); JodaBeanUtils.notNull(values, "values"); JodaBeanUtils.notNull(globalValues, "globalValues"); JodaBeanUtils.notNull(singleValueFailures, "singleValueFailures"); this.sharedData = sharedData; this.scenarioCount = scenarioCount; this.valuationDates = ImmutableList.copyOf(valuationDates); this.values = ImmutableListMultimap.copyOf(values); this.globalValues = ImmutableMap.copyOf(globalValues); this.singleValueFailures = ImmutableMap.copyOf(singleValueFailures); validate(); }
From source file:org.joda.beans.gen.ImmGuava.java
/** * Creates an instance.//from www. j a v a 2 s . c om * @param collection the value of the property, not null * @param list the value of the property, not null * @param set the value of the property, not null * @param sortedSet the value of the property, not null * @param map the value of the property, not null * @param sortedMap the value of the property, not null * @param biMap the value of the property, not null * @param multimap the value of the property, not null * @param listMultimap the value of the property, not null * @param setMultimap the value of the property, not null * @param multiset the value of the property, not null * @param sortedMultiset the value of the property, not null * @param collectionInterface the value of the property, not null * @param listInterface the value of the property, not null * @param setInterface the value of the property, not null * @param sortedSetInterface the value of the property, not null * @param mapInterface the value of the property, not null * @param sortedMapInterface the value of the property, not null * @param biMapInterface the value of the property, not null * @param multimapInterface the value of the property, not null * @param listMultimapInterface the value of the property, not null * @param setMultimapInterface the value of the property, not null * @param multisetInterface the value of the property, not null * @param sortedMultisetInterface the value of the property, not null * @param listWildExtendsT the value of the property, not null * @param listWildExtendsNumber the value of the property, not null * @param listWildExtendsComparable the value of the property, not null * @param setWildExtendsT the value of the property, not null * @param setWildExtendsNumber the value of the property, not null * @param setWildExtendsComparable the value of the property, not null * @param listWildBuilder1 the value of the property, not null * @param listWildBuilder2 the value of the property, not null * @param mapWildBuilder1 the value of the property, not null */ public ImmGuava(Collection<T> collection, List<T> list, Set<T> set, SortedSet<T> sortedSet, Map<T, String> map, SortedMap<T, String> sortedMap, BiMap<T, String> biMap, Multimap<T, String> multimap, ListMultimap<T, String> listMultimap, SetMultimap<T, String> setMultimap, Multiset<T> multiset, SortedMultiset<T> sortedMultiset, Collection<T> collectionInterface, List<T> listInterface, Set<T> setInterface, SortedSet<T> sortedSetInterface, Map<T, String> mapInterface, SortedMap<T, String> sortedMapInterface, BiMap<T, String> biMapInterface, Multimap<T, String> multimapInterface, ListMultimap<T, String> listMultimapInterface, SetMultimap<T, String> setMultimapInterface, Multiset<T> multisetInterface, SortedMultiset<T> sortedMultisetInterface, List<? extends T> listWildExtendsT, List<? extends Number> listWildExtendsNumber, List<? extends Comparable<?>> listWildExtendsComparable, Set<? extends T> setWildExtendsT, Set<? extends Number> setWildExtendsNumber, Set<? extends Comparable<?>> setWildExtendsComparable, List<?> listWildBuilder1, List<? extends Address> listWildBuilder2, Map<String, ? extends Address> mapWildBuilder1) { JodaBeanUtils.notNull(collection, "collection"); JodaBeanUtils.notNull(list, "list"); JodaBeanUtils.notNull(set, "set"); JodaBeanUtils.notNull(sortedSet, "sortedSet"); JodaBeanUtils.notNull(map, "map"); JodaBeanUtils.notNull(sortedMap, "sortedMap"); JodaBeanUtils.notNull(biMap, "biMap"); JodaBeanUtils.notNull(multimap, "multimap"); JodaBeanUtils.notNull(listMultimap, "listMultimap"); JodaBeanUtils.notNull(setMultimap, "setMultimap"); JodaBeanUtils.notNull(multiset, "multiset"); JodaBeanUtils.notNull(sortedMultiset, "sortedMultiset"); JodaBeanUtils.notNull(collectionInterface, "collectionInterface"); JodaBeanUtils.notNull(listInterface, "listInterface"); JodaBeanUtils.notNull(setInterface, "setInterface"); JodaBeanUtils.notNull(sortedSetInterface, "sortedSetInterface"); JodaBeanUtils.notNull(mapInterface, "mapInterface"); JodaBeanUtils.notNull(sortedMapInterface, "sortedMapInterface"); JodaBeanUtils.notNull(biMapInterface, "biMapInterface"); JodaBeanUtils.notNull(multimapInterface, "multimapInterface"); JodaBeanUtils.notNull(listMultimapInterface, "listMultimapInterface"); JodaBeanUtils.notNull(setMultimapInterface, "setMultimapInterface"); JodaBeanUtils.notNull(multisetInterface, "multisetInterface"); JodaBeanUtils.notNull(sortedMultisetInterface, "sortedMultisetInterface"); JodaBeanUtils.notNull(listWildExtendsT, "listWildExtendsT"); JodaBeanUtils.notNull(listWildExtendsNumber, "listWildExtendsNumber"); JodaBeanUtils.notNull(listWildExtendsComparable, "listWildExtendsComparable"); JodaBeanUtils.notNull(setWildExtendsT, "setWildExtendsT"); JodaBeanUtils.notNull(setWildExtendsNumber, "setWildExtendsNumber"); JodaBeanUtils.notNull(setWildExtendsComparable, "setWildExtendsComparable"); JodaBeanUtils.notNull(listWildBuilder1, "listWildBuilder1"); JodaBeanUtils.notNull(listWildBuilder2, "listWildBuilder2"); JodaBeanUtils.notNull(mapWildBuilder1, "mapWildBuilder1"); this.collection = ImmutableList.copyOf(collection); this.list = ImmutableList.copyOf(list); this.set = ImmutableSet.copyOf(set); this.sortedSet = ImmutableSortedSet.copyOfSorted(sortedSet); this.map = ImmutableMap.copyOf(map); this.sortedMap = ImmutableSortedMap.copyOfSorted(sortedMap); this.biMap = ImmutableBiMap.copyOf(biMap); this.multimap = ImmutableMultimap.copyOf(multimap); this.listMultimap = ImmutableListMultimap.copyOf(listMultimap); this.setMultimap = ImmutableSetMultimap.copyOf(setMultimap); this.multiset = ImmutableMultiset.copyOf(multiset); this.sortedMultiset = ImmutableSortedMultiset.copyOfSorted(sortedMultiset); this.collectionInterface = ImmutableList.copyOf(collectionInterface); this.listInterface = ImmutableList.copyOf(listInterface); this.setInterface = ImmutableSet.copyOf(setInterface); this.sortedSetInterface = ImmutableSortedSet.copyOfSorted(sortedSetInterface); this.mapInterface = ImmutableMap.copyOf(mapInterface); this.sortedMapInterface = ImmutableSortedMap.copyOfSorted(sortedMapInterface); this.biMapInterface = ImmutableBiMap.copyOf(biMapInterface); this.multimapInterface = ImmutableMultimap.copyOf(multimapInterface); this.listMultimapInterface = ImmutableListMultimap.copyOf(listMultimapInterface); this.setMultimapInterface = ImmutableSetMultimap.copyOf(setMultimapInterface); this.multisetInterface = ImmutableMultiset.copyOf(multisetInterface); this.sortedMultisetInterface = ImmutableSortedMultiset.copyOfSorted(sortedMultisetInterface); this.listWildExtendsT = ImmutableList.copyOf(listWildExtendsT); this.listWildExtendsNumber = ImmutableList.copyOf(listWildExtendsNumber); this.listWildExtendsComparable = ImmutableList.copyOf(listWildExtendsComparable); this.setWildExtendsT = ImmutableSet.copyOf(setWildExtendsT); this.setWildExtendsNumber = ImmutableSet.copyOf(setWildExtendsNumber); this.setWildExtendsComparable = ImmutableSet.copyOf(setWildExtendsComparable); this.listWildBuilder1 = ImmutableList.copyOf(listWildBuilder1); this.listWildBuilder2 = ImmutableList.copyOf(listWildBuilder2); this.mapWildBuilder1 = ImmutableMap.copyOf(mapWildBuilder1); }
From source file:com.facebook.buck.cxx.CxxLibraryFactory.java
private static ImmutableMap<CxxPreprocessAndCompile, SourcePath> requireCxxObjects(BuildTarget buildTarget, ProjectFilesystem projectFilesystem, ActionGraphBuilder graphBuilder, SourcePathResolver sourcePathResolver, SourcePathRuleFinder ruleFinder, CellPathResolver cellRoots, CxxBuckConfig cxxBuckConfig, CxxPlatform cxxPlatform, PicType pic, CxxLibraryDescriptionArg args, ImmutableSet<BuildRule> deps, CxxLibraryDescription.TransitiveCxxPreprocessorInputFunction transitivePreprocessorInputs, Optional<CxxLibraryDescriptionDelegate> delegate) { boolean shouldCreatePrivateHeadersSymlinks = args.getXcodePrivateHeadersSymlinks() .orElse(cxxPlatform.getPrivateHeadersSymlinksEnabled()); HeaderSymlinkTree headerSymlinkTree = CxxDescriptionEnhancer.requireHeaderSymlinkTree(buildTarget, projectFilesystem, ruleFinder, graphBuilder, cxxPlatform, CxxDescriptionEnhancer.parseHeaders(buildTarget, graphBuilder, ruleFinder, sourcePathResolver, Optional.of(cxxPlatform), args), HeaderVisibility.PRIVATE, shouldCreatePrivateHeadersSymlinks); ImmutableList.Builder<HeaderSymlinkTree> privateHeaderSymlinkTrees = ImmutableList.builder(); privateHeaderSymlinkTrees.add(headerSymlinkTree); delegate.ifPresent(d -> d.getPrivateHeaderSymlinkTree(buildTarget, graphBuilder, cxxPlatform) .ifPresent(h -> privateHeaderSymlinkTrees.add(h))); // Create rule to build the object files. ImmutableMultimap<CxxSource.Type, Arg> compilerFlags = ImmutableListMultimap .copyOf(Multimaps.transformValues( CxxFlags.getLanguageFlagsWithMacros(args.getCompilerFlags(), args.getPlatformCompilerFlags(), args.getLangCompilerFlags(), args.getLangPlatformCompilerFlags(), cxxPlatform), f -> CxxDescriptionEnhancer.toStringWithMacrosArgs(buildTarget, cellRoots, graphBuilder, cxxPlatform, f))); return CxxSourceRuleFactory .of(projectFilesystem, buildTarget, graphBuilder, sourcePathResolver, ruleFinder, cxxBuckConfig, cxxPlatform,/*from ww w .ja va 2s . c om*/ CxxLibraryDescription.getPreprocessorInputsForBuildingLibrarySources(cxxBuckConfig, graphBuilder, cellRoots, buildTarget, args, cxxPlatform, deps, transitivePreprocessorInputs, privateHeaderSymlinkTrees.build()), compilerFlags, args.getPrefixHeader(), args.getPrecompiledHeader(), pic) .requirePreprocessAndCompileRules(CxxDescriptionEnhancer.parseCxxSources(buildTarget, graphBuilder, ruleFinder, sourcePathResolver, cxxPlatform, args)); }
From source file:com.google.devtools.build.lib.packages.Rule.java
/** * Collects the output files (both implicit and explicit). All the implicit output files are added * first, followed by any explicit files. Additionally both implicit and explicit output files * will retain the relative order in which they were declared. *//*from www.jav a2 s .c o m*/ void populateOutputFiles(EventHandler eventHandler, Package.Builder pkgBuilder) throws LabelSyntaxException, InterruptedException { Preconditions.checkState(outputFiles == null); // Order is important here: implicit before explicit outputFiles = Lists.newArrayList(); outputFileMap = LinkedListMultimap.create(); populateImplicitOutputFiles(eventHandler, pkgBuilder); populateExplicitOutputFiles(eventHandler); outputFiles = ImmutableList.copyOf(outputFiles); outputFileMap = ImmutableListMultimap.copyOf(outputFileMap); }
From source file:org.terasology.assets.module.ModuleAwareAssetTypeManager.java
/** * Updates the map of subtypes based on the current asset types */// www .ja v a 2s.c om private void updateSubtypesMap() { ListMultimap<Class<? extends Asset>, Class<? extends Asset>> subtypesBuilder = ArrayListMultimap.create(); for (Class<? extends Asset> type : assetTypes.keySet()) { for (Class<?> parentType : ReflectionUtils.getAllSuperTypes(type, new Predicate<Class<?>>() { @Override public boolean apply(Class<?> input) { return Asset.class.isAssignableFrom(input) && input != Asset.class; } })) { subtypesBuilder.put((Class<? extends Asset>) parentType, type); Collections.sort(subtypesBuilder.get((Class<? extends Asset>) parentType), new Comparator<Class<?>>() { @Override public int compare(Class<?> o1, Class<?> o2) { return o1.getSimpleName().compareTo(o2.getSimpleName()); } }); } } subtypes = ImmutableListMultimap.copyOf(subtypesBuilder); }
From source file:net.minecraftforge.common.ForgeChunkManager.java
static void loadWorld(World world) { ArrayListMultimap<String, Ticket> newTickets = ArrayListMultimap.<String, Ticket>create(); tickets.put(world, newTickets);/* w ww .j ava 2 s .c o m*/ forcedChunks.put(world, ImmutableSetMultimap.<ChunkCoordIntPair, Ticket>of()); if (!(world instanceof WorldServer)) { return; } dormantChunkCache.put(world, CacheBuilder.newBuilder().maximumSize(dormantChunkCacheSize).<Long, Chunk>build()); WorldServer worldServer = (WorldServer) world; File chunkDir = worldServer.getChunkSaveLocation(); File chunkLoaderData = new File(chunkDir, "forcedchunks.dat"); if (chunkLoaderData.exists() && chunkLoaderData.isFile()) { ArrayListMultimap<String, Ticket> loadedTickets = ArrayListMultimap.<String, Ticket>create(); Map<String, ListMultimap<String, Ticket>> playerLoadedTickets = Maps.newHashMap(); NBTTagCompound forcedChunkData; try { forcedChunkData = CompressedStreamTools.read(chunkLoaderData); } catch (IOException e) { FMLLog.log(Level.WARN, e, "Unable to read forced chunk data at %s - it will be ignored", chunkLoaderData.getAbsolutePath()); return; } NBTTagList ticketList = forcedChunkData.getTagList("TicketList", Constants.NBT.TAG_COMPOUND); for (int i = 0; i < ticketList.tagCount(); i++) { NBTTagCompound ticketHolder = (NBTTagCompound) ticketList.getCompoundTagAt(i); String modId = ticketHolder.getString("Owner"); boolean isPlayer = "Forge".equals(modId); if (!isPlayer && !Loader.isModLoaded(modId)) { FMLLog.warning( "Found chunkloading data for mod %s which is currently not available or active - it will be removed from the world save", modId); continue; } if (!isPlayer && !callbacks.containsKey(modId)) { FMLLog.warning( "The mod %s has registered persistent chunkloading data but doesn't seem to want to be called back with it - it will be removed from the world save", modId); continue; } NBTTagList tickets = ticketHolder.getTagList("Tickets", Constants.NBT.TAG_COMPOUND); for (int j = 0; j < tickets.tagCount(); j++) { NBTTagCompound ticket = (NBTTagCompound) tickets.getCompoundTagAt(j); modId = ticket.hasKey("ModId") ? ticket.getString("ModId") : modId; Type type = Type.values()[ticket.getByte("Type")]; //byte ticketChunkDepth = ticket.getByte("ChunkListDepth"); Ticket tick = new Ticket(modId, type, world); if (ticket.hasKey("ModData")) { tick.modData = ticket.getCompoundTag("ModData"); } if (ticket.hasKey("Player")) { tick.player = ticket.getString("Player"); if (!playerLoadedTickets.containsKey(tick.modId)) { playerLoadedTickets.put(modId, ArrayListMultimap.<String, Ticket>create()); } playerLoadedTickets.get(tick.modId).put(tick.player, tick); } else { loadedTickets.put(modId, tick); } if (type == Type.ENTITY) { tick.entityChunkX = ticket.getInteger("chunkX"); tick.entityChunkZ = ticket.getInteger("chunkZ"); UUID uuid = new UUID(ticket.getLong("PersistentIDMSB"), ticket.getLong("PersistentIDLSB")); // add the ticket to the "pending entity" list pendingEntities.put(uuid, tick); } } } for (Ticket tick : ImmutableSet.copyOf(pendingEntities.values())) { if (tick.ticketType == Type.ENTITY && tick.entity == null) { // force the world to load the entity's chunk // the load will come back through the loadEntity method and attach the entity // to the ticket world.getChunkFromChunkCoords(tick.entityChunkX, tick.entityChunkZ); } } for (Ticket tick : ImmutableSet.copyOf(pendingEntities.values())) { if (tick.ticketType == Type.ENTITY && tick.entity == null) { FMLLog.warning("Failed to load persistent chunkloading entity %s from store.", pendingEntities.inverse().get(tick)); loadedTickets.remove(tick.modId, tick); } } pendingEntities.clear(); // send callbacks for (String modId : loadedTickets.keySet()) { LoadingCallback loadingCallback = callbacks.get(modId); if (loadingCallback == null) { continue; } int maxTicketLength = getMaxTicketLengthFor(modId); List<Ticket> tickets = loadedTickets.get(modId); if (loadingCallback instanceof OrderedLoadingCallback) { OrderedLoadingCallback orderedLoadingCallback = (OrderedLoadingCallback) loadingCallback; tickets = orderedLoadingCallback.ticketsLoaded(ImmutableList.copyOf(tickets), world, maxTicketLength); } if (tickets.size() > maxTicketLength) { FMLLog.warning("The mod %s has too many open chunkloading tickets %d. Excess will be dropped", modId, tickets.size()); tickets.subList(maxTicketLength, tickets.size()).clear(); } ForgeChunkManager.tickets.get(world).putAll(modId, tickets); loadingCallback.ticketsLoaded(ImmutableList.copyOf(tickets), world); } for (String modId : playerLoadedTickets.keySet()) { LoadingCallback loadingCallback = callbacks.get(modId); if (loadingCallback == null) { continue; } ListMultimap<String, Ticket> tickets = playerLoadedTickets.get(modId); if (loadingCallback instanceof PlayerOrderedLoadingCallback) { PlayerOrderedLoadingCallback orderedLoadingCallback = (PlayerOrderedLoadingCallback) loadingCallback; tickets = orderedLoadingCallback.playerTicketsLoaded(ImmutableListMultimap.copyOf(tickets), world); playerTickets.putAll(tickets); } ForgeChunkManager.tickets.get(world).putAll("Forge", tickets.values()); loadingCallback.ticketsLoaded(ImmutableList.copyOf(tickets.values()), world); } } }
From source file:com.google.gerrit.server.notedb.ChangeNotes.java
public ImmutableListMultimap<RevId, Comment> getDraftComments(Account.Id author, @Nullable Ref ref) throws OrmException { loadDraftComments(author, ref);/*from w ww .j a v a 2 s . co m*/ // Filter out any zombie draft comments. These are drafts that are also in // the published map, and arise when the update to All-Users to delete them // during the publish operation failed. return ImmutableListMultimap.copyOf(Multimaps.filterEntries(draftCommentNotes.getComments(), e -> !getCommentKeys().contains(e.getValue().key))); }
From source file:com.analog.lyric.dimple.solvers.core.CustomFactors.java
/** * Freezes state of object, preventing further changes. * <p>//from w w w . j a v a2s . c o m * Intended for use in defining built-in instances for {@link CustomFactorsOptionKey} default values. * <p> * @since 0.08 */ protected void freeze() { _map = ImmutableListMultimap.copyOf(_map); }