Skip to content

Commit

Permalink
Change ListSubject references to IterableSubject.
Browse files Browse the repository at this point in the history
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=82353185
  • Loading branch information
kluever authored and cpovirk committed Jan 9, 2015
1 parent 94c64c0 commit ad7a007
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 51 deletions.
Expand Up @@ -20,9 +20,6 @@

import java.util.List;

import javax.annotation.CheckReturnValue;
import javax.annotation.Nullable;

/**
* Type-specific extensions of {@link com.google.common.collect.Multimap} subjects for
* {@link com.google.common.collect.ListMultimap} subjects.
Expand All @@ -44,18 +41,6 @@ ListMultimapSubject<? extends ListMultimapSubject<?, K, V, M>, K, V, M> create(
return new ListMultimapSubject(failureStrategy, multimap);
}

/**
* {@inheritDoc}
*
* <p>This method returns a ListSubject instead of an IterableSubject to allow for more
* type-specific assertions.
*/
@CheckReturnValue
public ListSubject<? extends ListSubject<?, V, ? extends List<V>>, V,
? extends List<V>> valuesForKey(@Nullable K key) {
return new ListValuesForKey(failureStrategy, key, getSubject().get(key));
}

/**
* @deprecated {@code #isEqualTo} A SetMultimap can never compare equal with a ListMultimap if
* either Multimap is non-empty, because {@link java.util.Set} and {@link List} can never
Expand All @@ -67,22 +52,4 @@ ListMultimapSubject<? extends ListMultimapSubject<?, K, V, M>, K, V, M> create(
public void isEqualTo(SetMultimap<?, ?> other) {
super.isEqualTo(other);
}

private class ListValuesForKey extends ListSubject<ListValuesForKey, V, List<V>> {

private final K key;

ListValuesForKey(
FailureStrategy failureStrategy, K key, List<V> valuesForKey) {
super(failureStrategy, valuesForKey);
this.key = key;
}

@Override
protected String getDisplaySubject() {
return valuesForKeyDisplaySubject(key, this);
}

}

}
Expand Up @@ -92,7 +92,7 @@ private String typeNameFromInstance(Object instance) {
} catch (ClassCastException ignored) {}
}

public ListSubject<?, T, List<T>> asList() {
return ListSubject.create(failureStrategy, listRepresentation());
public IterableSubject<?, T, List<T>> asList() {
return IterableSubject.create(failureStrategy, listRepresentation());
}
}
Expand Up @@ -70,7 +70,7 @@ public class PrimitiveBooleanArraySubject
} catch (ClassCastException ignored) {}
}

public ListSubject<?, Boolean, List<Boolean>> asList() {
return ListSubject.create(failureStrategy, listRepresentation());
public IterableSubject<?, Boolean, List<Boolean>> asList() {
return IterableSubject.create(failureStrategy, listRepresentation());
}
}
Expand Up @@ -70,7 +70,7 @@ public class PrimitiveByteArraySubject
} catch (ClassCastException ignored) {}
}

public ListSubject<?, Byte, List<Byte>> asList() {
return ListSubject.create(failureStrategy, listRepresentation());
public IterableSubject<?, Byte, List<Byte>> asList() {
return IterableSubject.create(failureStrategy, listRepresentation());
}
}
Expand Up @@ -70,7 +70,7 @@ public class PrimitiveCharArraySubject
} catch (ClassCastException ignored) {}
}

public ListSubject<?, Character, List<Character>> asList() {
return ListSubject.create(failureStrategy, listRepresentation());
public IterableSubject<?, Character, List<Character>> asList() {
return IterableSubject.create(failureStrategy, listRepresentation());
}
}
Expand Up @@ -132,7 +132,7 @@ public void isNotEqualTo(Object expectedArray, double tolerance) {
// incorrect to simply treat a list of floats and do normal set operations that are
// based on bare comparisons.
@SuppressWarnings("unused")
private ListSubject<?, Double, List<Double>> asList() {
return ListSubject.create(failureStrategy, listRepresentation());
private IterableSubject<?, Double, List<Double>> asList() {
return IterableSubject.create(failureStrategy, listRepresentation());
}
}
Expand Up @@ -128,7 +128,7 @@ public void isNotEqualTo(Object expectedArray, float tolerance) {
// incorrect to simply treat a list of floats and do normal set operations that are
// based on bare comparisons.
@SuppressWarnings("unused")
private ListSubject<?, Float, List<Float>> asList() {
return ListSubject.create(failureStrategy, listRepresentation());
private IterableSubject<?, Float, List<Float>> asList() {
return IterableSubject.create(failureStrategy, listRepresentation());
}
}
Expand Up @@ -71,7 +71,7 @@ public class PrimitiveIntArraySubject
} catch (ClassCastException ignored) {}
}

public ListSubject<?, Integer, List<Integer>> asList() {
return ListSubject.create(failureStrategy, listRepresentation());
public IterableSubject<?, Integer, List<Integer>> asList() {
return IterableSubject.create(failureStrategy, listRepresentation());
}
}
Expand Up @@ -70,7 +70,7 @@ public class PrimitiveLongArraySubject
} catch (ClassCastException ignored) {}
}

public ListSubject<?, Long, List<Long>> asList() {
return ListSubject.create(failureStrategy, listRepresentation());
public IterableSubject<?, Long, List<Long>> asList() {
return IterableSubject.create(failureStrategy, listRepresentation());
}
}
2 changes: 0 additions & 2 deletions core/src/test/java/com/google/common/truth/MultimapTest.java
Expand Up @@ -24,7 +24,6 @@
import com.google.common.collect.ImmutableSetMultimap;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;

import org.junit.Test;
Expand Down Expand Up @@ -191,7 +190,6 @@ public class MultimapTest {
ImmutableListMultimap<Integer, String> multimap = ImmutableListMultimap.of(
3, "one", 3, "six", 3, "two", 4, "five", 4, "four");

assertThat(multimap).valuesForKey(3).containsSequence(Lists.newArrayList("one", "six"));
assertThat(multimap).valuesForKey(4).isOrdered();
}

Expand Down

0 comments on commit ad7a007

Please sign in to comment.