@Test public void testShouldAddObjectIfNotExists() throws Exception { final TestObject addedObject = new TestObject(111); multimap.update(3, new ObjectAddedUpdater<TestObject>(addedObject)); assertTrue(multimap.get(3).contains(addedObject)); }
@Nullable @Override public List<V> update(@Nonnull List<V> values) { if (values == ThreadSafeMultimap.NO_VALUE) { return null; } else if (!Iterables.contains(values, newObject)) { final List<V> result = ThreadSafeMultimap.copy(values); result.add(newObject); return result; } else { return null; } }
ObjectAddedUpdater implements ThreadSafeMultimap.ListUpdater<V> { @Nullable @Override public List<V> update(@Nonnull List<V> values) { if (values == ThreadSafeMultimap.NO_VALUE) { return null; } else if (!Iterables.contains(values, newObject)) { final List<V> result = ThreadSafeMultimap.copy(values); result.add(newObject); return result; } else { return null; } } }
ObjectAddedUpdater implements ThreadSafeMultimap.ListUpdater<V> { @Nullable @Override public List<V> update(@Nonnull List<V> values) { if (values == ThreadSafeMultimap.NO_VALUE) { return null; } else if (!Iterables.contains(values, newObject)) { final List<V> result = ThreadSafeMultimap.copy(values); result.add(newObject); return result; } else { return null; } } ObjectAddedUpdater(@Nonnull V newObject); }
ObjectAddedUpdater implements ThreadSafeMultimap.ListUpdater<V> { @Nullable @Override public List<V> update(@Nonnull List<V> values) { if (values == ThreadSafeMultimap.NO_VALUE) { return null; } else if (!Iterables.contains(values, newObject)) { final List<V> result = ThreadSafeMultimap.copy(values); result.add(newObject); return result; } else { return null; } } ObjectAddedUpdater(@Nonnull V newObject); @Nullable @Override List<V> update(@Nonnull List<V> values); }
ObjectAddedUpdater implements ThreadSafeMultimap.ListUpdater<V> { @Nullable @Override public List<V> update(@Nonnull List<V> values) { if (values == ThreadSafeMultimap.NO_VALUE) { return null; } else if (!Iterables.contains(values, newObject)) { final List<V> result = ThreadSafeMultimap.copy(values); result.add(newObject); return result; } else { return null; } } ObjectAddedUpdater(@Nonnull V newObject); @Nullable @Override List<V> update(@Nonnull List<V> values);  }