@Override public boolean isEmpty() { return Iterate.isEmpty(this.adapted); }
@Override public boolean isEmpty() { return Iterate.isEmpty(this.adapted); }
@Override public boolean containsAllIterable(Iterable<?> source) { return Iterate.isEmpty(source); }
/** * A null-safe check on a collection to see if it is notEmpty. A null collection results in a false. */ public static boolean notEmpty(Iterable<?> iterable) { return !Iterate.isEmpty(iterable); }
/** * Returns the first element of a list. */ public static <T> T getFirst(List<T> collection) { return Iterate.isEmpty(collection) ? null : collection.get(0); }
/** * Returns the last element of a list. */ public static <T> T getLast(List<T> collection) { return Iterate.isEmpty(collection) ? null : collection.get(collection.size() - 1); }
public <T> MutableSet<T> withAll(HashingStrategy<? super T> hashingStrategy, Iterable<? extends T> items) { if (Iterate.isEmpty(items)) { return this.with(hashingStrategy); } return UnifiedSetWithHashingStrategy.newSet(hashingStrategy, items); } }
@Override public MutableList<T> withAll(Iterable<? extends T> elements) { if (Iterate.isEmpty(elements)) { return this; } return Lists.fixedSize.ofAll(this.toList().withAll(elements)); }
@Override public MutableList<T> withoutAll(Iterable<? extends T> elements) { if (Iterate.isEmpty(elements)) { return this; } return Lists.fixedSize.ofAll(this.toList().withoutAll(elements)); }
@Override public ArrayAdapter<T> withAll(Iterable<? extends T> elements) { if (Iterate.isEmpty(elements)) { return this; } return ArrayAdapter.newArray(this.toList().withAll(elements)); }
public MutableSet<T> withAll(Iterable<? extends T> elements) { if (Iterate.isEmpty(elements)) { return this; } return Sets.fixedSize.ofAll(this.toList().withAll(elements)); }
public MutableSet<T> withoutAll(Iterable<? extends T> elements) { if (Iterate.isEmpty(elements)) { return this; } return Sets.fixedSize.ofAll(this.toList().withoutAll(elements)); }
public <T> ImmutableSet<T> withAll(Iterable<? extends T> items) { if (items instanceof ImmutableSet<?>) { return (ImmutableSet<T>) items; } if (Iterate.isEmpty(items)) { return this.with(); } return this.with((T[]) Iterate.toArray(items)); } }
public <T> ImmutableList<T> withAll(Iterable<? extends T> items) { if (items instanceof ImmutableList<?>) { return (ImmutableList<T>) items; } if (items instanceof List && items instanceof RandomAccess) { return this.withList((List<T>) items); } if (Iterate.isEmpty(items)) { return this.empty(); } return this.of((T[]) Iterate.toArray(items)); } }
@Override public ArrayAdapter<T> withoutAll(Iterable<? extends T> elements) { if (Iterate.isEmpty(elements)) { return this; } if (Iterate.anySatisfyWith(elements, Predicates2.in(), this)) { return ArrayAdapter.newArray(this.toList().withoutAll(elements)); } return this; }
/** * Assert that the given {@link MutableMapIterable} is <em>not</em> empty. */ public static void assertNotEmpty(String mutableMapIterableName, MutableMapIterable<?, ?> actualMutableMapIterable) { try { Verify.assertObjectNotNull(mutableMapIterableName, actualMutableMapIterable); Assert.assertFalse(mutableMapIterableName + " should be non-empty, but was empty", Iterate.isEmpty(actualMutableMapIterable)); Assert.assertTrue(mutableMapIterableName + " should be non-empty, but was empty", Iterate.notEmpty(actualMutableMapIterable)); Assert.assertTrue(mutableMapIterableName + " should be non-empty, but was empty", actualMutableMapIterable.notEmpty()); Assert.assertNotEquals(mutableMapIterableName + " should be non-empty, but was empty", 0, actualMutableMapIterable.size()); Assert.assertNotEquals(mutableMapIterableName + " should be non-empty, but was empty", 0, actualMutableMapIterable.keySet().size()); Assert.assertNotEquals(mutableMapIterableName + " should be non-empty, but was empty", 0, actualMutableMapIterable.values().size()); Assert.assertNotEquals(mutableMapIterableName + " should be non-empty, but was empty", 0, actualMutableMapIterable.entrySet().size()); } catch (AssertionError e) { Verify.throwMangledException(e); } }
/** * Assert that the given {@link Iterable} is <em>not</em> empty. */ public static void assertNotEmpty(String iterableName, Iterable<?> actualIterable) { try { Verify.assertObjectNotNull(iterableName, actualIterable); Assert.assertFalse(iterableName + " should be non-empty, but was empty", Iterate.isEmpty(actualIterable)); Assert.assertTrue(iterableName + " should be non-empty, but was empty", Iterate.notEmpty(actualIterable)); Assert.assertNotEquals(iterableName + " should be non-empty, but was empty", 0, Iterate.sizeOf(actualIterable)); } catch (AssertionError e) { Verify.throwMangledException(e); } }
/** * Assert that the given {@link Iterable} is <em>not</em> empty. */ public static void assertIterableNotEmpty(String iterableName, Iterable<?> iterable) { try { Verify.assertObjectNotNull(iterableName, iterable); Assert.assertFalse(iterableName + " should be non-empty, but was empty", Iterate.isEmpty(iterable)); Assert.assertTrue(iterableName + " should be non-empty, but was empty", Iterate.notEmpty(iterable)); Assert.assertNotEquals(iterableName + " should be non-empty, but was empty", 0, Iterate.sizeOf(iterable)); } catch (AssertionError e) { Verify.throwMangledException(e); } }
public C replaceValues(K key, Iterable<? extends V> values) { if (Iterate.isEmpty(values)) { return this.removeAll(key); } C newValues = Iterate.addAllTo(values, this.createCollection()); C oldValues = this.map.put(key, newValues); oldValues = oldValues == null ? this.createCollection() : oldValues; this.addToTotalSize(newValues.size() - oldValues.size()); return (C) oldValues.asUnmodifiable(); }
/** * Assert that the given {@link Collection} is empty. */ public static void assertEmpty(String iterableName, Iterable<?> actualIterable) { try { Verify.assertObjectNotNull(iterableName, actualIterable); if (Iterate.notEmpty(actualIterable)) { Assert.fail(iterableName + " should be empty; actual size:<" + Iterate.sizeOf(actualIterable) + '>'); } if (!Iterate.isEmpty(actualIterable)) { Assert.fail(iterableName + " should be empty; actual size:<" + Iterate.sizeOf(actualIterable) + '>'); } if (Iterate.sizeOf(actualIterable) != 0) { Assert.fail(iterableName + " should be empty; actual size:<" + Iterate.sizeOf(actualIterable) + '>'); } } catch (AssertionError e) { Verify.throwMangledException(e); } }