Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.testing.IteratorFeature.MODIFIABLE;
import static java.util.Collections.emptyList;

import com.google.common.annotations.GwtCompatible;
import com.google.common.collect.ImmutableList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,12 @@ public long getWriteTimestamp() {
return writeTimestamp;
}

@Override
public boolean equals(Object o) {
return value.equals(o);
}

@Override
public int hashCode() {
return value.hashCode();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public boolean containsAll(Collection<?> targets) {
return delegate.containsAll(targets);
}

@Override
public int size() {
return delegate.size();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,22 @@ abstract class ForwardingImmutableList<E> extends ImmutableList<E> {

abstract List<E> delegateList();

@Override
public int indexOf(@Nullable Object object) {
return delegateList().indexOf(object);
}

@Override
public int lastIndexOf(@Nullable Object object) {
return delegateList().lastIndexOf(object);
}

@Override
public E get(int index) {
return delegateList().get(index);
}

@Override
public ImmutableList<E> subList(int fromIndex, int toIndex) {
return unsafeDelegateList(delegateList().subList(fromIndex, toIndex));
}
Expand Down Expand Up @@ -79,6 +83,7 @@ public boolean containsAll(Collection<?> targets) {
return delegateList().containsAll(targets);
}

@Override
public int size() {
return delegateList().size();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,27 @@ public abstract class ForwardingImmutableMap<K, V> extends ImmutableMap<K, V> {
this.delegate = Collections.unmodifiableMap(delegate);
}

@Override
boolean isPartialView() {
return false;
}

@Override
public final boolean isEmpty() {
return delegate.isEmpty();
}

@Override
public final boolean containsKey(@Nullable Object key) {
return Maps.safeContainsKey(delegate, key);
}

@Override
public final boolean containsValue(@Nullable Object value) {
return delegate.containsValue(value);
}

@Override
public @Nullable V get(@Nullable Object key) {
return (key == null) ? null : Maps.safeGet(delegate, key);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ public Builder<K, V> putAll(Iterable<? extends Entry<? extends K, ? extends V>>
}

@CanIgnoreReturnValue
@Override
public Builder<K, V> orderEntriesByValue(Comparator<? super V> valueComparator) {
super.orderEntriesByValue(valueComparator);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,36 +39,45 @@ public abstract class ImmutableCollection<E> extends AbstractCollection<E> imple

ImmutableCollection() {}

@Override
public abstract UnmodifiableIterator<E> iterator();

@Override
public boolean contains(@Nullable Object object) {
return object != null && super.contains(object);
}

@Override
public final boolean add(E e) {
throw new UnsupportedOperationException();
}

@Override
public final boolean remove(@Nullable Object object) {
throw new UnsupportedOperationException();
}

@Override
public final boolean addAll(Collection<? extends E> newElements) {
throw new UnsupportedOperationException();
}

@Override
public final boolean removeAll(Collection<?> oldElements) {
throw new UnsupportedOperationException();
}

@Override
public final boolean removeIf(Predicate<? super E> predicate) {
throw new UnsupportedOperationException();
}

@Override
public final boolean retainAll(Collection<?> elementsToKeep) {
throw new UnsupportedOperationException();
}

@Override
public final void clear() {
throw new UnsupportedOperationException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,18 +231,22 @@ public int lastIndexOf(@Nullable Object object) {
return (object == null) ? -1 : Lists.lastIndexOfImpl(this, object);
}

@Override
public final boolean addAll(int index, Collection<? extends E> newElements) {
throw new UnsupportedOperationException();
}

@Override
public final E set(int index, E element) {
throw new UnsupportedOperationException();
}

@Override
public final void add(int index, E element) {
throw new UnsupportedOperationException();
}

@Override
public final E remove(int index) {
throw new UnsupportedOperationException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,18 +402,22 @@ public static <K, V> ImmutableMap<K, V> copyOf(

abstract boolean isPartialView();

@Override
public final @Nullable V put(K k, V v) {
throw new UnsupportedOperationException();
}

@Override
public final @Nullable V remove(Object o) {
throw new UnsupportedOperationException();
}

@Override
public final void putAll(Map<? extends K, ? extends V> map) {
throw new UnsupportedOperationException();
}

@Override
public final void clear() {
throw new UnsupportedOperationException();
}
Expand All @@ -435,6 +439,7 @@ public boolean containsValue(@Nullable Object value) {

private transient @Nullable ImmutableSet<Entry<K, V>> cachedEntrySet = null;

@Override
public final ImmutableSet<Entry<K, V>> entrySet() {
if (cachedEntrySet != null) {
return cachedEntrySet;
Expand All @@ -446,6 +451,7 @@ public final ImmutableSet<Entry<K, V>> entrySet() {

private transient @Nullable ImmutableSet<K> cachedKeySet = null;

@Override
public ImmutableSet<K> keySet() {
if (cachedKeySet != null) {
return cachedKeySet;
Expand Down Expand Up @@ -478,6 +484,7 @@ Spliterator<K> keySpliterator() {

private transient @Nullable ImmutableCollection<V> cachedValues = null;

@Override
public ImmutableCollection<V> values() {
if (cachedValues != null) {
return cachedValues;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ public ImmutableList<E> asList() {
}
}

@Override
ImmutableList<E> createAsList() {
return new RegularImmutableAsList<E>(this, toArray());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,14 +418,17 @@ ImmutableSortedSet<K> createKeySet() {
return ImmutableSortedSet.copyOf(comparator, sortedDelegate.keySet());
}

@Override
public Comparator<? super K> comparator() {
return comparator;
}

@Override
public @Nullable K firstKey() {
return sortedDelegate.firstKey();
}

@Override
public @Nullable K lastKey() {
return sortedDelegate.lastKey();
}
Expand All @@ -441,6 +444,7 @@ public Comparator<? super K> comparator() {
return null;
}

@Override
public ImmutableSortedMap<K, V> headMap(K toKey) {
checkNotNull(toKey);
return newView(sortedDelegate.headMap(toKey));
Expand All @@ -458,6 +462,7 @@ ImmutableSortedMap<K, V> headMap(K toKey, boolean inclusive) {
return headMap(toKey);
}

@Override
public ImmutableSortedMap<K, V> subMap(K fromKey, K toKey) {
checkNotNull(fromKey);
checkNotNull(toKey);
Expand All @@ -472,6 +477,7 @@ ImmutableSortedMap<K, V> subMap(K fromKey, boolean fromInclusive, K toKey, boole
return tailMap(fromKey, fromInclusive).headMap(toKey, toInclusive);
}

@Override
public ImmutableSortedMap<K, V> tailMap(K fromKey) {
checkNotNull(fromKey);
return newView(sortedDelegate.tailMap(fromKey));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ static <E> ImmutableSortedSet<E> unsafeDelegateSortedSet(
this.sortedDelegate = Collections.unmodifiableSortedSet(sortedDelegate);
}

@Override
public Comparator<? super E> comparator() {
return sortedDelegate.comparator();
}
Expand Down Expand Up @@ -310,10 +311,12 @@ public boolean containsAll(Collection<?> targets) {
}
}

@Override
public E first() {
return sortedDelegate.first();
}

@Override
public ImmutableSortedSet<E> headSet(E toElement) {
checkNotNull(toElement);
try {
Expand Down Expand Up @@ -357,10 +360,12 @@ public ImmutableSortedSet<E> headSet(E toElement, boolean inclusive) {
return headSet(toElement);
}

@Override
public E last() {
return sortedDelegate.last();
}

@Override
public ImmutableSortedSet<E> subSet(E fromElement, E toElement) {
return subSet(fromElement, true, toElement, false);
}
Expand All @@ -377,6 +382,7 @@ ImmutableSortedSet<E> subSet(
return tailSet(fromElement, fromInclusive).headSet(toElement, toInclusive);
}

@Override
public ImmutableSortedSet<E> tailSet(E fromElement) {
checkNotNull(fromElement);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.testing.IteratorFeature.MODIFIABLE;
import static java.util.Collections.emptyList;

import com.google.common.annotations.GwtCompatible;
import com.google.common.collect.ImmutableList;
Expand Down
Loading