diff options
Diffstat (limited to 'abi-check-plugin/src/main/java/com/yahoo/abicheck/setmatcher/SetMatcher.java')
-rw-r--r-- | abi-check-plugin/src/main/java/com/yahoo/abicheck/setmatcher/SetMatcher.java | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/abi-check-plugin/src/main/java/com/yahoo/abicheck/setmatcher/SetMatcher.java b/abi-check-plugin/src/main/java/com/yahoo/abicheck/setmatcher/SetMatcher.java index 037e42d04e7..f34cd3121e4 100644 --- a/abi-check-plugin/src/main/java/com/yahoo/abicheck/setmatcher/SetMatcher.java +++ b/abi-check-plugin/src/main/java/com/yahoo/abicheck/setmatcher/SetMatcher.java @@ -1,27 +1,32 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.abicheck.setmatcher; -import com.google.common.collect.Sets; +import java.util.HashSet; import java.util.Set; import java.util.function.Consumer; import java.util.function.Predicate; +import static java.util.function.Predicate.not; + public class SetMatcher { public static <T> boolean compare(Set<T> expected, Set<T> actual, Predicate<T> itemsMatch, Consumer<T> onMissing, Consumer<T> onExtra) { boolean mismatch = false; - Set<T> missing = Sets.difference(expected, actual); + Set<T> missing = new HashSet<>(expected); + missing.removeIf(actual::contains); for (T item : missing) { mismatch = true; onMissing.accept(item); } - Set<T> extra = Sets.difference(actual, expected); + Set<T> extra = new HashSet<>(actual); + extra.removeIf(expected::contains); for (T item : extra) { mismatch = true; onExtra.accept(item); } - Set<T> both = Sets.intersection(actual, expected); + Set<T> both = new HashSet<>(actual); + both.removeIf(not(expected::contains)); for (T item : both) { if (!itemsMatch.test(item)) { mismatch = true; |