diff options
author | jonmv <venstad@gmail.com> | 2022-10-21 13:39:05 +0200 |
---|---|---|
committer | jonmv <venstad@gmail.com> | 2022-10-21 13:39:05 +0200 |
commit | fe4c6158a9d9a33cbe6024916bf96dd7474fc391 (patch) | |
tree | ac8a9a66c6e79ed6338135d5529d5616f4fca4f2 /abi-check-plugin | |
parent | 60149c673b244d27f0c7af00f1015479ed611cb0 (diff) |
Replace guava dependency with a couple of set operations
Diffstat (limited to 'abi-check-plugin')
-rw-r--r-- | abi-check-plugin/pom.xml | 5 | ||||
-rw-r--r-- | abi-check-plugin/src/main/java/com/yahoo/abicheck/setmatcher/SetMatcher.java | 13 |
2 files changed, 9 insertions, 9 deletions
diff --git a/abi-check-plugin/pom.xml b/abi-check-plugin/pom.xml index d24765a5f88..253bf8e0a60 100644 --- a/abi-check-plugin/pom.xml +++ b/abi-check-plugin/pom.xml @@ -35,11 +35,6 @@ <artifactId>asm</artifactId> </dependency> <dependency> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - <version>29.0-jre</version> - </dependency> - <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>${gson.version}</version> 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; |