List of usage examples for com.google.common.collect Multimaps newSetMultimap
public static <K, V> SetMultimap<K, V> newSetMultimap(Map<K, Collection<V>> map, final Supplier<? extends Set<V>> factory)
From source file:org.onosproject.store.trivial.impl.SimpleLinkStore.java
/** * Creates concurrent readable, synchronized HashMultimap. * * @return SetMultimap/*from www .j av a2 s .c om*/ */ private static <K, V> SetMultimap<K, V> createSynchronizedHashMultiMap() { return synchronizedSetMultimap(Multimaps.newSetMultimap(new ConcurrentHashMap<K, Collection<V>>(), () -> Sets.newConcurrentHashSet())); }
From source file:org.eclipse.osee.orcs.db.internal.loader.processor.DynamicObjectBuilder.java
private static <K, V> SetMultimap<K, V> newSetMultimap() { Map<K, Collection<V>> map = Maps.newLinkedHashMap(); return Multimaps.newSetMultimap(map, new Supplier<Set<V>>() { @Override//from w w w .j a v a2s .c o m public Set<V> get() { return Sets.newLinkedHashSet(); } }); }
From source file:com.google.cloud.dataflow.sdk.util.ApiSurface.java
/** * See {@link #getExposedToExposers}./*ww w.j av a 2s . c om*/ */ private void constructExposedToExposers() { visited = Sets.newHashSet(); exposedToExposers = Multimaps.newSetMultimap(Maps.<Class<?>, Collection<Class<?>>>newHashMap(), new Supplier<Set<Class<?>>>() { @Override public Set<Class<?>> get() { return Sets.newHashSet(); } }); for (Class<?> clazz : rootClasses) { addExposedTypes(clazz, null); } }
From source file:me.seeber.gradle.workspace.WorkspacePlugin.java
/** * Get the configurations that export an artifact * * @param projects Projects to search/* www .j a va 2 s .c o m*/ * @return Exporting configurations */ protected Multimap<@NonNull String, @NonNull ExportingConfiguration> getExportingConfigurations( Collection<@NonNull Project> projects) { Multimap<@NonNull String, @NonNull ExportingConfiguration> exports = Multimaps .newSetMultimap(new HashMap<>(), () -> new TreeSet<>(CONFIGURATION_INFO_COMPARATOR)); for (Project project : projects) { Set<String> configurationNames = ImmutableSet.of("default"); WorkspaceConfig workspaceConfig = project.getExtensions().findByType(WorkspaceConfig.class); if (workspaceConfig != null) { configurationNames = workspaceConfig.getExportedConfigurations(); } for (String configurationName : configurationNames) { Configuration configuration = project.getConfigurations().findByName(configurationName); if (configuration != null) { getExportingConfigurations(project, configuration, exports); } } } return exports; }
From source file:org.jboss.weld.annotated.enhanced.jlr.EnhancedAnnotatedTypeImpl.java
/** * * @param annotatedType/* w w w . j av a 2 s. c o m*/ * @param methods * @param skipOverridingBridgeMethods If set to <code>true</code> the returning set will not contain methods overriden by a bridge method * @return the set of overriden methods */ protected Set<EnhancedAnnotatedMethod<?, ? super T>> getOverriddenMethods( EnhancedAnnotatedType<T> annotatedType, Set<EnhancedAnnotatedMethod<?, ? super T>> methods, boolean skipOverridingBridgeMethods) { Set<EnhancedAnnotatedMethod<?, ? super T>> overriddenMethods = new HashSet<EnhancedAnnotatedMethod<?, ? super T>>(); Multimap<MethodSignature, Package> seenMethods = Multimaps.newSetMultimap( new HashMap<MethodSignature, Collection<Package>>(), HashSetSupplier.<Package>instance()); for (Class<? super T> clazz = annotatedType.getJavaClass(); clazz != null && clazz != Object.class; clazz = clazz.getSuperclass()) { for (EnhancedAnnotatedMethod<?, ? super T> method : methods) { if (method.getJavaMember().getDeclaringClass().equals(clazz)) { if (skipOverridingBridgeMethods && method.getJavaMember().isBridge()) { continue; } if (isOverridden(method, seenMethods)) { overriddenMethods.add(method); } seenMethods.put(method.getSignature(), method.getPackage()); } } } return immutableSet(overriddenMethods); }
From source file:org.onosproject.store.link.impl.GossipLinkStore.java
/** * Creates concurrent readable, synchronized HashMultimap. * * @return SetMultimap//from w ww.j av a2 s .co m */ private static <K, V> SetMultimap<K, V> createSynchronizedHashMultiMap() { return synchronizedSetMultimap( Multimaps.newSetMultimap(new ConcurrentHashMap<>(), () -> Sets.newConcurrentHashSet())); }
From source file:org.jboss.weld.bootstrap.Validator.java
public void validateBeanNames(BeanManagerImpl beanManager) { SetMultimap<String, Bean<?>> namedAccessibleBeans = Multimaps .newSetMultimap(new HashMap<String, Collection<Bean<?>>>(), HashSetSupplier.<Bean<?>>instance()); for (Bean<?> bean : beanManager.getAccessibleBeans()) { if (bean.getName() != null) { namedAccessibleBeans.put(bean.getName(), bean); }/*from w w w.j a va2s. c o m*/ } List<String> accessibleNamespaces = new ArrayList<String>(); for (String namespace : beanManager.getAccessibleNamespaces()) { accessibleNamespaces.add(namespace); } SpecializationAndEnablementRegistry registry = beanManager.getServices() .get(SpecializationAndEnablementRegistry.class); for (String name : namedAccessibleBeans.keySet()) { Set<Bean<?>> resolvedBeans = beanManager.getBeanResolver() .resolve(Beans.removeDisabledBeans(namedAccessibleBeans.get(name), beanManager, registry)); if (resolvedBeans.size() > 1) { throw ValidatorLogger.LOG.ambiguousElName(name, resolvedBeans); } if (accessibleNamespaces.contains(name)) { throw ValidatorLogger.LOG.beanNameIsPrefix(name); } } }
From source file:com.zimbra.cs.db.DbMailItem.java
public static SetMultimap<MailItem.Type, Integer> getIndexDeferredIds(DbConnection conn, Mailbox mbox) throws ServiceException { SetMultimap<MailItem.Type, Integer> result = Multimaps.newSetMultimap( new EnumMap<MailItem.Type, Collection<Integer>>(MailItem.Type.class), new Supplier<Set<Integer>>() { @Override//from ww w. j a va 2 s.c om public Set<Integer> get() { return new HashSet<Integer>(); } }); PreparedStatement stmt = null; ResultSet rs = null; try { // from MAIL_ITEM table stmt = conn.prepareStatement("SELECT type, id FROM " + getMailItemTableName(mbox, false) + " WHERE " + IN_THIS_MAILBOX_AND + "index_id <= 1"); // 0: deferred, 1: stale setMailboxId(stmt, mbox, 1); rs = stmt.executeQuery(); while (rs.next()) { result.put(MailItem.Type.of(rs.getByte(1)), rs.getInt(2)); } } catch (SQLException e) { throw ServiceException.FAILURE("Failed to query index deferred IDs", e); } finally { conn.closeQuietly(rs); conn.closeQuietly(stmt); } if (mbox.dumpsterEnabled()) { try { // also from MAIL_ITEM_DUMPSTER table stmt = conn.prepareStatement("SELECT type, id FROM " + getMailItemTableName(mbox, true) + " WHERE " + IN_THIS_MAILBOX_AND + "index_id <= 1"); setMailboxId(stmt, mbox, 1); rs = stmt.executeQuery(); while (rs.next()) { result.put(MailItem.Type.of(rs.getByte(1)), rs.getInt(2)); } } catch (SQLException e) { throw ServiceException.FAILURE("Failed to query index deferred IDs from dumpster", e); } finally { conn.closeQuietly(rs); conn.closeQuietly(stmt); } } return result; }