Example usage for com.google.common.collect Multimap values

List of usage examples for com.google.common.collect Multimap values

Introduction

In this page you can find the example usage for com.google.common.collect Multimap values.

Prototype

Collection<V> values();

Source Link

Document

Returns a view collection containing the value from each key-value pair contained in this multimap, without collapsing duplicates (so values().size() == size() ).

Usage

From source file:eu.mondo.driver.mongo.MongoGraphDriver.java

@Override
public void insertEdgesWithVertex(final Multimap<String, String> edges, final String edgeURI,
        final String vertexTypeURI) throws IOException {
    if (edges.isEmpty()) {
        return;/*from w w w.  j  a  va2s . c  om*/
    }

    for (final String targetVertexURI : edges.values()) {
        insertVertex(vertexTypeURI, targetVertexURI);
    }

    insertEdges(edges, edgeURI);
}

From source file:org.spongepowered.despector.ast.type.TypeEntry.java

protected MethodEntry findMethod(String name, Multimap<String, MethodEntry> map) {
    MethodEntry ret = null;//from   w  ww  . j a v  a2s  . c  om
    for (MethodEntry m : map.values()) {
        if (m.getName().equals(name)) {
            if (ret != null) {
                throw new IllegalStateException("Tried to get ambiguous method " + name);
            }
            ret = m;
        }
    }
    //        if (ret == null && this.actual_class != null) {
    //            Method found = null;
    //            for (Method mth : this.actual_class.getMethods()) {
    //                if (mth.getName().equals(name)) {
    //                    if (found != null) {
    //                        throw new IllegalStateException("Tried to get ambiguous method " + name);
    //                    }
    //                    found = mth;
    //                }
    //            }
    //            String sig = "(";
    //            for (Class<?> param : found.getParameterTypes()) {
    //                sig += Type.getDescriptor(param);
    //            }
    //            sig += ")";
    //            sig += Type.getDescriptor(found.getReturnType());
    //            MethodEntry dummy =
    //                    new MethodEntry(this, AccessModifier.fromModifiers(found.getModifiers()), name, sig, Modifier.isStatic(found.getModifiers()));
    //            dummy.setReturnType(this.set.get(Type.getInternalName(found.getReturnType())));
    //            if (Modifier.isStatic(found.getModifiers())) {
    //                this.static_methods.put(name, dummy);
    //            } else {
    //                this.methods.put(name, dummy);
    //            }
    //            return dummy;
    //        }
    return ret;
}

From source file:com.github.jsdossier.jscomp.TypeRegistry.java

/**
 * Finds all nominal types whose underlying JSType is <em>equivalent</em> to the given type. This
 * stands in contrast to {@link #getTypes(JSType)}, which returns the nominal types with the
 * exact JSType.//from w ww  . j  av  a2  s  . co m
 */
public Collection<NominalType> findTypes(final JSType type) {
    Predicate<JSType> predicate = new Predicate<JSType>() {
        @Override
        public boolean apply(JSType input) {
            return typesEqual(type, input);
        }
    };
    Multimap<JSType, NominalType> filtered = filterKeys(typesByJsType, predicate);
    return Collections.unmodifiableCollection(filtered.values());
}

From source file:org.mitreid.multiparty.service.InMemoryResourceService.java

@Override
public Resource getById(final String rsId) {

    Multimap<String, Resource> filtered = Multimaps.filterValues(resources, new Predicate<Resource>() {

        @Override//from  ww  w.  j  a  v  a  2s  . c  o  m
        public boolean apply(Resource input) {
            if (input.getId().equals(rsId)) {
                return true;
            } else {
                return false;
            }
        }
    });

    if (filtered.size() == 1) {
        return Iterators.getOnlyElement(filtered.values().iterator());
    } else {
        return null;
    }

}

From source file:org.killbill.billing.plugin.analytics.dao.BusinessInvoiceAndPaymentDao.java

/**
 * Refresh the records. This does not perform any logic but simply deletes existing records and inserts the current ones.
 *
 * @param bac             current, fully populated, BusinessAccountModelDao record
 * @param invoices        current, fully populated, mapping of invoice id -> BusinessInvoiceModelDao records
 * @param invoiceItems    current, fully populated, mapping of invoice id -> BusinessInvoiceItemBaseModelDao records
 * @param invoicePayments current, fully populated, mapping of invoice id -> BusinessInvoicePaymentBaseModelDao records
 * @param transactional   current transaction
 * @param context         call context//  w  w w.  j a  va 2 s.c o  m
 */
