/** * Gets the handlers added. * * @return the map from {@link JibEvent} type to a list of {@link Handler}s */ ImmutableMultimap<Class<? extends JibEvent>, Handler<? extends JibEvent>> getHandlers() { return ImmutableMultimap.copyOf(handlers); } }
@Override public Multimap<String, CommandMapping> getAll() { return ImmutableMultimap.copyOf(this.commands); } }
/** * Unregisters all subscribed methods from provided subscriber object. * * @param object object to unsubscribe from */ public synchronized void unregister(@Nonnull final Object object) { if (subscribers == null) { return; } final Multimap<Class, Subscriber> map = HashMultimap.create(); map.putAll(subscribers); for (Class<?> clazz = object.getClass(); clazz != null; clazz = clazz.getSuperclass()) { for (final Method method : clazz.getDeclaredMethods()) { final Subscribe sub = method.getAnnotation(Subscribe.class); if (sub == null) { continue; } final Class<?> parameterClazz = method.getParameterTypes()[0]; map.remove(parameterClazz, new Subscriber(object, method, null)); } } subscribers = ImmutableMultimap.copyOf(map); }
@Override protected Map<String, Collection<Integer>> makePopulatedMap() { Multimap<String, Integer> delegate = HashMultimap.create(); populate(delegate); return ImmutableMultimap.copyOf(delegate).asMap(); } }
public void testCopyOf() { ImmutableSetMultimap<String, String> setMultimap = ImmutableSetMultimap.of("k1", "v1"); ImmutableMultimap<String, String> setMultimapCopy = ImmutableMultimap.copyOf(setMultimap); assertSame( "copyOf(ImmutableSetMultimap) should not create a new instance", setMultimap, setMultimapCopy); ImmutableListMultimap<String, String> listMultimap = ImmutableListMultimap.of("k1", "v1"); ImmutableMultimap<String, String> listMultimapCopy = ImmutableMultimap.copyOf(listMultimap); assertSame( "copyOf(ImmutableListMultimap) should not create a new instance", listMultimap, listMultimapCopy); }
return ImmutableMultimap.copyOf(cardinalityToConstraints);
public static SplitPlacementResult selectDistributionNodes( NodeMap nodeMap, NodeTaskMap nodeTaskMap, int maxSplitsPerNode, int maxPendingSplitsPerTask, Set<Split> splits, List<RemoteTask> existingTasks, BucketNodeMap bucketNodeMap) { Multimap<Node, Split> assignments = HashMultimap.create(); NodeAssignmentStats assignmentStats = new NodeAssignmentStats(nodeTaskMap, nodeMap, existingTasks); Set<Node> blockedNodes = new HashSet<>(); for (Split split : splits) { // node placement is forced by the bucket to node map Node node = bucketNodeMap.getAssignedNode(split).get(); // if node is full, don't schedule now, which will push back on the scheduling of splits if (assignmentStats.getTotalSplitCount(node) < maxSplitsPerNode || assignmentStats.getQueuedSplitCountForStage(node) < maxPendingSplitsPerTask) { assignments.put(node, split); assignmentStats.addAssignedSplit(node); } else { blockedNodes.add(node); } } ListenableFuture<?> blocked = toWhenHasSplitQueueSpaceFuture(blockedNodes, existingTasks, calculateLowWatermark(maxPendingSplitsPerTask)); return new SplitPlacementResult(blocked, ImmutableMultimap.copyOf(assignments)); }
private CleanupFollower(Multimap<TableReference, OnCleanupTask> cleanupTasksByTable) { this.cleanupTasksByTable = ImmutableMultimap.copyOf(cleanupTasksByTable); }
synchronized void updateCache() { Multimap<String, Location> newClassNameLocations = HashMultimap.create(); for (ClassLoader loader : getKnownClassLoaders()) { updateCache(loader, newClassNameLocations); } updateCacheWithClasspathClasses(newClassNameLocations); updateCacheWithBootstrapClasses(newClassNameLocations); if (!newClassNameLocations.isEmpty()) { // multimap that sorts keys and de-dups values while maintains value ordering SetMultimap<String, Location> newMap = MultimapBuilder.treeKeys().linkedHashSetValues().build(); newMap.putAll(classNameLocations); newMap.putAll(newClassNameLocations); classNameLocations = ImmutableMultimap.copyOf(newMap); } }
/** * Returns a newly-created immutable multimap. */ public ImmutableMultimap<K, V> build() { return copyOf(builderMultimap); } }
/** * @see Auth#getServiceCatalog() */ public Builder serviceCatalog(Multimap<String, Endpoint> serviceCatalog) { this.serviceCatalog = ImmutableMultimap.copyOf(checkNotNull(serviceCatalog, "serviceCatalog")); return this; }
/** * @see BaseEnvelope#getAdditionalSections */ @SuppressWarnings("unchecked") public Builder<V, E> additionalSections(Multimap<String, Section> additionalSections) { this.additionalSections = ImmutableMultimap.<String, Section> copyOf(checkNotNull(additionalSections, "additionalSections")); return this; }
/** * @see BaseVirtualSystem#getAdditionalSections */ @SuppressWarnings("unchecked") public Builder<T> additionalSections(Multimap<String, Section> additionalSections) { this.additionalSections = ImmutableMultimap.<String, Section> copyOf(checkNotNull(additionalSections, "additionalSections")); return this; }
protected <K,V> Multimap<K,V> fromPersistedMultimap(Multimap<K,V> m) { if (m==null) return ImmutableMultimap.of(); return ImmutableMultimap.copyOf(m); } protected <K,V> Multimap<K,V> toPersistedMultimap(Multimap<K,V> m) {
@Inject public PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet( LoadingCache<String, Set<? extends Extension>> extensions, Multimap<URI, URI> aliases) { this.extensions = checkNotNull(extensions, "extensions"); this.aliases = aliases == null ? ImmutableMultimap.<URI, URI> of() : ImmutableMultimap.copyOf(aliases); }
protected IpPermission(IpProtocol ipProtocol, int fromPort, int toPort, Multimap<String, String> tenantIdGroupNamePairs, Iterable<String> groupIds, Iterable<String> cidrBlocks) { this.fromPort = fromPort; this.toPort = toPort; this.tenantIdGroupNamePairs = ImmutableMultimap.copyOf(checkNotNull(tenantIdGroupNamePairs, "tenantIdGroupNamePairs")); this.ipProtocol = checkNotNull(ipProtocol, "ipProtocol"); this.groupIds = ImmutableSet.copyOf(checkNotNull(groupIds, "groupIds")); this.cidrBlocks = ImmutableSet.copyOf(checkNotNull(cidrBlocks, "cidrBlocks")); }
@SuppressWarnings("unchecked") public BaseVirtualSystem(String id, String info, String name, OperatingSystemSection operatingSystem, Iterable<? extends VirtualHardwareSection> virtualHardwareSections, Iterable<? extends ProductSection> productSections, Multimap<String, Section> additionalSections) { super(info); this.id = id; this.name = name; this.operatingSystem = checkNotNull(operatingSystem, "operatingSystem"); this.virtualHardwareSections = ImmutableSet.copyOf(checkNotNull(virtualHardwareSections, "virtualHardwareSections")); this.productSections = ImmutableSet.copyOf(checkNotNull(productSections, "productSections")); this.additionalSections = ImmutableMultimap.copyOf(checkNotNull(additionalSections, "additionalSections")); }
public IpPermission(IpProtocol ipProtocol, int fromPort, int toPort, Multimap<String, String> userIdGroupPairs, Iterable<String> groupIds, Iterable<String> ipRanges) { this.fromPort = fromPort; this.toPort = toPort; this.userIdGroupPairs = ImmutableMultimap.copyOf(checkNotNull(userIdGroupPairs, "userIdGroupPairs")); this.ipProtocol = checkNotNull(ipProtocol, "ipProtocol"); this.groupIds = ImmutableSet.copyOf(checkNotNull(groupIds, "groupIds")); this.ipRanges = ImmutableSet.copyOf(checkNotNull(ipRanges, "ipRanges")); }
@SuppressWarnings("unchecked") public BaseEnvelope(Iterable<? extends DiskSection> diskSections, Iterable<? extends NetworkSection> networkSections, Multimap<String, Section> additionalSections, V virtualSystem) { this.diskSections = ImmutableSet.copyOf(checkNotNull(diskSections, "diskSections")); this.networkSections = ImmutableSet.copyOf(checkNotNull(networkSections, "networkSections")); this.additionalSections = ImmutableMultimap.copyOf(checkNotNull(additionalSections, "additionalSections")); this.virtualSystem = checkNotNull(virtualSystem, "virtualSystem"); }
@SuppressWarnings("unchecked") public BaseVirtualSystem(String id, String info, String name, OperatingSystemSection operatingSystem, Iterable<? extends VirtualHardwareSection> virtualHardwareSections, Iterable<? extends ProductSection> productSections, Multimap<String, Section> additionalSections) { super(info); this.id = id; this.name = name; this.operatingSystem = checkNotNull(operatingSystem, "operatingSystem"); this.virtualHardwareSections = ImmutableSet.copyOf(checkNotNull(virtualHardwareSections, "virtualHardwareSections")); this.productSections = ImmutableSet.copyOf(checkNotNull(productSections, "productSections")); this.additionalSections = ImmutableMultimap.copyOf(checkNotNull(additionalSections, "additionalSections")); }