@Test public void testShouldNotAddExistingObject() throws Exception { final List<TestObject> expected = multimap.asMap().get(5); multimap.update(5, new ObjectsAddedUpdater<TestObject>(Arrays.asList(multimap.get(5).get(3)))); final List<TestObject> actual = multimap.asMap().get(5); assertEquals(expected, actual); assertSame(expected, actual); }
@Nullable @Override public List<V> update(@Nonnull List<V> values) { if (values == ThreadSafeMultimap.NO_VALUE) { return null; } else { List<V> result = null; for (V newObject : newObjects) { if (!Iterables.contains(values, newObject)) { if (result == null) { result = ThreadSafeMultimap.copy(values); } result.add(newObject); } } return result; } }
ObjectsAddedUpdater implements ThreadSafeMultimap.ListUpdater<V> { @Nullable @Override public List<V> update(@Nonnull List<V> values) { if (values == ThreadSafeMultimap.NO_VALUE) { return null; } else { List<V> result = null; for (V newObject : newObjects) { if (!Iterables.contains(values, newObject)) { if (result == null) { result = ThreadSafeMultimap.copy(values); } result.add(newObject); } } return result; } } }
ObjectsAddedUpdater implements ThreadSafeMultimap.ListUpdater<V> { @Nullable @Override public List<V> update(@Nonnull List<V> values) { if (values == ThreadSafeMultimap.NO_VALUE) { return null; } else { List<V> result = null; for (V newObject : newObjects) { if (!Iterables.contains(values, newObject)) { if (result == null) { result = ThreadSafeMultimap.copy(values); } result.add(newObject); } } return result; } } ObjectsAddedUpdater(@Nonnull Collection<V> newObjects); }
ObjectsAddedUpdater implements ThreadSafeMultimap.ListUpdater<V> { @Nullable @Override public List<V> update(@Nonnull List<V> values) { if (values == ThreadSafeMultimap.NO_VALUE) { return null; } else { List<V> result = null; for (V newObject : newObjects) { if (!Iterables.contains(values, newObject)) { if (result == null) { result = ThreadSafeMultimap.copy(values); } result.add(newObject); } } return result; } } ObjectsAddedUpdater(@Nonnull Collection<V> newObjects); @Nullable @Override List<V> update(@Nonnull List<V> values); }
ObjectsAddedUpdater implements ThreadSafeMultimap.ListUpdater<V> { @Nullable @Override public List<V> update(@Nonnull List<V> values) { if (values == ThreadSafeMultimap.NO_VALUE) { return null; } else { List<V> result = null; for (V newObject : newObjects) { if (!Iterables.contains(values, newObject)) { if (result == null) { result = ThreadSafeMultimap.copy(values); } result.add(newObject); } } return result; } } ObjectsAddedUpdater(@Nonnull Collection<V> newObjects); @Nullable @Override List<V> update(@Nonnull List<V> values);  }