private void updateInTransaction(final BusinessAccountModelDao bac,
        final Map<UUID, BusinessInvoiceModelDao> invoices,
        final Multimap<UUID, BusinessInvoiceItemBaseModelDao> invoiceItems,
        final Multimap<UUID, BusinessPaymentBaseModelDao> invoicePayments,
        final BusinessAnalyticsSqlDao transactional, final CallContext context) {
    // Update invoice and invoice items tables
    businessInvoiceDao.updateInTransaction(bac, invoices, invoiceItems, transactional, context);

    // Update payment tables
    businessPaymentDao.updateInTransaction(bac,
            Iterables.<BusinessPaymentBaseModelDao>concat(invoicePayments.values()), transactional, context);

    // Update denormalized invoice and payment details in BAC
    businessAccountDao.updateInTransaction(bac, transactional, context);
}

From source file:com.b2international.snowowl.snomed.reasoner.server.classification.EquivalentConceptMerger.java

public void fixEquivalencies() {
    // First resolve the equivalencies Map, to find the equivalent concept instances
    final Multimap<Concept, Concept> equivalentConcepts = resolveEquivalencies();
    final Iterable<Concept> concepts = Iterables.concat(equivalentConcepts.keySet(),
            equivalentConcepts.values());
    final Iterable<String> destinationIds = Iterables.transform(concepts, Concept::getId);
    SnomedRelationships inboundRelationships = SnomedRequests.prepareSearchRelationship().all()
            .filterByActive(true).filterByDestination(destinationIds)
            .build(SnomedDatastoreActivator.REPOSITORY_UUID, editingContext.getBranch())
            .execute(ApplicationContext.getServiceForClass(IEventBus.class)).getSync();
    final Multimap<String, Relationship> inboundRelationshipMap = HashMultimap.create(FluentIterable
            .from(inboundRelationships)//from  ww  w .j  ava  2 s  .  c o m
            .transform(relationship -> (Relationship) editingContext.lookup(relationship.getStorageKey()))
            //Exclude relationships that were already marked redundant
            .filter(relationship -> relationship.getSource() != null && relationship.getDestination() != null)
            .index(relationship -> relationship.getDestination().getId()));
    for (Relationship relationship : ComponentUtils2.getNewObjects(editingContext.getTransaction(),
            Relationship.class)) {
        inboundRelationshipMap.put(relationship.getDestination().getId(), relationship);
    }
    for (Relationship relationship : ComponentUtils2.getDetachedObjects(editingContext.getTransaction(),
            Relationship.class)) {
        inboundRelationshipMap.values().remove(relationship);
    }

    // iterate over the sorted concepts and switch to the equivalent using
    // the resolved Map
    try {
        for (final Concept conceptToKeep : equivalentConcepts.keySet()) {
            final Collection<Concept> conceptsToRemove = equivalentConcepts.get(conceptToKeep);
            switchToEquivalentConcept(conceptToKeep, conceptsToRemove, inboundRelationshipMap,
                    equivalentConcepts);
            removeOrDeactivate(conceptsToRemove);
        }

    } catch (ConflictException e) {
        throw new SnowowlRuntimeException(e);
    }
}

From source file:com.dnastack.bob.service.impl.BeaconResponseServiceImpl.java

private Collection<BeaconResponse> queryMultipleBeacons(Collection<String> beaconIds, String chrom, Long pos,
        String allele, String ref) throws ClassNotFoundException {
    Query q = getQuery(chrom, pos, allele, ref);

    // init to create a response for each beacon even if the query is invalid
    Map<Beacon, BeaconResponse> brs = setUpBeaconResponseMapForIds(beaconIds, q);

    // validate query
    if (queryNotNormalizedOrValid(q, ref)) {
        return brs.values();
    }//from   w w  w .j  a  v a2s . co m

    // construct map of atomic nodes covered by aggregates
    Multimap<Beacon, Beacon> children = setUpChildrenMultimap(brs.keySet());
    // obtain children's responses
    Map<Beacon, BeaconResponse> childrenResponses = fillBeaconResponseMap(
            setUpBeaconResponseMapForBeacons(new HashSet<>(children.values()), q), q);

    // aggregate
    return fillAggregateResponses(brs, childrenResponses, children, q).values();
}

