From 70e00d6d98136e00fd8c8482f89427b7e602c723 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 26 Mar 2016 09:51:39 +0000 Subject: Remove usages of Iterables.filter --- .../mammoth/tests/DeepReflectionMatcher.java | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src/test/java/org/zwobble/mammoth/tests/DeepReflectionMatcher.java') diff --git a/src/test/java/org/zwobble/mammoth/tests/DeepReflectionMatcher.java b/src/test/java/org/zwobble/mammoth/tests/DeepReflectionMatcher.java index dff85a8..19a8043 100644 --- a/src/test/java/org/zwobble/mammoth/tests/DeepReflectionMatcher.java +++ b/src/test/java/org/zwobble/mammoth/tests/DeepReflectionMatcher.java @@ -1,9 +1,11 @@ package org.zwobble.mammoth.tests; -import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; -import org.hamcrest.*; +import org.hamcrest.Description; +import org.hamcrest.Matcher; +import org.hamcrest.Matchers; +import org.hamcrest.TypeSafeDiagnosingMatcher; import java.lang.reflect.Field; import java.lang.reflect.Modifier; @@ -13,9 +15,9 @@ import java.util.Optional; import java.util.Set; import static com.google.common.collect.Iterables.any; -import static com.google.common.collect.Iterables.filter; import static java.util.Arrays.asList; import static org.zwobble.mammoth.internal.util.MammothIterables.lazyMap; +import static org.zwobble.mammoth.internal.util.MammothLists.eagerFilter; public class DeepReflectionMatcher extends TypeSafeDiagnosingMatcher { public static Matcher deepEquals(T value) { @@ -98,9 +100,9 @@ public class DeepReflectionMatcher extends TypeSafeDiagnosingMatcher { } private static boolean matchesSet(String path, Set expected, Set actual, Description mismatchDescription) { - List missing = ImmutableList.copyOf(filter( + List missing = eagerFilter( expected, - expectedElement -> !any(actual, actualElement -> deepEquals(expectedElement, actualElement)))); + expectedElement -> !any(actual, actualElement -> deepEquals(expectedElement, actualElement))); if (!missing.isEmpty()) { appendPath(mismatchDescription, path); @@ -109,9 +111,9 @@ public class DeepReflectionMatcher extends TypeSafeDiagnosingMatcher { return false; } - List extra = ImmutableList.copyOf(filter( + List extra = eagerFilter( actual, - actualElement -> !any(expected, expectedElement -> deepEquals(expectedElement, actualElement)))); + actualElement -> !any(expected, expectedElement -> deepEquals(expectedElement, actualElement))); if (!extra.isEmpty()) { appendPath(mismatchDescription, path); @@ -234,10 +236,10 @@ public class DeepReflectionMatcher extends TypeSafeDiagnosingMatcher { return value.replaceAll("\n", "\n "); } - private static ImmutableList fields(Class clazz) { - return ImmutableList.copyOf(filter( + private static List fields(Class clazz) { + return eagerFilter( asList(clazz.getDeclaredFields()), - field -> !Modifier.isStatic(field.getModifiers()))); + field -> !Modifier.isStatic(field.getModifiers())); } private static Object readField(Object obj, Field field) { -- cgit v1.2.3