List of usage examples for com.google.common.collect ImmutableMultimap copyOf
@Beta public static <K, V> ImmutableMultimap<K, V> copyOf( Iterable<? extends Entry<? extends K, ? extends V>> entries)
From source file:com.google.openrtb.json.OpenRtbJsonFactory.java
/** * Creates an {@link OpenRtbJsonWriter}, configured to the current state of this factory. *//*from ww w.jav a 2 s .c o m*/ public OpenRtbJsonWriter newWriter() { return new OpenRtbJsonWriter(new OpenRtbJsonFactory(getJsonFactory(), ImmutableMultimap.copyOf(extReaders), ImmutableMap.copyOf(extWriters))); }
From source file:org.apache.shindig.gadgets.render.DefaultServiceFetcher.java
/** * Returns the services, keyed by endpoint for the given container. * * @param container The particular container whose services we want. * @return Map endpoints and their serviceMethod list *//*from w ww .ja v a 2 s . com*/ public Multimap<String, String> getServicesForContainer(String container, String host) { if (containerConfig == null) { return ImmutableMultimap.<String, String>builder().build(); } LinkedHashMultimap<String, String> endpointServices = LinkedHashMultimap.create(); // First check services directly declared in container config @SuppressWarnings("unchecked") Map<String, Object> declaredServices = (Map<String, Object>) containerConfig .getMap(container, GADGETS_FEATURES_CONFIG).get(OSAPI_SERVICES); if (declaredServices != null) { for (Map.Entry<String, Object> entry : declaredServices.entrySet()) { @SuppressWarnings("unchecked") Iterable<String> entryValue = (Iterable<String>) entry.getValue(); endpointServices.putAll(entry.getKey(), entryValue); } } // Merge services lazily loaded from the endpoints if any List<String> endpoints = getEndpointsFromContainerConfig(container, host); for (String endpoint : endpoints) { endpointServices.putAll(endpoint, retrieveServices(endpoint.replace("%host%", host))); } return ImmutableMultimap.copyOf(endpointServices); }
From source file:org.iq80.leveldb.impl.VersionEdit.java
public Multimap<Integer, Long> getDeletedFiles() { return ImmutableMultimap.copyOf(deletedFiles); }
From source file:weld.guiceconfig.internal.CdiBindingOracle.java
public static CdiBindingOracle process(List<Element> elementList) { final HashMultimap<Class, Class<? extends Annotation>> annotations = HashMultimap.create(); final HashMap<Class, Class<? extends Annotation>> scopes = Maps.newHashMap(); final HashSet<InterceptorBinding> interceptors = Sets.newHashSet(); for (Element element : elementList) { element.acceptVisitor(new ElementVisitor<Void>() { @Override//from w w w . j a v a2 s . c o m public <T> Void visit(Binding<T> binding) { Key<T> key = binding.getKey(); Key targetKey = binding.acceptTargetVisitor(targetExtractor); Class<? extends Annotation> scope = binding.acceptScopingVisitor(scopeExtractor); processBinding(key, targetKey, scope, annotations, scopes); return null; } @Override public Void visit(InterceptorBinding interceptorBinding) { interceptors.add(interceptorBinding); return null; } @Override public Void visit(ScopeBinding scopeBinding) { log.warn("bindScope(...); not supported."); return null; } @Override public Void visit(TypeConverterBinding typeConverterBinding) { log.warn("convertToTypes(...); not supported."); return null; } @Override public Void visit(InjectionRequest injectionRequest) { log.warn("requestInjection(...); not supported."); return null; } @Override public Void visit(StaticInjectionRequest staticInjectionRequest) { log.warn("requestStaticInjection(...); not supported."); return null; } @Override public <T> Void visit(ProviderLookup<T> tProviderLookup) { log.warn("getProvider(...); not supported."); return null; } @Override public <T> Void visit(MembersInjectorLookup<T> tMembersInjectorLookup) { log.warn("getMembersInjector(...); not supported."); return null; } @Override public Void visit(Message message) { log.warn("addError(...); not supported."); return null; } @Override public Void visit(PrivateElements privateElements) { log.warn("expose(...); not supported."); return null; } @Override public Void visit(TypeListenerBinding typeListenerBinding) { log.warn("bindListener(...); not supported."); return null; } }); } return new CdiBindingOracle(ImmutableMultimap.copyOf(annotations), ImmutableMap.copyOf(scopes), ImmutableList.copyOf(interceptors)); }
From source file:com.google.openrtb.json.OpenRtbJsonFactory.java
/** * Creates an {@link OpenRtbJsonWriter}, configured to the current state of this factory. */// w ww . j a va 2 s . c o m public OpenRtbJsonReader newReader() { return new OpenRtbJsonReader(new OpenRtbJsonFactory(getJsonFactory(), ImmutableMultimap.copyOf(extReaders), ImmutableMap.copyOf(extWriters))); }
From source file:com.aipo.container.gadgets.render.AipoServiceFetcher.java
/** * Returns the services, keyed by endpoint for the given container. * * @param container/*from w ww. j ava2 s . c o m*/ * The particular container whose services we want. * @return Map endpoints and their serviceMethod list */ public Multimap<String, String> getServicesForContainer(String container, String host) { if (containerConfig == null) { return ImmutableMultimap.<String, String>builder().build(); } LinkedHashMultimap<String, String> endpointServices = LinkedHashMultimap.create(); // First check services directly declared in container config @SuppressWarnings("unchecked") Map<String, Object> declaredServices = (Map<String, Object>) containerConfig .getMap(container, GADGETS_FEATURES_CONFIG).get(OSAPI_SERVICES); if (declaredServices != null) { for (Map.Entry<String, Object> entry : declaredServices.entrySet()) { @SuppressWarnings("unchecked") Iterable<String> entryValue = (Iterable<String>) entry.getValue(); endpointServices.putAll(entry.getKey(), entryValue); } } HttpServletRequest request = HttpServletRequestLocator.get(); // Merge services lazily loaded from the endpoints if any List<String> endpoints = getEndpointsFromContainerConfig(container, host); for (String endpoint : endpoints) { if (endpoint.startsWith("//")) { endpoint = request.getScheme() + ":" + endpoint; } Set<String> merge = endpointServices.get("gadgets.rpc"); endpointServices.putAll(endpoint, merge); } return ImmutableMultimap.copyOf(endpointServices); }
From source file:com.b2international.snowowl.datastore.index.ImmutableIndexCommitChangeSet.java
/** * Apply this {@link ImmutableIndexCommitChangeSet} on the given {@link RevisionWriter index transaction}. * /* w ww .j ava 2 s.com*/ * @param index * @throws IOException */ @Override public void apply(RevisionWriter index) throws IOException { for (final Class<?> type : rawDeletions.keySet()) { final Map<Class<?>, Set<String>> map = Collections.<Class<?>, Set<String>>singletonMap(type, Sets.newHashSet(rawDeletions.get(type))); index.writer().removeAll(map); } for (Entry<String, Object> doc : rawMappings.entrySet()) { if (!rawDeletions.containsValue(doc.getKey())) { index.writer().put(doc.getKey(), doc.getValue()); } } final Multimap<Class<? extends Revision>, Long> copiedRevision = ImmutableMultimap .copyOf(revisionDeletions); for (Class<? extends Revision> type : copiedRevision.keySet()) { index.remove(type, copiedRevision.get(type)); } for (Entry<Long, Revision> doc : revisionMappings.entrySet()) { if (!revisionDeletions.containsValue(doc.getKey())) { index.put(doc.getKey(), doc.getValue()); } } }
From source file:org.ow2.proactive.addons.inmemory_keyvalue_store.InMemoryKeyValueStore.java
@ImmediateService public Multimap<String, String> getChannels() { synchronized (channels) { return ImmutableMultimap.copyOf(channels); } }
From source file:org.opendaylight.yangtools.yang.parser.repo.DependencyResolver.java
protected DependencyResolver(final Map<SourceIdentifier, YangModelDependencyInfo> depInfo) { final Collection<SourceIdentifier> resolved = new ArrayList<>(depInfo.size()); final Collection<SourceIdentifier> pending = new ArrayList<>(depInfo.keySet()); final Map<SourceIdentifier, BelongsToDependency> submodules = Maps.newHashMap(); boolean progress; do {//ww w.java 2 s . c o m progress = false; final Iterator<SourceIdentifier> it = pending.iterator(); while (it.hasNext()) { final SourceIdentifier id = it.next(); final YangModelDependencyInfo dep = depInfo.get(id); boolean okay = true; final Set<ModuleImport> dependencies = dep.getDependencies(); // in case of submodule, remember belongs to if (dep instanceof YangModelDependencyInfo.SubmoduleDependencyInfo) { final String parent = ((YangModelDependencyInfo.SubmoduleDependencyInfo) dep).getParentModule(); submodules.put(id, new BelongsToDependency(parent)); } for (final ModuleImport mi : dependencies) { if (!isKnown(resolved, mi)) { LOG.debug("Source {} is missing import {}", id, mi); okay = false; break; } } if (okay) { LOG.debug("Resolved source {}", id); resolved.add(id); it.remove(); progress = true; } } } while (progress); /// Additional check only for belongs-to statement for (final Entry<SourceIdentifier, BelongsToDependency> submodule : submodules.entrySet()) { final BelongsToDependency belongs = submodule.getValue(); final SourceIdentifier sourceIdentifier = submodule.getKey(); if (!isKnown(resolved, belongs)) { LOG.debug("Source {} is missing parent {}", sourceIdentifier, belongs); pending.add(sourceIdentifier); resolved.remove(sourceIdentifier); } } final Multimap<SourceIdentifier, ModuleImport> imports = ArrayListMultimap.create(); for (final SourceIdentifier id : pending) { final YangModelDependencyInfo dep = depInfo.get(id); for (final ModuleImport mi : dep.getDependencies()) { if (!isKnown(pending, mi) && !isKnown(resolved, mi)) { imports.put(id, mi); } } } this.resolvedSources = ImmutableList.copyOf(resolved); this.unresolvedSources = ImmutableList.copyOf(pending); this.unsatisfiedImports = ImmutableMultimap.copyOf(imports); }
From source file:de.metas.ui.web.order.sales.purchasePlanning.process.WEBUI_SalesOrder_Apply_Availability_Row.java
private Multimap<PurchaseRow, PurchaseRow> extractLineRow2availabilityRows() { final PurchaseView view = getView(); final ListMultimap<PurchaseRow, PurchaseRow> lineRow2AvailabilityRows = getSelectedRowIds().stream() .map(PurchaseRowId::fromDocumentId) // map to PurchaseRowIds .filter(PurchaseRowId::isAvailabilityRowId) .filter(availabilityRowId -> availabilityRowId.getAvailabilityType().equals(Type.AVAILABLE)) .map(availabilityRowId -> ImmutablePair.of( // map to pair (availabilityRowId, availabilityRow) availabilityRowId, view.getById(availabilityRowId.toDocumentId()))) .filter(availabilityRowId2row -> isPositive(availabilityRowId2row.getRight().getQtyToPurchase())) .map(availabilityRowId2row -> ImmutablePair.of( // map to pair (lineRow, availabilityRow) view.getById(availabilityRowId2row.getLeft().toLineRowId().toDocumentId()), availabilityRowId2row.getRight())) .filter(lineRow2availabilityRow -> !lineRow2availabilityRow.getLeft().isProcessed()) .collect(Multimaps.toMultimap(IPair::getLeft, IPair::getRight, MultimapBuilder.hashKeys().arrayListValues()::build)); return ImmutableMultimap.copyOf(lineRow2AvailabilityRows); }