From source file:com.palantir.atlasdb.sweep.SweepTaskRunner.java

private Multimap<Cell, Long> getCellTsPairsToSweep(Multimap<Cell, Long> cellTsMappings,
        PeekingIterator<RowResult<Value>> values, long sweepTimestamp, SweepStrategy sweepStrategy,
        @Output Set<Cell> sentinelsToAdd) {
    Multimap<Cell, Long> cellTsMappingsToSweep = HashMultimap.create();

    Map<Long, Long> startTsToCommitTs = transactionService.get(cellTsMappings.values());
    for (Map.Entry<Cell, Collection<Long>> entry : cellTsMappings.asMap().entrySet()) {
        Cell cell = entry.getKey();/*from  ww w . ja v  a 2 s.  co  m*/
        Collection<Long> timestamps = entry.getValue();
        boolean sweepLastCommitted = isLatestValueEmpty(cell, values);
        Iterable<? extends Long> timestampsToSweep = getTimestampsToSweep(cell, timestamps, startTsToCommitTs,
                sentinelsToAdd, sweepTimestamp, sweepLastCommitted, sweepStrategy);
        cellTsMappingsToSweep.putAll(entry.getKey(), timestampsToSweep);
    }
    return cellTsMappingsToSweep;
}

From source file:com.ning.billing.osgi.bundles.analytics.dao.BusinessInvoiceAndInvoicePaymentDao.java

/**
 * Refresh the records. This does not perform any logic but simply deletes existing records and inserts the current ones.
 *
 * @param bac             current, fully populated, BusinessAccountModelDao record
 * @param invoices        current, fully populated, mapping of invoice id -> BusinessInvoiceModelDao records
 * @param invoiceItems    current, fully populated, mapping of invoice id -> BusinessInvoiceItemBaseModelDao records
 * @param invoicePayments current, fully populated, mapping of invoice id -> BusinessInvoicePaymentBaseModelDao records
 * @param transactional   current transaction
 * @param context         call context/*from  w w  w .  j a v  a2  s.  com*/
 */
private void updateInTransaction(final BusinessAccountModelDao bac,
        final Map<UUID, BusinessInvoiceModelDao> invoices,
        final Multimap<UUID, BusinessInvoiceItemBaseModelDao> invoiceItems,
        final Multimap<UUID, BusinessInvoicePaymentBaseModelDao> invoicePayments,
        final BusinessAnalyticsSqlDao transactional, final CallContext context) {
    // Update invoice and invoice items tables
    businessInvoiceDao.updateInTransaction(bac, invoices, invoiceItems, transactional, context);

    // Update invoice payment tables
    businessInvoicePaymentDao.updateInTransaction(bac,
            Iterables.<BusinessInvoicePaymentBaseModelDao>concat(invoicePayments.values()), transactional,
            context);

    // Update denormalized invoice and payment details in BAC
    businessAccountDao.updateInTransaction(bac, transactional, context);
}

From source file:org.robotframework.ide.eclipse.main.plugin.navigator.actions.ReloadLibraryAction.java

private void rebuildLibraries(final IProgressMonitor monitor) {
    final Multimap<IProject, LibrarySpecification> groupedSpecifications = groupSpecificationsByProject();
    monitor.beginTask("Regenerating library specifications", 10);
    new LibrariesBuilder(new BuildLogger()).forceLibrariesRebuild(groupedSpecifications,
            SubMonitor.convert(monitor));
    for (final IProject project : groupedSpecifications.keySet()) {
        final RobotProject robotProject = RedPlugin.getModelManager().createProject(project);
        robotProject.clearDirtyLibSpecs(groupedSpecifications.values());
        robotProject.clearConfiguration();
        robotProject.clearKwSources();//from  ww w. j a  v  a 2 s .co  m
    }

    SwtThread.asyncExec(new Runnable() {
        @Override
        public void run() {
            ((TreeViewer) selectionProvider).refresh();
        }
    });
}