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

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

Introduction

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

Prototype

boolean remove(@Nullable Object key, @Nullable Object value);

Source Link

Document

Removes a single key-value pair with the key key and the value value from this multimap, if such exists.

Usage

From source file:ca.sqlpower.dao.helper.AbstractSPPersisterHelper.java

/**
 * Finds and removes a property from a {@link Multimap} of persisted
 * properties of a given {@link SPObject}.
 * // w w  w .jav a  2 s  . co m
 * @param uuid
 *            The UUID of the {@link SPObject} to find and remove the
 *            property from.
 * @param propertyName
 *            The JavaBean property name.
 * @param persistedProperties
 *            {@link Multimap} of persisted properties to retrieve and
 *            remove the property from.
 * @return The value of the property.
 */
public static Object findPropertyAndRemove(String uuid, String propertyName,
        Multimap<String, PersistedSPOProperty> persistedProperties) {
    for (PersistedSPOProperty property : persistedProperties.get(uuid)) {
        if (property.getPropertyName().equals(propertyName)) {
            Object newValue = property.getNewValue();
            persistedProperties.remove(uuid, property);
            return newValue;
        }
    }
    // Property might not be persisted because it might be null. 
    // We therefore need to return null.
    return null;
}

From source file:com.google.publicalerts.cap.testing.CapTestUtil.java

/**
 * Asserts that the {@code expected} matches {@code actual}, where equality
 * between {@link Reason} objects is guaranteed if two objects have same:
 * <ul>//from  w  w  w . j a v a2  s . com
 * <li>reason type,
 * <li>XPath.
 * </ul>
 */
public static void assertReasons(Reasons actual, Reason... expected) {
    Multimap<Reason.Type, String> expectedReasonTypeToXPath = HashMultimap.create();

    for (Reason reason : expected) {
        expectedReasonTypeToXPath.put(reason.getType(), reason.getXPath());
    }

    String msg = "";
    boolean failed = false;

    for (Reason reason : actual) {
        if (!expectedReasonTypeToXPath.remove(reason.getType(), reason.getXPath())) {
            msg += " Unexpected reason: " + reason;
            failed = true;
        }
    }

    for (Entry<Reason.Type, String> expectedEntry : expectedReasonTypeToXPath.entries()) {
        msg += " Expected reason with type: " + expectedEntry.getKey() + " and XPath: "
                + expectedEntry.getValue();
        failed = true;
    }

    Assert.assertFalse(msg, failed);
}

From source file:org.sonar.plsqlopen.checks.verifier.PlSqlCheckVerifier.java

private static void validateIssue(Multimap<Integer, Map<IssueAttribute, String>> expected,
        List<Integer> unexpectedLines, AnalyzerMessage issue) {
    int line = issue.getLine();
    if (expected.containsKey(line)) {
        Map<IssueAttribute, String> attrs = Iterables.getLast(expected.get(line));
        assertEquals(issue.getText(Locale.ENGLISH), attrs, IssueAttribute.MESSAGE);
        validateAnalyzerMessage(attrs, issue);
        expected.remove(line, attrs);
    } else {/*from  www  . j  ava 2s  .com*/
        unexpectedLines.add(line);
    }
}

From source file:org.polarsys.reqcycle.uri.impl.ReachableListenerManager.java

public <X, Y> void remove(Multimap<X, Y> map, Multimap<Y, X> map2, X reachable, Y listener) {
    map.remove(reachable, listener);
    map2.remove(listener, reachable);/*from   w w  w .j ava 2 s. c  o m*/
}

From source file:gr.forth.ics.swkm.model2.index.NamespaceIndexer.java

private void removeEntry(Resource resource, RdfType type) {
    if (!type.isSchema()) {
        return;/*from  w w w. java 2s. c o  m*/
    }
    Uri namespace = resource.getUri().getNamespaceUri();
    Multimap<RdfType, Resource> map = index.get(namespace);
    if (map == null) {
        return;
    }
    map.remove(type, resource);
    if (map.isEmpty()) {
        index.remove(namespace);
    }
}

From source file:com.b2international.snowowl.datastore.server.oplock.impl.RemoteLockTargetListener.java

@Override
public void targetReleased(final IOperationLockTarget target, final DatastoreLockContext context) {

    final RpcSession session = RpcThreadLocal.getSessionUnchecked();

    if (null == session) {
        return;/*from w ww .  java 2 s  . com*/
    }

    if (!remotelyLockedContexts.containsKey(session)) {
        return;
    }

    final Multimap<IOperationLockTarget, DatastoreLockContext> targetsForSession = remotelyLockedContexts
            .get(session);
    targetsForSession.remove(target, context);
}

From source file:org.opendaylight.controller.sal.binding.impl.NotificationBrokerImpl.java

private synchronized void removeRegistrations(final NotificationListenerRegistration<?>... registrations) {
    final Multimap<Class<? extends Notification>, NotificationListenerRegistration<?>> newListeners = mutableListeners();

    for (NotificationListenerRegistration<?> reg : registrations) {
        newListeners.remove(reg.getType(), reg);
    }/*from  w  ww.  j  ava2s.co m*/

    listeners.set(new ListenerMapGeneration(newListeners));
}

From source file:org.opendaylight.controller.md.sal.binding.compat.HydrogenNotificationBrokerImpl.java

private synchronized void removeRegistrations(final NotificationListenerRegistration<?>... registrations) {
    final Multimap<Class<? extends Notification>, NotificationListenerRegistration<?>> newListeners = mutableListeners();

    for (final NotificationListenerRegistration<?> reg : registrations) {
        newListeners.remove(reg.getType(), reg);
    }/*w w w .  ja v a 2s .co  m*/

    listeners.set(new ListenerMapGeneration(newListeners));
}

From source file:org.wso2.siddhi.debs2016.graph.CommentLikeGraph.java

/**
 * Handle event of a new friendship in CommentLikeGraph
 *
 * @param userOneId the userID of friend one
 * @param userTwoId the userID of friend two
 * @param componentSizeCommentMap is reference to Map that holds size and comment string of each comment
 *//*from w w  w .ja va 2 s  .  c  om*/
public void handleNewFriendship(long userOneId, long userTwoId,
        Multimap<Long, String> componentSizeCommentMap) {
    if (graph.hasVertex(userOneId) && graph.hasVertex(userTwoId)) {
        graph.addEdge(userOneId, userTwoId);
        if (sizeOfLargestConnectedComponent != 0) {
            componentSizeCommentMap.remove(getSizeOfLargestConnectedComponent(), comment);
        }
        sizeOfLargestConnectedComponent = computeLargestConnectedComponent();
        componentSizeCommentMap.put(sizeOfLargestConnectedComponent, comment);
    }
}

From source file:org.waveprotocol.box.server.waveserver.MemoryPerUserWaveViewHandlerImpl.java

@Override
public ListenableFuture<Void> onParticipantRemoved(WaveletName waveletName, ParticipantId user) {
    Multimap<WaveId, WaveletId> perUserView = explicitPerUserWaveViews.getIfPresent(user);
    if (perUserView != null) {
        if (perUserView.containsEntry(waveletName.waveId, waveletName.waveletId)) {
            perUserView.remove(waveletName.waveId, waveletName.waveletId);
            LOG.fine("Removed wavelet: " + waveletName + " from the view of user: " + user.getAddress());
        }/*from  ww w  .  ja  v  a 2 s  . co  m*/
    }
    SettableFuture<Void> task = SettableFuture.create();
    task.set(null);
    return task;
}