diff --git a/algorithms/active/aaar/pom.xml b/algorithms/active/aaar/pom.xml index d17520d8da..bdcedce54e 100644 --- a/algorithms/active/aaar/pom.xml +++ b/algorithms/active/aaar/pom.xml @@ -42,11 +42,6 @@ limitations under the License. - - com.google.guava - guava - - net.automatalib automata-api diff --git a/algorithms/active/aaar/src/main/java/de/learnlib/algorithm/aaar/explicit/AbstractExplicitAAARLearner.java b/algorithms/active/aaar/src/main/java/de/learnlib/algorithm/aaar/explicit/AbstractExplicitAAARLearner.java index 6fc06c6a31..6dc3edb5c4 100644 --- a/algorithms/active/aaar/src/main/java/de/learnlib/algorithm/aaar/explicit/AbstractExplicitAAARLearner.java +++ b/algorithms/active/aaar/src/main/java/de/learnlib/algorithm/aaar/explicit/AbstractExplicitAAARLearner.java @@ -17,12 +17,12 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.function.Function; -import com.google.common.collect.Maps; import de.learnlib.algorithm.LearnerConstructor; import de.learnlib.algorithm.LearningAlgorithm; import de.learnlib.algorithm.aaar.AbstractAAARLearner; @@ -34,6 +34,7 @@ import net.automatalib.alphabet.Alphabet; import net.automatalib.alphabet.SupportsGrowingAlphabet; import net.automatalib.alphabet.impl.Alphabets; +import net.automatalib.common.util.HashUtil; /** * An "explicit" refinement of the {@link AbstractAAARLearner}. This implementation requires a prior partition of (all) @@ -83,7 +84,7 @@ public AbstractExplicitAAARLearner(LearnerConstructor learnerConstruct super(learnerConstructor, oracle); this.explicitInitialAbstraction = explicitInitialAbstraction; - this.trees = Maps.newHashMapWithExpectedSize(explicitInitialAbstraction.getInitialAbstracts().size()); + this.trees = new HashMap<>(HashUtil.capacity(explicitInitialAbstraction.getInitialAbstracts().size())); for (AI a : explicitInitialAbstraction.getInitialAbstracts()) { final CI rep = explicitInitialAbstraction.getRepresentative(a); diff --git a/algorithms/active/aaar/src/main/java/module-info.java b/algorithms/active/aaar/src/main/java/module-info.java index 1995b07f62..16b6493ff7 100644 --- a/algorithms/active/aaar/src/main/java/module-info.java +++ b/algorithms/active/aaar/src/main/java/module-info.java @@ -30,7 +30,6 @@ */ open module de.learnlib.algorithm.aaar { - requires com.google.common; requires de.learnlib.api; requires net.automatalib.api; requires net.automatalib.common.util; diff --git a/algorithms/active/aaar/src/test/java/de/learnlib/algorithm/aaar/AbstractAAARTest.java b/algorithms/active/aaar/src/test/java/de/learnlib/algorithm/aaar/AbstractAAARTest.java index 66a78eb28d..76c2502bc1 100644 --- a/algorithms/active/aaar/src/test/java/de/learnlib/algorithm/aaar/AbstractAAARTest.java +++ b/algorithms/active/aaar/src/test/java/de/learnlib/algorithm/aaar/AbstractAAARTest.java @@ -15,10 +15,9 @@ */ package de.learnlib.algorithm.aaar; -import java.util.ArrayList; import java.util.HashSet; +import java.util.List; -import com.google.common.collect.Lists; import de.learnlib.algorithm.LearningAlgorithm; import de.learnlib.oracle.MembershipOracle; import de.learnlib.oracle.equivalence.SampleSetEQOracle; @@ -28,6 +27,7 @@ import net.automatalib.alphabet.Alphabet; import net.automatalib.automaton.UniversalDeterministicAutomaton; import net.automatalib.automaton.concept.SuffixOutput; +import net.automatalib.common.util.collection.IteratorUtil; import net.automatalib.util.automaton.Automata; import net.automatalib.util.automaton.conformance.WpMethodTestsIterator; import net.automatalib.word.Word; @@ -50,7 +50,7 @@ public AbstractAAARTest(LearningExample learningExample) { public void testAbstractHypothesisEquivalence() { final WpMethodTestsIterator iter = new WpMethodTestsIterator<>(automaton, alphabet); - final ArrayList> testCases = Lists.newArrayList(iter); + final List> testCases = IteratorUtil.list(iter); final SampleSetEQOracle eqo = new SampleSetEQOracle<>(false); eqo.addAll(new SimulatorOracle<>(automaton), testCases); diff --git a/algorithms/active/aaar/src/test/java/de/learnlib/algorithm/aaar/generic/GenericAAARLearnerDFATest.java b/algorithms/active/aaar/src/test/java/de/learnlib/algorithm/aaar/generic/GenericAAARLearnerDFATest.java index b8c9a37581..3abefda4bb 100644 --- a/algorithms/active/aaar/src/test/java/de/learnlib/algorithm/aaar/generic/GenericAAARLearnerDFATest.java +++ b/algorithms/active/aaar/src/test/java/de/learnlib/algorithm/aaar/generic/GenericAAARLearnerDFATest.java @@ -21,7 +21,6 @@ import java.io.Writer; import java.util.function.Function; -import com.google.common.io.CharStreams; import de.learnlib.algorithm.aaar.AAARTestUtil; import de.learnlib.algorithm.aaar.AbstractAAARTest; import de.learnlib.algorithm.aaar.abstraction.AbstractAbstractionTree; @@ -59,7 +58,7 @@ public void testTreeSerialization() throws IOException { try (Reader r = IOUtil.asBufferedUTF8Reader(GenericAAARLearnerDFATest.class.getResourceAsStream("/tree_dfa.dot")); Writer w = new StringWriter()) { - final String expected = CharStreams.toString(r); + final String expected = IOUtil.toString(r); GraphDOT.write((GraphViewable) tree, w); Assert.assertEquals(w.toString(), expected); diff --git a/algorithms/active/aaar/src/test/java/de/learnlib/algorithm/aaar/generic/GenericAAARLearnerMealyTest.java b/algorithms/active/aaar/src/test/java/de/learnlib/algorithm/aaar/generic/GenericAAARLearnerMealyTest.java index 20cf8106be..52a9e349d5 100644 --- a/algorithms/active/aaar/src/test/java/de/learnlib/algorithm/aaar/generic/GenericAAARLearnerMealyTest.java +++ b/algorithms/active/aaar/src/test/java/de/learnlib/algorithm/aaar/generic/GenericAAARLearnerMealyTest.java @@ -21,7 +21,6 @@ import java.io.Writer; import java.util.function.Function; -import com.google.common.io.CharStreams; import de.learnlib.algorithm.aaar.AAARTestUtil; import de.learnlib.algorithm.aaar.AbstractAAARTest; import de.learnlib.algorithm.aaar.abstraction.AbstractAbstractionTree; @@ -63,7 +62,7 @@ public void testTreeSerialization() throws IOException { "/tree_mealy.dot")); Writer w = new StringWriter()) { - final String expected = CharStreams.toString(r); + final String expected = IOUtil.toString(r); GraphDOT.write((GraphViewable) tree, w); Assert.assertEquals(w.toString(), expected); diff --git a/algorithms/active/aaar/src/test/java/de/learnlib/algorithm/aaar/generic/GenericAAARLearnerMooreTest.java b/algorithms/active/aaar/src/test/java/de/learnlib/algorithm/aaar/generic/GenericAAARLearnerMooreTest.java index e63d0b6f23..0fefab5173 100644 --- a/algorithms/active/aaar/src/test/java/de/learnlib/algorithm/aaar/generic/GenericAAARLearnerMooreTest.java +++ b/algorithms/active/aaar/src/test/java/de/learnlib/algorithm/aaar/generic/GenericAAARLearnerMooreTest.java @@ -22,7 +22,6 @@ import java.util.Random; import java.util.function.Function; -import com.google.common.io.CharStreams; import de.learnlib.algorithm.LearningAlgorithm.MooreLearner; import de.learnlib.algorithm.aaar.AAARTestUtil; import de.learnlib.algorithm.aaar.AbstractAAARTest; @@ -76,7 +75,7 @@ public void testTreeSerialization() throws IOException { "/tree_moore.dot")); Writer w = new StringWriter()) { - final String expected = CharStreams.toString(r); + final String expected = IOUtil.toString(r); GraphDOT.write((GraphViewable) tree, w); Assert.assertEquals(w.toString(), expected); diff --git a/algorithms/active/adt/pom.xml b/algorithms/active/adt/pom.xml index c514e0ca4b..2b8000b280 100644 --- a/algorithms/active/adt/pom.xml +++ b/algorithms/active/adt/pom.xml @@ -50,11 +50,6 @@ limitations under the License. - - com.google.guava - guava - - net.automatalib automata-api diff --git a/algorithms/active/adt/src/main/java/de/learnlib/algorithm/adt/config/model/replacer/ExhaustiveReplacer.java b/algorithms/active/adt/src/main/java/de/learnlib/algorithm/adt/config/model/replacer/ExhaustiveReplacer.java index afe4f81eaf..b7738a056d 100644 --- a/algorithms/active/adt/src/main/java/de/learnlib/algorithm/adt/config/model/replacer/ExhaustiveReplacer.java +++ b/algorithms/active/adt/src/main/java/de/learnlib/algorithm/adt/config/model/replacer/ExhaustiveReplacer.java @@ -22,7 +22,6 @@ import java.util.PriorityQueue; import java.util.Set; -import com.google.common.collect.Sets; import de.learnlib.algorithm.adt.adt.ADT; import de.learnlib.algorithm.adt.adt.ADTNode; import de.learnlib.algorithm.adt.api.SubtreeReplacer; @@ -31,6 +30,7 @@ import de.learnlib.algorithm.adt.util.ADTUtil; import net.automatalib.alphabet.Alphabet; import net.automatalib.automaton.transducer.MealyMachine; +import net.automatalib.common.util.HashUtil; public class ExhaustiveReplacer implements SubtreeReplacer { @@ -62,7 +62,7 @@ public Set> computeReplacements(MealyMachin final PriorityQueue> queue = new PriorityQueue<>(candidates.size(), Comparator.comparingInt(Set::size)); for (ADTNode node : candidates) { final Set> leaves = ADTUtil.collectLeaves(node); - final Set set = Sets.newHashSetWithExpectedSize(leaves.size()); + final Set set = new HashSet<>(HashUtil.capacity(leaves.size())); for (ADTNode l : leaves) { set.add(l.getHypothesisState()); diff --git a/algorithms/active/adt/src/main/java/de/learnlib/algorithm/adt/config/model/replacer/SingleReplacer.java b/algorithms/active/adt/src/main/java/de/learnlib/algorithm/adt/config/model/replacer/SingleReplacer.java index ea7d7179f8..2abab9e849 100644 --- a/algorithms/active/adt/src/main/java/de/learnlib/algorithm/adt/config/model/replacer/SingleReplacer.java +++ b/algorithms/active/adt/src/main/java/de/learnlib/algorithm/adt/config/model/replacer/SingleReplacer.java @@ -24,7 +24,6 @@ import java.util.Optional; import java.util.Set; -import com.google.common.collect.Maps; import de.learnlib.algorithm.adt.adt.ADT; import de.learnlib.algorithm.adt.adt.ADTNode; import de.learnlib.algorithm.adt.api.SubtreeReplacer; @@ -34,6 +33,7 @@ import net.automatalib.alphabet.Alphabet; import net.automatalib.automaton.transducer.MealyMachine; import net.automatalib.common.smartcollection.ReflexiveMapView; +import net.automatalib.common.util.Pair; import net.automatalib.word.Word; import org.checkerframework.checker.nullness.qual.Nullable; @@ -52,17 +52,18 @@ public Set> computeReplacements(MealyMachin final Set> candidates = ADTUtil.collectADSNodes(adt.getRoot()); candidates.remove(adt.getRoot()); - final Map, Double> candidatesScore = Maps.toMap(candidates, node -> { - final int resets = 1 + ADTUtil.collectResetNodes(node).size(); - final int finals = ADTUtil.collectLeaves(node).size(); - return resets / (double) finals; - }); - - final List> sortedCandidates = new ArrayList<>(candidates); - sortedCandidates.sort(Comparator.comparingDouble(candidatesScore::get)); + // cache scores to prevent expensive recalculations during sorting + final List, Double>> sortedCandidates = new ArrayList<>(candidates.size()); + for (ADTNode candidate : candidates) { + final int resets = 1 + ADTUtil.collectResetNodes(candidate).size(); + final int leaves = ADTUtil.collectLeaves(candidate).size(); + sortedCandidates.add(Pair.of(candidate, resets / (double) leaves)); + } + sortedCandidates.sort(Comparator.comparingDouble(Pair::getSecond)); - for (ADTNode node : sortedCandidates) { + for (Pair, Double> candidate : sortedCandidates) { + final ADTNode node = candidate.getFirst(); final Set targetStates = ADTUtil.collectHypothesisStates(node); // check if we can extendLeaf the parent ADS diff --git a/algorithms/active/adt/src/main/java/module-info.java b/algorithms/active/adt/src/main/java/module-info.java index 6a594c8686..2b0b52ed0d 100644 --- a/algorithms/active/adt/src/main/java/module-info.java +++ b/algorithms/active/adt/src/main/java/module-info.java @@ -30,7 +30,6 @@ */ open module de.learnlib.algorithm.adt { - requires com.google.common; requires de.learnlib.api; requires de.learnlib.common.counterexample; requires de.learnlib.common.util; diff --git a/algorithms/active/dhc/pom.xml b/algorithms/active/dhc/pom.xml index a990fe1169..88a3ddc0f9 100644 --- a/algorithms/active/dhc/pom.xml +++ b/algorithms/active/dhc/pom.xml @@ -46,11 +46,6 @@ limitations under the License. - - com.google.guava - guava - - net.automatalib automata-api diff --git a/algorithms/active/dhc/src/main/java/de/learnlib/algorithm/dhc/mealy/MealyDHC.java b/algorithms/active/dhc/src/main/java/de/learnlib/algorithm/dhc/mealy/MealyDHC.java index a5481d8a0a..854c060bd8 100644 --- a/algorithms/active/dhc/src/main/java/de/learnlib/algorithm/dhc/mealy/MealyDHC.java +++ b/algorithms/active/dhc/src/main/java/de/learnlib/algorithm/dhc/mealy/MealyDHC.java @@ -27,9 +27,6 @@ import java.util.Queue; import java.util.Set; -import com.google.common.collect.Interner; -import com.google.common.collect.Interners; -import com.google.common.collect.Sets; import de.learnlib.AccessSequenceTransformer; import de.learnlib.Resumable; import de.learnlib.algorithm.GlobalSuffixLearner.GlobalSuffixLearnerMealy; @@ -42,6 +39,7 @@ import net.automatalib.alphabet.Alphabet; import net.automatalib.alphabet.SupportsGrowingAlphabet; import net.automatalib.automaton.transducer.impl.CompactMealy; +import net.automatalib.common.util.HashUtil; import net.automatalib.common.util.mapping.MapMapping; import net.automatalib.common.util.mapping.MutableMapping; import net.automatalib.word.Word; @@ -157,8 +155,6 @@ public void startLearning() { // first element to be explored represents the initial state with no predecessor queue.add(new QueueElement<>(null, null, null, null)); - Interner> deduplicator = Interners.newStrongInterner(); - while (!queue.isEmpty()) { // get element to be explored from queue @SuppressWarnings("nullness") // false positive https://github.com/typetools/checker-framework/issues/399 @@ -179,7 +175,7 @@ public void startLearning() { // assemble output signature List> sig = new ArrayList<>(splitters.size()); for (DefaultQuery> query : queries) { - sig.add(deduplicator.intern(query.getOutput())); + sig.add(query.getOutput()); } Integer sibling = signatures.get(sig); @@ -257,7 +253,7 @@ public void addAlphabetSymbol(I symbol) { if (!this.splitters.contains(Word.fromLetter(symbol))) { final Iterator> splitterIterator = this.splitters.iterator(); final LinkedHashSet> newSplitters = - Sets.newLinkedHashSetWithExpectedSize(this.splitters.size() + 1); + new LinkedHashSet<>(HashUtil.capacity(this.splitters.size() + 1)); // see initial initialization of the splitters for (int i = 0; i < this.alphabet.size() - 1; i++) { diff --git a/algorithms/active/dhc/src/main/java/de/learnlib/algorithm/dhc/mealy/MealyDHCState.java b/algorithms/active/dhc/src/main/java/de/learnlib/algorithm/dhc/mealy/MealyDHCState.java index f3ced0f6f9..51c381b36d 100644 --- a/algorithms/active/dhc/src/main/java/de/learnlib/algorithm/dhc/mealy/MealyDHCState.java +++ b/algorithms/active/dhc/src/main/java/de/learnlib/algorithm/dhc/mealy/MealyDHCState.java @@ -15,11 +15,12 @@ */ package de.learnlib.algorithm.dhc.mealy; +import java.util.HashMap; import java.util.Map; import java.util.Set; -import com.google.common.collect.Maps; import net.automatalib.automaton.transducer.impl.CompactMealy; +import net.automatalib.common.util.HashUtil; import net.automatalib.common.util.mapping.MutableMapping; import net.automatalib.word.Word; @@ -42,7 +43,7 @@ public class MealyDHCState { MutableMapping> accessSequences) { this.splitters = splitters; this.hypothesis = hypothesis; - this.accessSequences = Maps.newHashMapWithExpectedSize(hypothesis.size()); + this.accessSequences = new HashMap<>(HashUtil.capacity(hypothesis.size())); for (Integer s : hypothesis.getStates()) { final MealyDHC.QueueElement elem = accessSequences.get(s); diff --git a/algorithms/active/dhc/src/main/java/module-info.java b/algorithms/active/dhc/src/main/java/module-info.java index b7eea4d3a6..6035bf691d 100644 --- a/algorithms/active/dhc/src/main/java/module-info.java +++ b/algorithms/active/dhc/src/main/java/module-info.java @@ -30,7 +30,6 @@ */ open module de.learnlib.algorithm.dhc { - requires com.google.common; requires de.learnlib.api; requires de.learnlib.common.counterexample; requires net.automatalib.api; diff --git a/algorithms/active/kearns-vazirani/pom.xml b/algorithms/active/kearns-vazirani/pom.xml index 5c998b498d..31fc6b28c8 100644 --- a/algorithms/active/kearns-vazirani/pom.xml +++ b/algorithms/active/kearns-vazirani/pom.xml @@ -59,7 +59,7 @@ limitations under the License. net.automatalib - automata-commons-smartcollections + automata-commons-util net.automatalib diff --git a/algorithms/active/kearns-vazirani/src/main/java/de/learnlib/algorithm/kv/dfa/KearnsVaziraniDFA.java b/algorithms/active/kearns-vazirani/src/main/java/de/learnlib/algorithm/kv/dfa/KearnsVaziraniDFA.java index e355d776cf..0bab4e3f0d 100644 --- a/algorithms/active/kearns-vazirani/src/main/java/de/learnlib/algorithm/kv/dfa/KearnsVaziraniDFA.java +++ b/algorithms/active/kearns-vazirani/src/main/java/de/learnlib/algorithm/kv/dfa/KearnsVaziraniDFA.java @@ -40,7 +40,7 @@ import net.automatalib.alphabet.SupportsGrowingAlphabet; import net.automatalib.automaton.fsa.DFA; import net.automatalib.automaton.fsa.impl.CompactDFA; -import net.automatalib.common.smartcollection.ArrayStorage; +import net.automatalib.common.util.array.ArrayStorage; import net.automatalib.word.Word; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/algorithms/active/kearns-vazirani/src/main/java/module-info.java b/algorithms/active/kearns-vazirani/src/main/java/module-info.java index 621bd817b6..f901b87422 100644 --- a/algorithms/active/kearns-vazirani/src/main/java/module-info.java +++ b/algorithms/active/kearns-vazirani/src/main/java/module-info.java @@ -34,7 +34,7 @@ requires de.learnlib.common.util; requires de.learnlib.datastructure.discriminationtree; requires net.automatalib.api; - requires net.automatalib.common.smartcollection; + requires net.automatalib.common.util; requires net.automatalib.core; requires org.checkerframework.checker.qual; requires org.slf4j; diff --git a/algorithms/active/observation-pack-vpa/pom.xml b/algorithms/active/observation-pack-vpa/pom.xml index 8b5ca0bffc..3322b2ad9c 100644 --- a/algorithms/active/observation-pack-vpa/pom.xml +++ b/algorithms/active/observation-pack-vpa/pom.xml @@ -54,11 +54,6 @@ limitations under the License. - - com.google.guava - guava - - org.checkerframework checker-qual diff --git a/algorithms/active/observation-pack-vpa/src/main/java/de/learnlib/algorithm/observationpack/vpa/OPLearnerVPA.java b/algorithms/active/observation-pack-vpa/src/main/java/de/learnlib/algorithm/observationpack/vpa/OPLearnerVPA.java index 2739399e5a..fb6fbacce6 100644 --- a/algorithms/active/observation-pack-vpa/src/main/java/de/learnlib/algorithm/observationpack/vpa/OPLearnerVPA.java +++ b/algorithms/active/observation-pack-vpa/src/main/java/de/learnlib/algorithm/observationpack/vpa/OPLearnerVPA.java @@ -18,7 +18,6 @@ import java.util.ArrayList; import java.util.List; -import com.google.common.collect.Iterables; import de.learnlib.acex.AbstractBaseCounterexample; import de.learnlib.acex.AcexAnalyzer; import de.learnlib.algorithm.observationpack.vpa.hypothesis.AbstractHypTrans; @@ -32,6 +31,7 @@ import net.automatalib.automaton.vpa.SEVPA; import net.automatalib.automaton.vpa.StackContents; import net.automatalib.automaton.vpa.State; +import net.automatalib.common.util.collection.IterableUtil; import net.automatalib.word.Word; import net.automatalib.word.WordBuilder; import org.checkerframework.checker.nullness.qual.Nullable; @@ -134,7 +134,7 @@ protected class PrefixTransformAcex extends AbstractBaseCounterexample public PrefixTransformAcex(Word word, ContextPair context) { super(context.getSuffix().length() + 1); this.suffix = context.getSuffix(); - this.baseState = hypothesis.getState(Iterables.concat(context.getPrefix(), word)); + this.baseState = hypothesis.getState(IterableUtil.concat(context.getPrefix(), word)); } public State> getBaseState() { diff --git a/algorithms/active/observation-pack-vpa/src/main/java/de/learnlib/algorithm/observationpack/vpa/hypothesis/HypLoc.java b/algorithms/active/observation-pack-vpa/src/main/java/de/learnlib/algorithm/observationpack/vpa/hypothesis/HypLoc.java index 7bfab6d360..7edfbe6309 100644 --- a/algorithms/active/observation-pack-vpa/src/main/java/de/learnlib/algorithm/observationpack/vpa/hypothesis/HypLoc.java +++ b/algorithms/active/observation-pack-vpa/src/main/java/de/learnlib/algorithm/observationpack/vpa/hypothesis/HypLoc.java @@ -21,7 +21,7 @@ import de.learnlib.AccessSequenceProvider; import net.automatalib.alphabet.VPAlphabet; -import net.automatalib.common.smartcollection.ArrayStorage; +import net.automatalib.common.util.array.ArrayStorage; import net.automatalib.word.Word; /** diff --git a/algorithms/active/observation-pack-vpa/src/main/java/module-info.java b/algorithms/active/observation-pack-vpa/src/main/java/module-info.java index ca68f5d5eb..c453d4dc88 100644 --- a/algorithms/active/observation-pack-vpa/src/main/java/module-info.java +++ b/algorithms/active/observation-pack-vpa/src/main/java/module-info.java @@ -30,7 +30,6 @@ */ open module de.learnlib.algorithm.observationpack.vpa { - requires com.google.common; requires de.learnlib.api; requires de.learnlib.common.counterexample; requires de.learnlib.datastructure.discriminationtree; diff --git a/algorithms/active/observation-pack-vpa/src/test/java/de/learnlib/algorithm/observationpack/vpa/DTVisualizationTest.java b/algorithms/active/observation-pack-vpa/src/test/java/de/learnlib/algorithm/observationpack/vpa/DTVisualizationTest.java index 714ca03777..12564e854c 100644 --- a/algorithms/active/observation-pack-vpa/src/test/java/de/learnlib/algorithm/observationpack/vpa/DTVisualizationTest.java +++ b/algorithms/active/observation-pack-vpa/src/test/java/de/learnlib/algorithm/observationpack/vpa/DTVisualizationTest.java @@ -20,7 +20,6 @@ import java.io.StringWriter; import java.util.Random; -import com.google.common.io.CharStreams; import de.learnlib.acex.AcexAnalyzers; import de.learnlib.oracle.MembershipOracle.DFAMembershipOracle; import de.learnlib.oracle.equivalence.vpa.SimulatorEQOracle; @@ -78,7 +77,7 @@ public void testVisualizeDT() throws IOException { private String resourceAsString(String resourceName) throws IOException { try (InputStream is = getClass().getResourceAsStream(resourceName)) { assert is != null; - return CharStreams.toString(IOUtil.asBufferedUTF8Reader(is)); + return IOUtil.toString(IOUtil.asBufferedUTF8Reader(is)); } } } diff --git a/algorithms/active/observation-pack/pom.xml b/algorithms/active/observation-pack/pom.xml index a8f9096ba6..48354c4cb9 100644 --- a/algorithms/active/observation-pack/pom.xml +++ b/algorithms/active/observation-pack/pom.xml @@ -59,7 +59,7 @@ limitations under the License. net.automatalib - automata-commons-smartcollections + automata-commons-util diff --git a/algorithms/active/observation-pack/src/main/java/de/learnlib/algorithm/observationpack/hypothesis/HState.java b/algorithms/active/observation-pack/src/main/java/de/learnlib/algorithm/observationpack/hypothesis/HState.java index b7652d71b9..47b09e5dba 100644 --- a/algorithms/active/observation-pack/src/main/java/de/learnlib/algorithm/observationpack/hypothesis/HState.java +++ b/algorithms/active/observation-pack/src/main/java/de/learnlib/algorithm/observationpack/hypothesis/HState.java @@ -22,7 +22,7 @@ import java.util.List; import de.learnlib.datastructure.discriminationtree.model.AbstractWordBasedDTNode; -import net.automatalib.common.smartcollection.ResizingArrayStorage; +import net.automatalib.common.util.array.ResizingArrayStorage; import net.automatalib.word.Word; import net.automatalib.word.WordBuilder; import org.checkerframework.checker.nullness.qual.Nullable; diff --git a/algorithms/active/observation-pack/src/main/java/module-info.java b/algorithms/active/observation-pack/src/main/java/module-info.java index bf34927aa2..30e18da50f 100644 --- a/algorithms/active/observation-pack/src/main/java/module-info.java +++ b/algorithms/active/observation-pack/src/main/java/module-info.java @@ -34,7 +34,7 @@ requires de.learnlib.common.util; requires de.learnlib.datastructure.discriminationtree; requires net.automatalib.api; - requires net.automatalib.common.smartcollection; + requires net.automatalib.common.util; requires org.checkerframework.checker.qual; requires static de.learnlib.tooling.annotation; diff --git a/algorithms/active/procedural/pom.xml b/algorithms/active/procedural/pom.xml index 813616fb0b..dcddf34cf5 100644 --- a/algorithms/active/procedural/pom.xml +++ b/algorithms/active/procedural/pom.xml @@ -75,11 +75,6 @@ limitations under the License. - - com.google.guava - guava - - net.automatalib automata-api diff --git a/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/sba/MappingSBA.java b/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/sba/MappingSBA.java index 4689fe517e..4834b9fbcd 100644 --- a/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/sba/MappingSBA.java +++ b/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/sba/MappingSBA.java @@ -16,14 +16,15 @@ package de.learnlib.algorithm.procedural.sba; import java.util.Collection; +import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; -import com.google.common.collect.Maps; import de.learnlib.algorithm.procedural.SymbolWrapper; import net.automatalib.alphabet.ProceduralInputAlphabet; import net.automatalib.automaton.fsa.DFA; import net.automatalib.automaton.procedural.SBA; +import net.automatalib.common.util.HashUtil; import org.checkerframework.checker.nullness.qual.Nullable; class MappingSBA implements SBA { @@ -40,7 +41,7 @@ class MappingSBA implements SBA { this.delegate = delegate; final Map, DFA>> p = delegate.getProcedures(); - this.procedures = Maps.newHashMapWithExpectedSize(p.size()); + this.procedures = new HashMap<>(HashUtil.capacity(p.size())); for (Entry, DFA>> e : p.entrySet()) { procedures.put(e.getKey().getDelegate(), new DFAView<>(e.getValue())); diff --git a/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/sba/SBALearner.java b/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/sba/SBALearner.java index e42388b515..3a0fdbbbe4 100644 --- a/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/sba/SBALearner.java +++ b/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/sba/SBALearner.java @@ -17,6 +17,7 @@ import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Map.Entry; @@ -24,7 +25,6 @@ import java.util.Set; import java.util.function.Predicate; -import com.google.common.collect.Maps; import de.learnlib.AccessSequenceTransformer; import de.learnlib.acex.AbstractBaseCounterexample; import de.learnlib.acex.AcexAnalyzer; @@ -46,6 +46,7 @@ import net.automatalib.automaton.procedural.SBA; import net.automatalib.automaton.procedural.impl.EmptySBA; import net.automatalib.automaton.procedural.impl.StackSBA; +import net.automatalib.common.util.HashUtil; import net.automatalib.common.util.Pair; import net.automatalib.common.util.mapping.Mapping; import net.automatalib.util.automaton.Automata; @@ -96,8 +97,8 @@ public SBALearner(ProceduralInputAlphabet alphabet, this.analyzer = analyzer; this.atManager = atManager; - this.learners = Maps.newHashMapWithExpectedSize(this.alphabet.getNumCalls()); - this.mapping = Maps.newHashMapWithExpectedSize(this.alphabet.size()); + this.learners = new HashMap<>(HashUtil.capacity(this.alphabet.getNumCalls())); + this.mapping = new HashMap<>(HashUtil.capacity(this.alphabet.size())); for (I i : this.alphabet.getInternalAlphabet()) { final SymbolWrapper wrapper = new SymbolWrapper<>(i, true); @@ -172,7 +173,7 @@ public SBA getHypothesisModel() { final Map>> procedures = getSubModels(); final Map, DFA>> mappedProcedures = - Maps.newHashMapWithExpectedSize(procedures.size()); + new HashMap<>(HashUtil.capacity(procedures.size())); for (Entry>> e : procedures.entrySet()) { final SymbolWrapper w = this.mapping.get(e.getKey()); @@ -266,7 +267,7 @@ private boolean extractUsefulInformationFromCounterExample(DefaultQuery>> getSubModels() { - final Map>> subModels = Maps.newHashMapWithExpectedSize(this.learners.size()); + final Map>> subModels = new HashMap<>(HashUtil.capacity(this.learners.size())); for (Map.Entry entry : this.learners.entrySet()) { subModels.put(entry.getKey(), entry.getValue().getHypothesisModel()); diff --git a/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/sba/manager/DefaultATManager.java b/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/sba/manager/DefaultATManager.java index e888097e7f..8f123aa994 100644 --- a/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/sba/manager/DefaultATManager.java +++ b/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/sba/manager/DefaultATManager.java @@ -17,16 +17,17 @@ import java.util.Collection; import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import java.util.Set; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; import de.learnlib.AccessSequenceTransformer; import de.learnlib.algorithm.procedural.SymbolWrapper; import de.learnlib.algorithm.procedural.sba.ATManager; import net.automatalib.alphabet.ProceduralInputAlphabet; import net.automatalib.automaton.fsa.DFA; +import net.automatalib.common.util.HashUtil; import net.automatalib.common.util.Pair; import net.automatalib.word.Word; @@ -47,8 +48,8 @@ public class DefaultATManager implements ATManager { public DefaultATManager(ProceduralInputAlphabet alphabet) { this.alphabet = alphabet; - this.accessSequences = Maps.newHashMapWithExpectedSize(alphabet.getNumCalls()); - this.terminatingSequences = Maps.newHashMapWithExpectedSize(alphabet.getNumCalls()); + this.accessSequences = new HashMap<>(HashUtil.capacity(alphabet.getNumCalls())); + this.terminatingSequences = new HashMap<>(HashUtil.capacity(alphabet.getNumCalls())); } @Override @@ -65,8 +66,8 @@ public Word getTerminatingSequence(I procedure) { @Override public Pair, Set> scanPositiveCounterexample(Word input) { - final Set newCalls = Sets.newHashSetWithExpectedSize(alphabet.getNumCalls() - accessSequences.size()); - final Set newTerms = Sets.newHashSetWithExpectedSize(alphabet.getNumCalls() - terminatingSequences.size()); + final Set newCalls = new HashSet<>(HashUtil.capacity(alphabet.getNumCalls() - accessSequences.size())); + final Set newTerms = new HashSet<>(HashUtil.capacity(alphabet.getNumCalls() - terminatingSequences.size())); for (int i = 0; i < input.size(); i++) { final I sym = input.getSymbol(i); diff --git a/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/sba/manager/OptimizingATManager.java b/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/sba/manager/OptimizingATManager.java index 329354e726..1645e9f1a2 100644 --- a/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/sba/manager/OptimizingATManager.java +++ b/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/sba/manager/OptimizingATManager.java @@ -17,19 +17,20 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; import de.learnlib.AccessSequenceTransformer; import de.learnlib.algorithm.procedural.SymbolWrapper; import de.learnlib.algorithm.procedural.sba.ATManager; import net.automatalib.alphabet.ProceduralInputAlphabet; import net.automatalib.automaton.fsa.DFA; +import net.automatalib.common.util.HashUtil; import net.automatalib.common.util.Pair; import net.automatalib.util.automaton.cover.Covers; import net.automatalib.word.Word; @@ -54,8 +55,8 @@ public class OptimizingATManager implements ATManager { public OptimizingATManager(ProceduralInputAlphabet alphabet) { this.alphabet = alphabet; - this.accessSequences = Maps.newHashMapWithExpectedSize(alphabet.getNumCalls()); - this.terminatingSequences = Maps.newHashMapWithExpectedSize(alphabet.getNumCalls()); + this.accessSequences = new HashMap<>(HashUtil.capacity(alphabet.getNumCalls())); + this.terminatingSequences = new HashMap<>(HashUtil.capacity(alphabet.getNumCalls())); } @Override @@ -73,9 +74,9 @@ public Word getTerminatingSequence(I procedure) { @Override public Pair, Set> scanPositiveCounterexample(Word counterexample) { final Set newCalls = - Sets.newHashSetWithExpectedSize(this.alphabet.getNumCalls() - this.accessSequences.size()); + new HashSet<>(HashUtil.capacity(this.alphabet.getNumCalls() - this.accessSequences.size())); final Set newTerms = - Sets.newHashSetWithExpectedSize(this.alphabet.getNumCalls() - this.terminatingSequences.size()); + new HashSet<>(HashUtil.capacity(this.alphabet.getNumCalls() - this.terminatingSequences.size())); this.extractPotentialTerminatingSequences(counterexample, newTerms); this.extractPotentialAccessSequences(counterexample, newCalls); @@ -88,7 +89,7 @@ public Set scanProcedures(Map>> procedur Map>> providers, Collection> inputs) { - final Set newTS = Sets.newHashSetWithExpectedSize(procedures.size()); + final Set newTS = new HashSet<>(HashUtil.capacity(procedures.size())); if (!procedures.isEmpty()) { final SymbolWrapper returnSymbol = inputs.stream() diff --git a/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/spa/SPALearner.java b/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/spa/SPALearner.java index e6cafe869f..93a26f32ea 100644 --- a/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/spa/SPALearner.java +++ b/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/spa/SPALearner.java @@ -19,14 +19,14 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Deque; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.function.Predicate; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; import de.learnlib.AccessSequenceTransformer; import de.learnlib.acex.AbstractBaseCounterexample; import de.learnlib.acex.AcexAnalyzer; @@ -45,6 +45,7 @@ import net.automatalib.automaton.procedural.SPA; import net.automatalib.automaton.procedural.impl.EmptySPA; import net.automatalib.automaton.procedural.impl.StackSPA; +import net.automatalib.common.util.HashUtil; import net.automatalib.common.util.mapping.Mapping; import net.automatalib.word.Word; import net.automatalib.word.WordBuilder; @@ -92,8 +93,8 @@ public SPALearner(ProceduralInputAlphabet alphabet, this.analyzer = analyzer; this.atrManager = atrManager; - this.subLearners = Maps.newHashMapWithExpectedSize(this.alphabet.getNumCalls()); - this.activeAlphabet = Sets.newHashSetWithExpectedSize(alphabet.getNumCalls() + alphabet.getNumInternals()); + this.subLearners = new HashMap<>(HashUtil.capacity(this.alphabet.getNumCalls())); + this.activeAlphabet = new HashSet<>(HashUtil.capacity(alphabet.getNumCalls() + alphabet.getNumInternals())); this.activeAlphabet.addAll(alphabet.getInternalAlphabet()); } @@ -214,7 +215,7 @@ private boolean extractUsefulInformationFromCounterExample(DefaultQuery> getSubModels() { - final Map> subModels = Maps.newHashMapWithExpectedSize(this.subLearners.size()); + final Map> subModels = new HashMap<>(HashUtil.capacity(this.subLearners.size())); for (Map.Entry entry : this.subLearners.entrySet()) { subModels.put(entry.getKey(), entry.getValue().getHypothesisModel()); diff --git a/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/spa/manager/DefaultATRManager.java b/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/spa/manager/DefaultATRManager.java index 2dda0397f6..6dbd3f2006 100644 --- a/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/spa/manager/DefaultATRManager.java +++ b/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/spa/manager/DefaultATRManager.java @@ -16,15 +16,16 @@ package de.learnlib.algorithm.procedural.spa.manager; import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import java.util.Set; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; import de.learnlib.AccessSequenceTransformer; import de.learnlib.algorithm.procedural.spa.ATRManager; import net.automatalib.alphabet.ProceduralInputAlphabet; import net.automatalib.automaton.fsa.DFA; +import net.automatalib.common.util.HashUtil; import net.automatalib.word.Word; /** @@ -45,9 +46,9 @@ public class DefaultATRManager implements ATRManager { public DefaultATRManager(ProceduralInputAlphabet alphabet) { this.alphabet = alphabet; - this.accessSequences = Maps.newHashMapWithExpectedSize(alphabet.getNumCalls()); - this.returnSequences = Maps.newHashMapWithExpectedSize(alphabet.getNumCalls()); - this.terminatingSequences = Maps.newHashMapWithExpectedSize(alphabet.getNumCalls()); + this.accessSequences = new HashMap<>(HashUtil.capacity(alphabet.getNumCalls())); + this.returnSequences = new HashMap<>(HashUtil.capacity(alphabet.getNumCalls())); + this.terminatingSequences = new HashMap<>(HashUtil.capacity(alphabet.getNumCalls())); } @Override @@ -70,7 +71,7 @@ public Word getReturnSequence(I procedure) { @Override public Set scanPositiveCounterexample(Word input) { - final Set result = Sets.newHashSetWithExpectedSize(alphabet.getNumCalls() - accessSequences.size()); + final Set result = new HashSet<>(HashUtil.capacity(alphabet.getNumCalls() - accessSequences.size())); for (int i = 0; i < input.size(); i++) { final I sym = input.getSymbol(i); diff --git a/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/spa/manager/OptimizingATRManager.java b/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/spa/manager/OptimizingATRManager.java index 8c6c0bd819..3c13b3c43c 100644 --- a/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/spa/manager/OptimizingATRManager.java +++ b/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/spa/manager/OptimizingATRManager.java @@ -18,17 +18,18 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; -import com.google.common.collect.Streams; import de.learnlib.AccessSequenceTransformer; import de.learnlib.algorithm.procedural.spa.ATRManager; import net.automatalib.alphabet.ProceduralInputAlphabet; import net.automatalib.automaton.fsa.DFA; +import net.automatalib.common.util.HashUtil; +import net.automatalib.common.util.collection.IteratorUtil; import net.automatalib.util.automaton.cover.Covers; import net.automatalib.word.Word; import net.automatalib.word.WordBuilder; @@ -52,9 +53,9 @@ public class OptimizingATRManager implements ATRManager { public OptimizingATRManager(ProceduralInputAlphabet alphabet) { this.alphabet = alphabet; - this.accessSequences = Maps.newHashMapWithExpectedSize(alphabet.getNumCalls()); - this.returnSequences = Maps.newHashMapWithExpectedSize(alphabet.getNumCalls()); - this.terminatingSequences = Maps.newHashMapWithExpectedSize(alphabet.getNumCalls()); + this.accessSequences = new HashMap<>(HashUtil.capacity(alphabet.getNumCalls())); + this.returnSequences = new HashMap<>(HashUtil.capacity(alphabet.getNumCalls())); + this.terminatingSequences = new HashMap<>(HashUtil.capacity(alphabet.getNumCalls())); } @Override @@ -78,7 +79,7 @@ public Word getReturnSequence(I procedure) { @Override public Set scanPositiveCounterexample(Word input) { final Set newProcedures = - Sets.newHashSetWithExpectedSize(this.alphabet.getNumCalls() - this.terminatingSequences.size()); + new HashSet<>(HashUtil.capacity(this.alphabet.getNumCalls() - this.terminatingSequences.size())); this.extractPotentialTerminatingSequences(input, newProcedures); this.extractPotentialAccessAndReturnSequences(input); @@ -123,12 +124,12 @@ public void scanProcedures(Map> procedures, private @Nullable Word getShortestHypothesisTS(DFA hyp, AccessSequenceTransformer asTransformer, Collection inputs) { - return Streams.stream(Covers.stateCoverIterator(hyp, inputs)) - .filter(hyp::accepts) - .map(asTransformer::transformAccessSequence) - .map(as -> this.alphabet.expand(as, terminatingSequences::get)) - .min(Comparator.comparingInt(Word::size)) - .orElse(null); + return IteratorUtil.stream(Covers.stateCoverIterator(hyp, inputs)) + .filter(hyp::accepts) + .map(asTransformer::transformAccessSequence) + .map(as -> this.alphabet.expand(as, terminatingSequences::get)) + .min(Comparator.comparingInt(Word::size)) + .orElse(null); } private void optimizeSequences(Map> sequences) { diff --git a/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/spmm/MappingSPMM.java b/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/spmm/MappingSPMM.java index d5dde302d7..538fc973a9 100644 --- a/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/spmm/MappingSPMM.java +++ b/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/spmm/MappingSPMM.java @@ -16,14 +16,15 @@ package de.learnlib.algorithm.procedural.spmm; import java.util.Collection; +import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; -import com.google.common.collect.Maps; import de.learnlib.algorithm.procedural.SymbolWrapper; import net.automatalib.alphabet.ProceduralInputAlphabet; import net.automatalib.automaton.procedural.SPMM; import net.automatalib.automaton.transducer.MealyMachine; +import net.automatalib.common.util.HashUtil; import org.checkerframework.checker.nullness.qual.Nullable; class MappingSPMM implements SPMM { @@ -45,7 +46,7 @@ class MappingSPMM implements SPMM { this.delegate = delegate; final Map, MealyMachine, ?, O>> p = delegate.getProcedures(); - this.procedures = Maps.newHashMapWithExpectedSize(p.size()); + this.procedures = new HashMap<>(HashUtil.capacity(p.size())); for (Entry, MealyMachine, ?, O>> e : p.entrySet()) { procedures.put(e.getKey().getDelegate(), new MealyView<>(e.getValue())); diff --git a/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/spmm/SPMMLearner.java b/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/spmm/SPMMLearner.java index 922a71a1c4..3a96f4e628 100644 --- a/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/spmm/SPMMLearner.java +++ b/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/spmm/SPMMLearner.java @@ -17,6 +17,7 @@ import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; @@ -24,7 +25,6 @@ import java.util.Objects; import java.util.Set; -import com.google.common.collect.Maps; import de.learnlib.AccessSequenceTransformer; import de.learnlib.algorithm.LearnerConstructor; import de.learnlib.algorithm.LearningAlgorithm; @@ -43,6 +43,7 @@ import net.automatalib.automaton.procedural.impl.EmptySPMM; import net.automatalib.automaton.procedural.impl.StackSPMM; import net.automatalib.automaton.transducer.MealyMachine; +import net.automatalib.common.util.HashUtil; import net.automatalib.common.util.Pair; import net.automatalib.common.util.mapping.Mapping; import net.automatalib.util.automaton.Automata; @@ -97,8 +98,8 @@ public SPMMLearner(ProceduralInputAlphabet alphabet, this.learnerConstructors = learnerConstructors; this.atManager = atManager; - this.learners = Maps.newHashMapWithExpectedSize(this.alphabet.getNumCalls()); - this.mapping = Maps.newHashMapWithExpectedSize(this.alphabet.size()); + this.learners = new HashMap<>(HashUtil.capacity(this.alphabet.getNumCalls())); + this.mapping = new HashMap<>(HashUtil.capacity(this.alphabet.size())); for (I i : this.alphabet.getInternalAlphabet()) { final SymbolWrapper wrapper = new SymbolWrapper<>(i, true); @@ -173,7 +174,7 @@ private boolean refineHypothesisInternal(DefaultQuery> defaultQuery) final Map, ?, O>> procedures = getSubModels(); final Map, MealyMachine, ?, O>> mappedProcedures = - Maps.newHashMapWithExpectedSize(procedures.size()); + new HashMap<>(HashUtil.capacity(procedures.size())); for (Entry, ?, O>> e : procedures.entrySet()) { final SymbolWrapper w = this.mapping.get(e.getKey()); @@ -271,7 +272,7 @@ private boolean extractUsefulInformationFromCounterExample(DefaultQuery, ?, O>> getSubModels() { final Map, ?, O>> subModels = - Maps.newHashMapWithExpectedSize(this.learners.size()); + new HashMap<>(HashUtil.capacity(this.learners.size())); for (Map.Entry entry : this.learners.entrySet()) { subModels.put(entry.getKey(), entry.getValue().getHypothesisModel()); diff --git a/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/spmm/manager/DefaultATManager.java b/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/spmm/manager/DefaultATManager.java index c771c2a1e3..8f8f458b5e 100644 --- a/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/spmm/manager/DefaultATManager.java +++ b/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/spmm/manager/DefaultATManager.java @@ -17,18 +17,19 @@ import java.util.Collection; import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import java.util.Objects; import java.util.Set; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; import de.learnlib.AccessSequenceTransformer; import de.learnlib.algorithm.procedural.SymbolWrapper; import de.learnlib.algorithm.procedural.spmm.ATManager; import de.learnlib.query.DefaultQuery; import net.automatalib.alphabet.ProceduralInputAlphabet; import net.automatalib.automaton.transducer.MealyMachine; +import net.automatalib.common.util.HashUtil; import net.automatalib.common.util.Pair; import net.automatalib.word.Word; @@ -53,8 +54,8 @@ public DefaultATManager(ProceduralInputAlphabet inputAlphabet, O errorOutput) this.inputAlphabet = inputAlphabet; this.errorOutput = errorOutput; - this.accessSequences = Maps.newHashMapWithExpectedSize(inputAlphabet.getNumCalls()); - this.terminatingSequences = Maps.newHashMapWithExpectedSize(inputAlphabet.getNumCalls()); + this.accessSequences = new HashMap<>(HashUtil.capacity(inputAlphabet.getNumCalls())); + this.terminatingSequences = new HashMap<>(HashUtil.capacity(inputAlphabet.getNumCalls())); } @Override @@ -71,9 +72,9 @@ public Word getTerminatingSequence(I procedure) { @Override public Pair, Set> scanCounterexample(DefaultQuery> counterexample) { - final Set newCalls = Sets.newHashSetWithExpectedSize(inputAlphabet.getNumCalls() - accessSequences.size()); + final Set newCalls = new HashSet<>(HashUtil.capacity(inputAlphabet.getNumCalls() - accessSequences.size())); final Set newTerms = - Sets.newHashSetWithExpectedSize(inputAlphabet.getNumCalls() - terminatingSequences.size()); + new HashSet<>(HashUtil.capacity(inputAlphabet.getNumCalls() - terminatingSequences.size())); final Word input = counterexample.getInput(); final Word output = counterexample.getOutput(); diff --git a/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/spmm/manager/OptimizingATManager.java b/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/spmm/manager/OptimizingATManager.java index be6a3d9bf1..e2d34817a1 100644 --- a/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/spmm/manager/OptimizingATManager.java +++ b/algorithms/active/procedural/src/main/java/de/learnlib/algorithm/procedural/spmm/manager/OptimizingATManager.java @@ -17,6 +17,8 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -24,14 +26,13 @@ import java.util.Objects; import java.util.Set; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; import de.learnlib.AccessSequenceTransformer; import de.learnlib.algorithm.procedural.SymbolWrapper; import de.learnlib.algorithm.procedural.spmm.ATManager; import de.learnlib.query.DefaultQuery; import net.automatalib.alphabet.ProceduralInputAlphabet; import net.automatalib.automaton.transducer.MealyMachine; +import net.automatalib.common.util.HashUtil; import net.automatalib.common.util.Pair; import net.automatalib.util.automaton.cover.Covers; import net.automatalib.word.Word; @@ -59,8 +60,8 @@ public OptimizingATManager(ProceduralInputAlphabet inputAlphabet, O errorOutp this.inputAlphabet = inputAlphabet; this.errorOutput = errorOutput; - this.accessSequences = Maps.newHashMapWithExpectedSize(inputAlphabet.getNumCalls()); - this.terminatingSequences = Maps.newHashMapWithExpectedSize(inputAlphabet.getNumCalls()); + this.accessSequences = new HashMap<>(HashUtil.capacity(inputAlphabet.getNumCalls())); + this.terminatingSequences = new HashMap<>(HashUtil.capacity(inputAlphabet.getNumCalls())); } @Override @@ -78,9 +79,9 @@ public Word getTerminatingSequence(I procedure) { @Override public Pair, Set> scanCounterexample(DefaultQuery> counterexample) { final Set newCalls = - Sets.newHashSetWithExpectedSize(this.inputAlphabet.getNumCalls() - this.accessSequences.size()); + new HashSet<>(HashUtil.capacity(this.inputAlphabet.getNumCalls() - this.accessSequences.size())); final Set newTerms = - Sets.newHashSetWithExpectedSize(this.inputAlphabet.getNumCalls() - this.terminatingSequences.size()); + new HashSet<>(HashUtil.capacity(this.inputAlphabet.getNumCalls() - this.terminatingSequences.size())); this.extractPotentialTerminatingSequences(counterexample, newTerms); this.extractPotentialAccessSequences(counterexample, newCalls); @@ -93,7 +94,7 @@ public Set scanProcedures(Map, Map>> providers, Collection> inputs) { - final Set newTS = Sets.newHashSetWithExpectedSize(procedures.size()); + final Set newTS = new HashSet<>(HashUtil.capacity(procedures.size())); if (!procedures.isEmpty()) { final SymbolWrapper returnSymbol = inputs.stream() diff --git a/algorithms/active/procedural/src/main/java/module-info.java b/algorithms/active/procedural/src/main/java/module-info.java index 37d0de9e03..7dd90ea28a 100644 --- a/algorithms/active/procedural/src/main/java/module-info.java +++ b/algorithms/active/procedural/src/main/java/module-info.java @@ -31,7 +31,6 @@ */ open module de.learnlib.algorithm.procedural { - requires com.google.common; requires de.learnlib.algorithm.kv; requires de.learnlib.algorithm.lstar; requires de.learnlib.algorithm.observationpack; diff --git a/algorithms/active/ttt-vpa/pom.xml b/algorithms/active/ttt-vpa/pom.xml index be13b0d7d0..4c875feaf6 100644 --- a/algorithms/active/ttt-vpa/pom.xml +++ b/algorithms/active/ttt-vpa/pom.xml @@ -59,13 +59,12 @@ limitations under the License. - com.google.guava - guava + net.automatalib + automata-api - net.automatalib - automata-api + automata-commons-util diff --git a/algorithms/active/ttt-vpa/src/main/java/de/learnlib/algorithm/ttt/vpa/TTTLearnerVPA.java b/algorithms/active/ttt-vpa/src/main/java/de/learnlib/algorithm/ttt/vpa/TTTLearnerVPA.java index b326385b1e..f295d0fb1c 100644 --- a/algorithms/active/ttt-vpa/src/main/java/de/learnlib/algorithm/ttt/vpa/TTTLearnerVPA.java +++ b/algorithms/active/ttt-vpa/src/main/java/de/learnlib/algorithm/ttt/vpa/TTTLearnerVPA.java @@ -26,7 +26,6 @@ import java.util.Objects; import java.util.Set; -import com.google.common.collect.Iterables; import de.learnlib.acex.AcexAnalyzer; import de.learnlib.algorithm.observationpack.vpa.OPLearnerVPA; import de.learnlib.algorithm.observationpack.vpa.hypothesis.AbstractHypTrans; @@ -43,6 +42,7 @@ import net.automatalib.automaton.vpa.SEVPA; import net.automatalib.automaton.vpa.StackContents; import net.automatalib.automaton.vpa.State; +import net.automatalib.common.util.collection.CollectionUtil; import net.automatalib.word.Word; import org.checkerframework.checker.nullness.qual.Nullable; @@ -84,7 +84,7 @@ protected State> getDefinitiveSuccessor(State> baseState, Wo if (trans.isTree()) { succs.add(trans.getTreeTarget()); } else { - Iterables.addAll(succs, trans.getNonTreeTarget().subtreeLocations()); + CollectionUtil.add(succs, trans.getNonTreeTarget().subtreeLocsIterator()); } } } @@ -96,7 +96,7 @@ protected State> getDefinitiveSuccessor(State> baseState, Wo if (trans.isTree()) { succs.add(trans.getTreeTarget()); } else { - Iterables.addAll(succs, trans.getNonTreeTarget().subtreeLocations()); + CollectionUtil.add(succs, trans.getNonTreeTarget().subtreeLocsIterator()); } } curr = new NonDetState<>(succs, curr.getStack()); diff --git a/algorithms/active/ttt-vpa/src/main/java/module-info.java b/algorithms/active/ttt-vpa/src/main/java/module-info.java index 0c713c44b5..161cb3fe82 100644 --- a/algorithms/active/ttt-vpa/src/main/java/module-info.java +++ b/algorithms/active/ttt-vpa/src/main/java/module-info.java @@ -30,7 +30,6 @@ */ open module de.learnlib.algorithm.ttt.vpa { - requires com.google.common; requires de.learnlib.api; requires de.learnlib.algorithm.observationpack.vpa; requires de.learnlib.common.counterexample; @@ -39,6 +38,7 @@ requires org.checkerframework.checker.qual; requires static de.learnlib.tooling.annotation; + requires net.automatalib.common.util; exports de.learnlib.algorithm.ttt.vpa; } diff --git a/algorithms/active/ttt/pom.xml b/algorithms/active/ttt/pom.xml index a2bc118ce3..3346d33f57 100644 --- a/algorithms/active/ttt/pom.xml +++ b/algorithms/active/ttt/pom.xml @@ -58,11 +58,6 @@ limitations under the License. - - com.google.guava - guava - - net.automatalib automata-api @@ -71,6 +66,10 @@ limitations under the License. net.automatalib automata-commons-smartcollections + + net.automatalib + automata-commons-util + org.checkerframework diff --git a/algorithms/active/ttt/src/main/java/de/learnlib/algorithm/ttt/base/AbstractTTTLearner.java b/algorithms/active/ttt/src/main/java/de/learnlib/algorithm/ttt/base/AbstractTTTLearner.java index 81ae59d6d9..e82c900854 100644 --- a/algorithms/active/ttt/src/main/java/de/learnlib/algorithm/ttt/base/AbstractTTTLearner.java +++ b/algorithms/active/ttt/src/main/java/de/learnlib/algorithm/ttt/base/AbstractTTTLearner.java @@ -28,7 +28,6 @@ import java.util.Objects; import java.util.Set; -import com.google.common.collect.Iterators; import de.learnlib.AccessSequenceProvider; import de.learnlib.Resumable; import de.learnlib.acex.AcexAnalyzer; @@ -43,6 +42,7 @@ import net.automatalib.alphabet.SupportsGrowingAlphabet; import net.automatalib.common.smartcollection.ElementReference; import net.automatalib.common.smartcollection.UnorderedCollection; +import net.automatalib.common.util.collection.CollectionUtil; import net.automatalib.word.Word; import org.checkerframework.checker.nullness.qual.Nullable; import org.slf4j.Logger; @@ -344,7 +344,7 @@ protected Set> getNondetSuccessors(Collection tgtNode = trans.getNonTreeTarget(); - Iterators.addAll(result, tgtNode.subtreeStatesIterator()); + CollectionUtil.add(result, tgtNode.subtreeStatesIterator()); } } return result; diff --git a/algorithms/active/ttt/src/main/java/de/learnlib/algorithm/ttt/base/TTTState.java b/algorithms/active/ttt/src/main/java/de/learnlib/algorithm/ttt/base/TTTState.java index 0732ec433e..1613a8ad04 100644 --- a/algorithms/active/ttt/src/main/java/de/learnlib/algorithm/ttt/base/TTTState.java +++ b/algorithms/active/ttt/src/main/java/de/learnlib/algorithm/ttt/base/TTTState.java @@ -16,7 +16,7 @@ package de.learnlib.algorithm.ttt.base; import de.learnlib.AccessSequenceProvider; -import net.automatalib.common.smartcollection.ResizingArrayStorage; +import net.automatalib.common.util.array.ResizingArrayStorage; import net.automatalib.word.Word; /** diff --git a/algorithms/active/ttt/src/main/java/de/learnlib/algorithm/ttt/dfa/PrefixTTTLearnerDFA.java b/algorithms/active/ttt/src/main/java/de/learnlib/algorithm/ttt/dfa/PrefixTTTLearnerDFA.java index 332dbc17f9..e868dde40c 100644 --- a/algorithms/active/ttt/src/main/java/de/learnlib/algorithm/ttt/dfa/PrefixTTTLearnerDFA.java +++ b/algorithms/active/ttt/src/main/java/de/learnlib/algorithm/ttt/dfa/PrefixTTTLearnerDFA.java @@ -17,7 +17,6 @@ import java.util.Iterator; -import com.google.common.collect.AbstractIterator; import de.learnlib.acex.AbstractCounterexample; import de.learnlib.acex.AcexAnalyzer; import de.learnlib.algorithm.ttt.base.TTTState; @@ -25,7 +24,8 @@ import de.learnlib.oracle.MembershipOracle; import de.learnlib.query.DefaultQuery; import net.automatalib.alphabet.Alphabet; -import net.automatalib.common.smartcollection.ArrayStorage; +import net.automatalib.common.util.array.ArrayStorage; +import net.automatalib.common.util.collection.AbstractSimplifiedIterator; import net.automatalib.word.Word; public class PrefixTTTLearnerDFA extends TTTLearnerDFA { @@ -150,7 +150,7 @@ public Iterator> unlabeledIterator() { return new UnlabeledIterator<>(this); } - private static class UnlabeledIterator extends AbstractIterator> { + private static class UnlabeledIterator extends AbstractSimplifiedIterator> { private ExtDTNode curr; @@ -159,12 +159,13 @@ private static class UnlabeledIterator extends AbstractIterator> } @Override - protected ExtDTNode computeNext() { + protected boolean calculateNext() { curr = curr.nextUnlabeled; if (curr == null) { - return endOfData(); + return false; } - return curr; + super.nextValue = curr; + return true; } } } diff --git a/algorithms/active/ttt/src/main/java/module-info.java b/algorithms/active/ttt/src/main/java/module-info.java index a71384a597..179262dff6 100644 --- a/algorithms/active/ttt/src/main/java/module-info.java +++ b/algorithms/active/ttt/src/main/java/module-info.java @@ -30,7 +30,6 @@ */ open module de.learnlib.algorithm.ttt { - requires com.google.common; requires de.learnlib.api; requires de.learnlib.common.counterexample; requires de.learnlib.common.util; @@ -38,6 +37,7 @@ requires de.learnlib.datastructure.list; requires net.automatalib.api; requires net.automatalib.common.smartcollection; + requires net.automatalib.common.util; requires org.checkerframework.checker.qual; requires org.slf4j; diff --git a/algorithms/passive/ostia/pom.xml b/algorithms/passive/ostia/pom.xml index 7dda2bf371..5dca069871 100644 --- a/algorithms/passive/ostia/pom.xml +++ b/algorithms/passive/ostia/pom.xml @@ -62,12 +62,6 @@ limitations under the License. - - com.google.guava - guava - test - - de.learnlib.testsupport learnlib-learner-it-support diff --git a/algorithms/passive/ostia/src/test/java/de/learnlib/algorithm/ostia/OSTIATest.java b/algorithms/passive/ostia/src/test/java/de/learnlib/algorithm/ostia/OSTIATest.java index b2369ae77c..2261814900 100644 --- a/algorithms/passive/ostia/src/test/java/de/learnlib/algorithm/ostia/OSTIATest.java +++ b/algorithms/passive/ostia/src/test/java/de/learnlib/algorithm/ostia/OSTIATest.java @@ -26,8 +26,6 @@ import java.util.List; import java.util.Random; -import com.google.common.collect.Iterables; -import com.google.common.io.CharStreams; import net.automatalib.alphabet.Alphabet; import net.automatalib.alphabet.impl.Alphabets; import net.automatalib.automaton.transducer.SubsequentialTransducer; @@ -35,7 +33,8 @@ import net.automatalib.common.smartcollection.IntSeq; import net.automatalib.common.util.IOUtil; import net.automatalib.common.util.Pair; -import net.automatalib.common.util.collection.CollectionsUtil; +import net.automatalib.common.util.collection.CollectionUtil; +import net.automatalib.common.util.collection.IterableUtil; import net.automatalib.serialization.dot.GraphDOT; import net.automatalib.util.automaton.Automata; import net.automatalib.util.automaton.conformance.WMethodTestsIterator; @@ -104,11 +103,11 @@ public void testVisualization() throws IOException { final WordBuilder wb = new WordBuilder<>(); for (Pair p : getExampleSamples()) { - Iterables.addAll(wb, p.getFirst()); + CollectionUtil.add(wb, p.getFirst().iterator()); final Word input = wb.toWord(); wb.clear(); - Iterables.addAll(wb, p.getSecond()); + CollectionUtil.add(wb, p.getSecond().iterator()); final Word output = wb.toWord(); wb.clear(); @@ -120,7 +119,7 @@ public void testVisualization() throws IOException { try (InputStream is = getClass().getResourceAsStream("/hyp.dot")) { assert is != null; - expectedHyp = CharStreams.toString(IOUtil.asBufferedUTF8Reader(is)); + expectedHyp = IOUtil.toString(IOUtil.asBufferedUTF8Reader(is)); } final StringWriter actualHyp = new StringWriter(); @@ -136,7 +135,7 @@ public void testEquivalence(int size) { final CompactSST sst = new CompactSST<>(INPUTS); final List> words = new ArrayList<>(); - for (List t : CollectionsUtil.allTuples(OUTPUTS, 0, 3)) { + for (List t : IterableUtil.allTuples(OUTPUTS, 0, 3)) { words.add(Word.fromList(t)); } diff --git a/algorithms/passive/rpni/pom.xml b/algorithms/passive/rpni/pom.xml index c7dca4acbb..41dfbed0e4 100644 --- a/algorithms/passive/rpni/pom.xml +++ b/algorithms/passive/rpni/pom.xml @@ -50,11 +50,6 @@ limitations under the License. - - com.google.guava - guava - - net.automatalib automata-api diff --git a/algorithms/passive/rpni/src/main/java/de/learnlib/algorithm/rpni/EDSMUtil.java b/algorithms/passive/rpni/src/main/java/de/learnlib/algorithm/rpni/EDSMUtil.java index 6f9edf8359..65d629a6c2 100644 --- a/algorithms/passive/rpni/src/main/java/de/learnlib/algorithm/rpni/EDSMUtil.java +++ b/algorithms/passive/rpni/src/main/java/de/learnlib/algorithm/rpni/EDSMUtil.java @@ -16,12 +16,13 @@ package de.learnlib.algorithm.rpni; import java.util.Collection; +import java.util.HashMap; import java.util.List; import java.util.Map; -import com.google.common.collect.Maps; import net.automatalib.automaton.UniversalDeterministicAutomaton; import net.automatalib.common.smartcollection.IntSeq; +import net.automatalib.common.util.HashUtil; final class EDSMUtil { @@ -34,7 +35,7 @@ static long score(UniversalDeterministicAutomaton final Collection states = merge.getStates(); final int numStates = states.size(); // we don't use the regular stateIDs because we only want to collect all states once. - final Map stateIDs = Maps.newHashMapWithExpectedSize(numStates); + final Map stateIDs = new HashMap<>(HashUtil.capacity(numStates)); int counter = 0; for (S s : states) { diff --git a/algorithms/passive/rpni/src/main/java/module-info.java b/algorithms/passive/rpni/src/main/java/module-info.java index cf1419b7bc..dbf64f1492 100644 --- a/algorithms/passive/rpni/src/main/java/module-info.java +++ b/algorithms/passive/rpni/src/main/java/module-info.java @@ -34,7 +34,6 @@ */ open module de.learnlib.algorithm.rpni { - requires com.google.common; requires de.learnlib.api; requires de.learnlib.datastructure.pta; requires net.automatalib.api; diff --git a/commons/counterexamples/pom.xml b/commons/counterexamples/pom.xml index 241810cee5..f1848e8b00 100644 --- a/commons/counterexamples/pom.xml +++ b/commons/counterexamples/pom.xml @@ -44,7 +44,7 @@ limitations under the License. net.automatalib - automata-commons-smartcollections + automata-commons-util diff --git a/commons/counterexamples/src/main/java/de/learnlib/acex/AbstractBaseCounterexample.java b/commons/counterexamples/src/main/java/de/learnlib/acex/AbstractBaseCounterexample.java index 39127e1beb..3fde8b55b9 100644 --- a/commons/counterexamples/src/main/java/de/learnlib/acex/AbstractBaseCounterexample.java +++ b/commons/counterexamples/src/main/java/de/learnlib/acex/AbstractBaseCounterexample.java @@ -15,7 +15,7 @@ */ package de.learnlib.acex; -import net.automatalib.common.smartcollection.ArrayStorage; +import net.automatalib.common.util.array.ArrayStorage; import org.checkerframework.checker.initialization.qual.UnknownInitialization; public abstract class AbstractBaseCounterexample implements AbstractCounterexample { diff --git a/commons/counterexamples/src/main/java/module-info.java b/commons/counterexamples/src/main/java/module-info.java index 1c075f4b39..4af9efb501 100644 --- a/commons/counterexamples/src/main/java/module-info.java +++ b/commons/counterexamples/src/main/java/module-info.java @@ -30,7 +30,7 @@ requires de.learnlib.api; requires net.automatalib.api; - requires net.automatalib.common.smartcollection; + requires net.automatalib.common.util; requires org.checkerframework.checker.qual; exports de.learnlib.acex; diff --git a/datastructures/discrimination-tree/pom.xml b/datastructures/discrimination-tree/pom.xml index bea44bc030..a116db194b 100644 --- a/datastructures/discrimination-tree/pom.xml +++ b/datastructures/discrimination-tree/pom.xml @@ -42,19 +42,10 @@ limitations under the License. - - com.google.guava - guava - - net.automatalib automata-api - - net.automatalib - automata-commons-smartcollections - net.automatalib automata-commons-util diff --git a/datastructures/discrimination-tree/src/main/java/de/learnlib/datastructure/discriminationtree/iterators/DiscriminationTreeIterators.java b/datastructures/discrimination-tree/src/main/java/de/learnlib/datastructure/discriminationtree/iterators/DiscriminationTreeIterators.java index 89b5d7c5d4..671a962ce1 100644 --- a/datastructures/discrimination-tree/src/main/java/de/learnlib/datastructure/discriminationtree/iterators/DiscriminationTreeIterators.java +++ b/datastructures/discrimination-tree/src/main/java/de/learnlib/datastructure/discriminationtree/iterators/DiscriminationTreeIterators.java @@ -18,8 +18,8 @@ import java.util.Iterator; import java.util.function.Function; -import com.google.common.collect.Iterators; import de.learnlib.datastructure.discriminationtree.model.AbstractDTNode; +import net.automatalib.common.util.collection.IteratorUtil; /** * Factory methods for several kinds of discrimination tree node iterators. @@ -52,7 +52,7 @@ private DiscriminationTreeIterators() { */ @SuppressWarnings("nullness") // lambda is only called with our non-null nodes as argument public static > Iterator innerNodeIterator(N root) { - return Iterators.filter(nodeIterator(root), n -> !n.isLeaf()); + return IteratorUtil.filter(nodeIterator(root), n -> !n.isLeaf()); } /** @@ -64,7 +64,7 @@ private DiscriminationTreeIterators() { * node type */ public static > Iterator leafIterator(N root) { - return Iterators.filter(nodeIterator(root), AbstractDTNode::isLeaf); + return IteratorUtil.filter(nodeIterator(root), AbstractDTNode::isLeaf); } /** @@ -80,6 +80,6 @@ private DiscriminationTreeIterators() { */ public static , D> Iterator transformingLeafIterator(N root, Function transformer) { - return Iterators.transform(leafIterator(root), transformer::apply); + return IteratorUtil.map(leafIterator(root), transformer); } } diff --git a/datastructures/discrimination-tree/src/main/java/de/learnlib/datastructure/discriminationtree/iterators/NodeIterator.java b/datastructures/discrimination-tree/src/main/java/de/learnlib/datastructure/discriminationtree/iterators/NodeIterator.java index eb3ba9c250..193f44d1b5 100644 --- a/datastructures/discrimination-tree/src/main/java/de/learnlib/datastructure/discriminationtree/iterators/NodeIterator.java +++ b/datastructures/discrimination-tree/src/main/java/de/learnlib/datastructure/discriminationtree/iterators/NodeIterator.java @@ -17,8 +17,9 @@ import java.util.ArrayDeque; import java.util.Deque; +import java.util.Iterator; +import java.util.NoSuchElementException; -import com.google.common.collect.AbstractIterator; import de.learnlib.datastructure.discriminationtree.model.AbstractDTNode; /** @@ -27,7 +28,7 @@ * @param * node type */ -class NodeIterator> extends AbstractIterator { +class NodeIterator> implements Iterator { private final Deque stack = new ArrayDeque<>(); @@ -36,18 +37,24 @@ class NodeIterator> extends AbstractIterato } @Override - protected N computeNext() { - if (!stack.isEmpty()) { - N curr = stack.pop(); - - if (!curr.isLeaf()) { - for (N child : curr.getChildren()) { - stack.push(child); - } - } + public boolean hasNext() { + return !stack.isEmpty(); + } + + @Override + public N next() { + if (stack.isEmpty()) { + throw new NoSuchElementException(); + } + + final N curr = stack.pop(); - return curr; + if (!curr.isLeaf()) { + for (N child : curr.getChildren()) { + stack.push(child); + } } - return endOfData(); + + return curr; } } diff --git a/datastructures/discrimination-tree/src/main/java/de/learnlib/datastructure/discriminationtree/model/AbstractDiscriminationTree.java b/datastructures/discrimination-tree/src/main/java/de/learnlib/datastructure/discriminationtree/model/AbstractDiscriminationTree.java index 933a2e76f8..7a1449b50d 100644 --- a/datastructures/discrimination-tree/src/main/java/de/learnlib/datastructure/discriminationtree/model/AbstractDiscriminationTree.java +++ b/datastructures/discrimination-tree/src/main/java/de/learnlib/datastructure/discriminationtree/model/AbstractDiscriminationTree.java @@ -26,11 +26,11 @@ import java.util.RandomAccess; import java.util.function.Predicate; -import com.google.common.collect.Iterables; import de.learnlib.oracle.MembershipOracle; import de.learnlib.query.DefaultQuery; -import net.automatalib.common.smartcollection.ArrayStorage; +import net.automatalib.common.util.array.ArrayStorage; import net.automatalib.common.util.collection.BitSetIterator; +import net.automatalib.common.util.collection.IteratorUtil; import net.automatalib.graph.Graph; import net.automatalib.util.graph.traversal.GraphTraversal; import net.automatalib.visualization.DefaultVisualizationHelper; @@ -233,9 +233,7 @@ public LCAInfo lcaInfo(N node1, N node2) { */ @Override public Collection getNodes() { - List nodes = new ArrayList<>(); - Iterables.addAll(nodes, GraphTraversal.breadthFirstOrder(this, Collections.singleton(root))); - return nodes; + return IteratorUtil.list(GraphTraversal.breadthFirstIterator(this, Collections.singleton(root))); } @Override diff --git a/datastructures/discrimination-tree/src/main/java/module-info.java b/datastructures/discrimination-tree/src/main/java/module-info.java index 3bfb23f8bb..147be354b2 100644 --- a/datastructures/discrimination-tree/src/main/java/module-info.java +++ b/datastructures/discrimination-tree/src/main/java/module-info.java @@ -28,11 +28,9 @@ */ open module de.learnlib.datastructure.discriminationtree { - requires com.google.common; requires de.learnlib.api; requires de.learnlib.datastructure.list; requires net.automatalib.api; - requires net.automatalib.common.smartcollection; requires net.automatalib.common.util; requires net.automatalib.util; requires org.checkerframework.checker.qual; diff --git a/datastructures/discrimination-tree/src/test/java/de/learnlib/datastructure/discriminationtree/IteratorsTest.java b/datastructures/discrimination-tree/src/test/java/de/learnlib/datastructure/discriminationtree/IteratorsTest.java index 03ac42a3a0..40b9a508d2 100644 --- a/datastructures/discrimination-tree/src/test/java/de/learnlib/datastructure/discriminationtree/IteratorsTest.java +++ b/datastructures/discrimination-tree/src/test/java/de/learnlib/datastructure/discriminationtree/IteratorsTest.java @@ -15,13 +15,11 @@ */ package de.learnlib.datastructure.discriminationtree; -import java.util.Arrays; -import java.util.HashSet; import java.util.Set; -import com.google.common.collect.Sets; import de.learnlib.datastructure.discriminationtree.iterators.DiscriminationTreeIterators; import de.learnlib.datastructure.discriminationtree.model.AbstractWordBasedDTNode; +import net.automatalib.common.util.collection.IteratorUtil; import org.testng.Assert; import org.testng.annotations.Test; @@ -30,38 +28,34 @@ public class IteratorsTest { @Test public void testNodeIterator() { final Set> nodes = - Sets.newHashSet(DiscriminationTreeIterators.nodeIterator(DummyDT.DT.getRoot())); + IteratorUtil.set(DiscriminationTreeIterators.nodeIterator(DummyDT.DT.getRoot())); Assert.assertEquals(nodes, - new HashSet<>(Arrays.asList(DummyDT.INNER_1, - DummyDT.INNER_2, - DummyDT.LEAF_1, - DummyDT.LEAF_2, - DummyDT.LEAF_3))); + Set.of(DummyDT.INNER_1, DummyDT.INNER_2, DummyDT.LEAF_1, DummyDT.LEAF_2, DummyDT.LEAF_3)); } @Test public void testLeafIterator() { final Set> nodes = - Sets.newHashSet(DiscriminationTreeIterators.leafIterator(DummyDT.DT.getRoot())); + IteratorUtil.set(DiscriminationTreeIterators.leafIterator(DummyDT.DT.getRoot())); - Assert.assertEquals(nodes, new HashSet<>(Arrays.asList(DummyDT.LEAF_1, DummyDT.LEAF_2, DummyDT.LEAF_3))); + Assert.assertEquals(nodes, Set.of(DummyDT.LEAF_1, DummyDT.LEAF_2, DummyDT.LEAF_3)); } @Test public void testInnerNodeIterator() { final Set> nodes = - Sets.newHashSet(DiscriminationTreeIterators.innerNodeIterator(DummyDT.DT.getRoot())); + IteratorUtil.set(DiscriminationTreeIterators.innerNodeIterator(DummyDT.DT.getRoot())); - Assert.assertEquals(nodes, new HashSet<>(Arrays.asList(DummyDT.INNER_1, DummyDT.INNER_2))); + Assert.assertEquals(nodes, Set.of(DummyDT.INNER_1, DummyDT.INNER_2)); } @Test public void testTransformingLeafIterator() { final Set nodes = - Sets.newHashSet(DiscriminationTreeIterators.transformingLeafIterator(DummyDT.DT.getRoot(), - n -> String.valueOf(n.getData()))); + IteratorUtil.set(DiscriminationTreeIterators.transformingLeafIterator(DummyDT.DT.getRoot(), + n -> String.valueOf(n.getData()))); - Assert.assertEquals(nodes, Sets.newHashSet("a", "b", "c")); + Assert.assertEquals(nodes, Set.of("a", "b", "c")); } } diff --git a/datastructures/discrimination-tree/src/test/java/de/learnlib/datastructure/discriminationtree/VisualizationTest.java b/datastructures/discrimination-tree/src/test/java/de/learnlib/datastructure/discriminationtree/VisualizationTest.java index 3c18d1bd08..9647090ffd 100644 --- a/datastructures/discrimination-tree/src/test/java/de/learnlib/datastructure/discriminationtree/VisualizationTest.java +++ b/datastructures/discrimination-tree/src/test/java/de/learnlib/datastructure/discriminationtree/VisualizationTest.java @@ -18,7 +18,6 @@ import java.io.IOException; import java.io.StringWriter; -import com.google.common.io.CharStreams; import net.automatalib.common.util.IOUtil; import net.automatalib.serialization.dot.GraphDOT; import org.testng.Assert; @@ -32,7 +31,7 @@ public void testVisualization() throws IOException { GraphDOT.write(DummyDT.DT, actualDT); final String expectedDT = - CharStreams.toString(IOUtil.asBufferedUTF8Reader(VisualizationTest.class.getResourceAsStream("/dt.dot"))); + IOUtil.toString(IOUtil.asBufferedUTF8Reader(VisualizationTest.class.getResourceAsStream("/dt.dot"))); Assert.assertEquals(actualDT.toString(), expectedDT); } diff --git a/datastructures/list/pom.xml b/datastructures/list/pom.xml index 0d4cb64133..0c2308d2f4 100644 --- a/datastructures/list/pom.xml +++ b/datastructures/list/pom.xml @@ -32,11 +32,6 @@ limitations under the License. - - com.google.guava - guava - - org.checkerframework checker-qual diff --git a/datastructures/list/src/main/java/de/learnlib/datastructure/list/IntrusiveList.java b/datastructures/list/src/main/java/de/learnlib/datastructure/list/IntrusiveList.java index 11a68955a5..44eba8b473 100644 --- a/datastructures/list/src/main/java/de/learnlib/datastructure/list/IntrusiveList.java +++ b/datastructures/list/src/main/java/de/learnlib/datastructure/list/IntrusiveList.java @@ -16,8 +16,8 @@ package de.learnlib.datastructure.list; import java.util.Iterator; +import java.util.NoSuchElementException; -import com.google.common.collect.AbstractIterator; import org.checkerframework.checker.nullness.qual.EnsuresNonNullIf; import org.checkerframework.checker.nullness.qual.Nullable; @@ -59,7 +59,7 @@ public Iterator iterator() { return new ListIterator(next); } - private class ListIterator extends AbstractIterator { + private class ListIterator implements Iterator { private @Nullable T cursor; @@ -68,9 +68,14 @@ private class ListIterator extends AbstractIterator { } @Override - protected @Nullable T computeNext() { + public boolean hasNext() { + return cursor != null; + } + + @Override + public T next() { if (cursor == null) { - return endOfData(); + throw new NoSuchElementException(); } final T result = cursor; diff --git a/datastructures/list/src/main/java/module-info.java b/datastructures/list/src/main/java/module-info.java index c7d09ea9cf..544f3582e9 100644 --- a/datastructures/list/src/main/java/module-info.java +++ b/datastructures/list/src/main/java/module-info.java @@ -28,7 +28,6 @@ */ open module de.learnlib.datastructure.list { - requires com.google.common; requires org.checkerframework.checker.qual; exports de.learnlib.datastructure.list; diff --git a/datastructures/observation-table/pom.xml b/datastructures/observation-table/pom.xml index bcc69ade83..9d79f95d2a 100644 --- a/datastructures/observation-table/pom.xml +++ b/datastructures/observation-table/pom.xml @@ -38,11 +38,6 @@ limitations under the License. - - com.google.guava - guava - - net.automatalib automata-api @@ -55,10 +50,6 @@ limitations under the License. net.automatalib automata-commons-util - - net.automatalib - automata-commons-smartcollections - org.checkerframework diff --git a/datastructures/observation-table/src/main/java/de/learnlib/datastructure/observationtable/RowImpl.java b/datastructures/observation-table/src/main/java/de/learnlib/datastructure/observationtable/RowImpl.java index 42dfe5561f..cb57dbfa83 100644 --- a/datastructures/observation-table/src/main/java/de/learnlib/datastructure/observationtable/RowImpl.java +++ b/datastructures/observation-table/src/main/java/de/learnlib/datastructure/observationtable/RowImpl.java @@ -15,7 +15,7 @@ */ package de.learnlib.datastructure.observationtable; -import net.automatalib.common.smartcollection.ResizingArrayStorage; +import net.automatalib.common.util.array.ResizingArrayStorage; import net.automatalib.word.Word; final class RowImpl implements Row { diff --git a/datastructures/observation-table/src/main/java/de/learnlib/datastructure/observationtable/reader/SuffixASCIIReader.java b/datastructures/observation-table/src/main/java/de/learnlib/datastructure/observationtable/reader/SuffixASCIIReader.java index 1e45741c04..d9ca19d241 100644 --- a/datastructures/observation-table/src/main/java/de/learnlib/datastructure/observationtable/reader/SuffixASCIIReader.java +++ b/datastructures/observation-table/src/main/java/de/learnlib/datastructure/observationtable/reader/SuffixASCIIReader.java @@ -16,13 +16,14 @@ package de.learnlib.datastructure.observationtable.reader; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; -import com.google.common.collect.Maps; import de.learnlib.datastructure.observationtable.ObservationTable; import net.automatalib.alphabet.Alphabet; +import net.automatalib.common.util.HashUtil; import net.automatalib.word.Word; public class SuffixASCIIReader implements ObservationTableReader { @@ -52,7 +53,7 @@ public ObservationTable read(String source, Alphabet alphabet) { } private Map generateNameToSymbolMap(Alphabet alphabet) { - Map nameToSymbol = Maps.newHashMapWithExpectedSize(alphabet.size()); + Map nameToSymbol = new HashMap<>(HashUtil.capacity(alphabet.size())); for (I symbol : alphabet) { String symbolName = Objects.toString(symbol); diff --git a/datastructures/observation-table/src/main/java/module-info.java b/datastructures/observation-table/src/main/java/module-info.java index e9786f50ab..e65cbd9712 100644 --- a/datastructures/observation-table/src/main/java/module-info.java +++ b/datastructures/observation-table/src/main/java/module-info.java @@ -28,10 +28,8 @@ */ open module de.learnlib.datastructure.observationtable { - requires com.google.common; requires de.learnlib.api; requires net.automatalib.api; - requires net.automatalib.common.smartcollection; requires net.automatalib.common.util; requires net.automatalib.core; requires org.checkerframework.checker.qual; diff --git a/datastructures/observation-table/src/test/java/de/learnlib/datastructure/observationtable/MockedObservationTable.java b/datastructures/observation-table/src/test/java/de/learnlib/datastructure/observationtable/MockedObservationTable.java index 836d881af7..d12b1be767 100644 --- a/datastructures/observation-table/src/test/java/de/learnlib/datastructure/observationtable/MockedObservationTable.java +++ b/datastructures/observation-table/src/test/java/de/learnlib/datastructure/observationtable/MockedObservationTable.java @@ -22,7 +22,6 @@ import java.util.List; import java.util.Map; -import com.google.common.base.Preconditions; import de.learnlib.datastructure.observationtable.reader.SimpleObservationTable; import net.automatalib.word.Word; @@ -62,7 +61,7 @@ void addLongPrefix(Word prefix, List contents) { } private RowImpl addPrefix(Word prefix, List contents) { - Preconditions.checkArgument(getSuffixes().size() == contents.size()); + assert getSuffixes().size() == contents.size(); final RowImpl row = new RowImpl<>(prefix, rows.size()); diff --git a/datastructures/pta/pom.xml b/datastructures/pta/pom.xml index 8f840c8dce..dcad496c8c 100644 --- a/datastructures/pta/pom.xml +++ b/datastructures/pta/pom.xml @@ -32,11 +32,6 @@ limitations under the License. - - com.google.guava - guava - - net.automatalib automata-api diff --git a/datastructures/pta/src/main/java/de/learnlib/datastructure/pta/AbstractBasePTAState.java b/datastructures/pta/src/main/java/de/learnlib/datastructure/pta/AbstractBasePTAState.java index b8bc623413..f59d4c7490 100644 --- a/datastructures/pta/src/main/java/de/learnlib/datastructure/pta/AbstractBasePTAState.java +++ b/datastructures/pta/src/main/java/de/learnlib/datastructure/pta/AbstractBasePTAState.java @@ -18,7 +18,7 @@ import java.util.Objects; import java.util.function.Consumer; -import net.automatalib.common.smartcollection.ArrayStorage; +import net.automatalib.common.util.array.ArrayStorage; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; import org.checkerframework.checker.nullness.qual.Nullable; diff --git a/datastructures/pta/src/main/java/de/learnlib/datastructure/pta/BasePTA.java b/datastructures/pta/src/main/java/de/learnlib/datastructure/pta/BasePTA.java index 1bf52de8e8..3f968eea15 100644 --- a/datastructures/pta/src/main/java/de/learnlib/datastructure/pta/BasePTA.java +++ b/datastructures/pta/src/main/java/de/learnlib/datastructure/pta/BasePTA.java @@ -26,7 +26,6 @@ import java.util.Objects; import java.util.Set; -import com.google.common.collect.AbstractIterator; import net.automatalib.alphabet.Alphabet; import net.automatalib.alphabet.impl.Alphabets; import net.automatalib.automaton.FiniteAlphabetAutomaton; @@ -36,6 +35,7 @@ import net.automatalib.automaton.graph.UniversalAutomatonGraphView; import net.automatalib.automaton.visualization.AutomatonVisualizationHelper; import net.automatalib.common.smartcollection.IntSeq; +import net.automatalib.common.util.collection.AbstractSimplifiedIterator; import net.automatalib.graph.UniversalGraph; import net.automatalib.visualization.VisualizationHelper; import org.checkerframework.checker.nullness.qual.Nullable; @@ -180,21 +180,21 @@ public Iterator iterator() { bfsQueue.add(root); visited.add(root); - return new AbstractIterator() { + return new AbstractSimplifiedIterator() { @Override - protected S computeNext() { - S next = bfsQueue.poll(); - if (next == null) { - return endOfData(); + protected boolean calculateNext() { + super.nextValue = bfsQueue.poll(); + if (super.nextValue == null) { + return false; } for (int i = 0; i < alphabetSize; i++) { - S child = next.getSuccessor(i); + S child = super.nextValue.getSuccessor(i); if (child != null && visited.add(child)) { bfsQueue.offer(child); } } - return next; + return true; } }; } diff --git a/datastructures/pta/src/main/java/de/learnlib/datastructure/pta/RedBlueMerge.java b/datastructures/pta/src/main/java/de/learnlib/datastructure/pta/RedBlueMerge.java index 685a831e90..5927506e74 100644 --- a/datastructures/pta/src/main/java/de/learnlib/datastructure/pta/RedBlueMerge.java +++ b/datastructures/pta/src/main/java/de/learnlib/datastructure/pta/RedBlueMerge.java @@ -26,8 +26,8 @@ import java.util.function.Consumer; import net.automatalib.automaton.UniversalDeterministicAutomaton; -import net.automatalib.common.smartcollection.ArrayStorage; import net.automatalib.common.util.Pair; +import net.automatalib.common.util.array.ArrayStorage; import org.checkerframework.checker.nullness.qual.Nullable; public class RedBlueMerge, SP, TP> { diff --git a/datastructures/pta/src/main/java/module-info.java b/datastructures/pta/src/main/java/module-info.java index cd1514f243..0d1d581fd3 100644 --- a/datastructures/pta/src/main/java/module-info.java +++ b/datastructures/pta/src/main/java/module-info.java @@ -28,7 +28,6 @@ */ open module de.learnlib.datastructure.pta { - requires com.google.common; requires net.automatalib.api; requires net.automatalib.common.smartcollection; requires net.automatalib.common.util; diff --git a/datastructures/pta/src/test/java/de/learnlib/datastructure/pta/PTAVisualizationTest.java b/datastructures/pta/src/test/java/de/learnlib/datastructure/pta/PTAVisualizationTest.java index edf9f4b5d9..509f17a22c 100644 --- a/datastructures/pta/src/test/java/de/learnlib/datastructure/pta/PTAVisualizationTest.java +++ b/datastructures/pta/src/test/java/de/learnlib/datastructure/pta/PTAVisualizationTest.java @@ -20,7 +20,6 @@ import java.util.ArrayList; import java.util.List; -import com.google.common.io.CharStreams; import net.automatalib.alphabet.Alphabet; import net.automatalib.alphabet.impl.Alphabets; import net.automatalib.automaton.transducer.impl.CompactMoore; @@ -71,7 +70,7 @@ public void testVisualization() throws IOException { GraphDOT.write(this.pta, actualPTA); final String expectedPTA = - CharStreams.toString(IOUtil.asBufferedUTF8Reader(PTAVisualizationTest.class.getResourceAsStream( + IOUtil.toString(IOUtil.asBufferedUTF8Reader(PTAVisualizationTest.class.getResourceAsStream( "/pta.dot"))); Assert.assertEquals(actualPTA.toString(), expectedPTA); diff --git a/examples/src/main/java/de/learnlib/example/parallelism/ParallelismExample1.java b/examples/src/main/java/de/learnlib/example/parallelism/ParallelismExample1.java index fa2335b3f5..67ffbedf14 100644 --- a/examples/src/main/java/de/learnlib/example/parallelism/ParallelismExample1.java +++ b/examples/src/main/java/de/learnlib/example/parallelism/ParallelismExample1.java @@ -32,7 +32,7 @@ import net.automatalib.alphabet.Alphabet; import net.automatalib.alphabet.impl.Alphabets; import net.automatalib.automaton.transducer.impl.CompactMealy; -import net.automatalib.common.util.collection.CollectionsUtil; +import net.automatalib.common.util.collection.IterableUtil; import net.automatalib.util.automaton.random.RandomAutomata; import net.automatalib.word.Word; @@ -60,7 +60,7 @@ public ParallelismExample1() { // generate 1 million (10^6) input words this.queries = new ArrayList<>((int) Math.pow(inputs.size(), QUERIES_EXP)); - for (List input : CollectionsUtil.allTuples(inputs, QUERIES_EXP)) { + for (List input : IterableUtil.allTuples(inputs, QUERIES_EXP)) { queries.add(new DefaultQuery<>(Word.fromList(input))); } } diff --git a/filters/cache/src/test/java/de/learnlib/filter/cache/AbstractParallelCacheTest.java b/filters/cache/src/test/java/de/learnlib/filter/cache/AbstractParallelCacheTest.java index 75f66ec1c5..63023f079d 100644 --- a/filters/cache/src/test/java/de/learnlib/filter/cache/AbstractParallelCacheTest.java +++ b/filters/cache/src/test/java/de/learnlib/filter/cache/AbstractParallelCacheTest.java @@ -23,7 +23,7 @@ import de.learnlib.oracle.ParallelOracle; import de.learnlib.query.DefaultQuery; import net.automatalib.alphabet.Alphabet; -import net.automatalib.common.util.collection.CollectionsUtil; +import net.automatalib.common.util.collection.IterableUtil; import net.automatalib.word.Word; import org.testng.Assert; import org.testng.annotations.AfterClass; @@ -81,7 +81,7 @@ public void testConcurrentMembershipQueries() { final List> queries = new ArrayList<>(numQueries); - for (List word : CollectionsUtil.allTuples(alphabet, 0, MAXIMUM_LENGTH_OF_QUERIES)) { + for (List word : IterableUtil.allTuples(alphabet, 0, MAXIMUM_LENGTH_OF_QUERIES)) { queries.add(new CountingQuery<>(Word.fromList(word))); } @@ -111,9 +111,9 @@ public void testConcurrentEquivalenceQueries() { final List> queries = new ArrayList<>((int) Math.pow(alphabet.size(), MAXIMUM_LENGTH_OF_QUERIES)); - for (List word : CollectionsUtil.allTuples(alphabet, - MAXIMUM_LENGTH_OF_QUERIES + 1, - MAXIMUM_LENGTH_OF_QUERIES + 1)) { + for (List word : IterableUtil.allTuples(alphabet, + MAXIMUM_LENGTH_OF_QUERIES + 1, + MAXIMUM_LENGTH_OF_QUERIES + 1)) { queries.add(new DefaultQuery<>(Word.fromList(word))); } diff --git a/filters/statistics/pom.xml b/filters/statistics/pom.xml index 62bc8426e7..535758c8a5 100644 --- a/filters/statistics/pom.xml +++ b/filters/statistics/pom.xml @@ -54,12 +54,6 @@ limitations under the License. - - com.google.guava - guava - test - - de.learnlib learnlib-drivers-simulator diff --git a/filters/statistics/src/test/java/de/learnlib/filter/statistic/TestQueries.java b/filters/statistics/src/test/java/de/learnlib/filter/statistic/TestQueries.java index 6e1c44924c..636bf8091a 100644 --- a/filters/statistics/src/test/java/de/learnlib/filter/statistic/TestQueries.java +++ b/filters/statistics/src/test/java/de/learnlib/filter/statistic/TestQueries.java @@ -24,7 +24,7 @@ import net.automatalib.alphabet.Alphabet; import net.automatalib.alphabet.impl.Alphabets; import net.automatalib.automaton.transducer.impl.CompactMealy; -import net.automatalib.common.util.collection.CollectionsUtil; +import net.automatalib.common.util.collection.CollectionUtil; import net.automatalib.common.util.random.RandomUtil; import net.automatalib.util.automaton.random.RandomAutomata; import net.automatalib.word.Word; @@ -60,7 +60,7 @@ public static Collection> createNoopQueries(int numQueries, Collection inputs) { final Random r = new Random(42); - final List inputsAsList = CollectionsUtil.randomAccessList(inputs); + final List inputsAsList = CollectionUtil.randomAccessList(inputs); List> result = new ArrayList<>(numQueries); for (int i = 0; i < numQueries; i++) { diff --git a/filters/statistics/src/test/java/de/learnlib/filter/statistic/oracle/HistogramOracleTest.java b/filters/statistics/src/test/java/de/learnlib/filter/statistic/oracle/HistogramOracleTest.java index 50f96d3677..6eea7c62d0 100644 --- a/filters/statistics/src/test/java/de/learnlib/filter/statistic/oracle/HistogramOracleTest.java +++ b/filters/statistics/src/test/java/de/learnlib/filter/statistic/oracle/HistogramOracleTest.java @@ -20,7 +20,6 @@ import java.util.Collection; import java.util.Collections; -import com.google.common.io.CharStreams; import de.learnlib.filter.statistic.TestQueries; import de.learnlib.oracle.MembershipOracle; import de.learnlib.query.Query; @@ -76,8 +75,8 @@ public void testSummary() throws IOException { try (InputStream detailStream = HistogramOracleTest.class.getResourceAsStream("/histogram_details.txt"); InputStream summaryStream = HistogramOracleTest.class.getResourceAsStream("/histogram_summary.txt")) { - final String expectedDetail = CharStreams.toString(IOUtil.asBufferedUTF8Reader(detailStream)); - final String expectedSummary = CharStreams.toString(IOUtil.asBufferedUTF8Reader(summaryStream)); + final String expectedDetail = IOUtil.toString(IOUtil.asBufferedUTF8Reader(detailStream)); + final String expectedSummary = IOUtil.toString(IOUtil.asBufferedUTF8Reader(summaryStream)); Assert.assertEquals(details, expectedDetail); Assert.assertEquals(summary, expectedSummary); diff --git a/oracles/equivalence-oracles/pom.xml b/oracles/equivalence-oracles/pom.xml index c24767ec9a..045e1217c1 100644 --- a/oracles/equivalence-oracles/pom.xml +++ b/oracles/equivalence-oracles/pom.xml @@ -42,11 +42,6 @@ limitations under the License. - - com.google.guava - guava - - net.automatalib automata-api diff --git a/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/AbstractTestWordEQOracle.java b/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/AbstractTestWordEQOracle.java index 3ab689b8bd..6dfea3ba78 100644 --- a/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/AbstractTestWordEQOracle.java +++ b/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/AbstractTestWordEQOracle.java @@ -20,14 +20,12 @@ import java.util.Objects; import java.util.stream.Stream; -import com.google.common.base.Preconditions; -import com.google.common.collect.Iterators; -import com.google.common.collect.Streams; import de.learnlib.logging.Category; import de.learnlib.oracle.EquivalenceOracle; import de.learnlib.oracle.MembershipOracle; import de.learnlib.query.DefaultQuery; import net.automatalib.automaton.concept.Output; +import net.automatalib.common.util.collection.IteratorUtil; import net.automatalib.word.Word; import org.checkerframework.checker.nullness.qual.Nullable; import org.slf4j.Logger; @@ -59,7 +57,7 @@ public AbstractTestWordEQOracle(MembershipOracle membershipOracle) { } public AbstractTestWordEQOracle(MembershipOracle membershipOracle, int batchSize) { - Preconditions.checkArgument(batchSize > 0); + assert batchSize > 0; this.membershipOracle = membershipOracle; this.batchSize = batchSize; @@ -102,9 +100,9 @@ public AbstractTestWordEQOracle(MembershipOracle membershipOracle, int bat private Stream> answerQueries(Stream> stream) { if (isBatched()) { - return Streams.stream(Iterators.partition(stream.iterator(), this.batchSize)) - .peek(membershipOracle::processQueries) - .flatMap(List::stream); + return IteratorUtil.stream(IteratorUtil.batch(stream.iterator(), this.batchSize)) + .peek(membershipOracle::processQueries) + .flatMap(List::stream); } else { return stream.peek(membershipOracle::processQuery); } diff --git a/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/CompleteExplorationEQOracle.java b/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/CompleteExplorationEQOracle.java index 270531a952..14a8871e3b 100644 --- a/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/CompleteExplorationEQOracle.java +++ b/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/CompleteExplorationEQOracle.java @@ -18,7 +18,6 @@ import java.util.Collection; import java.util.stream.Stream; -import com.google.common.collect.Streams; import de.learnlib.oracle.EquivalenceOracle.DFAEquivalenceOracle; import de.learnlib.oracle.EquivalenceOracle.MealyEquivalenceOracle; import de.learnlib.oracle.EquivalenceOracle.MooreEquivalenceOracle; @@ -34,7 +33,7 @@ import net.automatalib.automaton.fsa.DFA; import net.automatalib.automaton.transducer.MealyMachine; import net.automatalib.automaton.transducer.MooreMachine; -import net.automatalib.common.util.collection.CollectionsUtil; +import net.automatalib.common.util.collection.IterableUtil; import net.automatalib.word.Word; /** @@ -128,6 +127,6 @@ public CompleteExplorationEQOracle(MembershipOracle sulOracle, int minDept @Override protected Stream> generateTestWords(A hypothesis, Collection inputs) { - return Streams.stream(CollectionsUtil.allTuples(inputs, minDepth, maxDepth)).map(Word::fromList); + return IterableUtil.stream(IterableUtil.allTuples(inputs, minDepth, maxDepth)).map(Word::fromList); } } diff --git a/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/IncrementalWMethodEQOracle.java b/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/IncrementalWMethodEQOracle.java index 614ec3337a..d305538eca 100644 --- a/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/IncrementalWMethodEQOracle.java +++ b/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/IncrementalWMethodEQOracle.java @@ -18,7 +18,6 @@ import java.util.Collection; import java.util.stream.Stream; -import com.google.common.collect.Streams; import de.learnlib.oracle.EquivalenceOracle.DFAEquivalenceOracle; import de.learnlib.oracle.EquivalenceOracle.MealyEquivalenceOracle; import de.learnlib.oracle.EquivalenceOracle.MooreEquivalenceOracle; @@ -36,6 +35,7 @@ import net.automatalib.automaton.fsa.DFA; import net.automatalib.automaton.transducer.MealyMachine; import net.automatalib.automaton.transducer.MooreMachine; +import net.automatalib.common.util.collection.IteratorUtil; import net.automatalib.util.automaton.conformance.IncrementalWMethodTestsIterator; import net.automatalib.word.Word; @@ -106,6 +106,6 @@ protected Stream> generateTestWords(A hypothesis, Collection mqOracle, @Override protected Stream> generateTestWords(A hypothesis, Collection inputs) { - final List symbolList = CollectionsUtil.randomAccessList(inputs); + final List symbolList = CollectionUtil.randomAccessList(inputs); return Stream.generate(() -> generateTestWord(symbolList, symbolList.size())).limit(maxTests); } diff --git a/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/WMethodEQOracle.java b/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/WMethodEQOracle.java index 8c3ad33b63..88deaf9d5d 100644 --- a/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/WMethodEQOracle.java +++ b/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/WMethodEQOracle.java @@ -18,7 +18,6 @@ import java.util.Collection; import java.util.stream.Stream; -import com.google.common.collect.Streams; import de.learnlib.oracle.EquivalenceOracle.DFAEquivalenceOracle; import de.learnlib.oracle.EquivalenceOracle.MealyEquivalenceOracle; import de.learnlib.oracle.EquivalenceOracle.MooreEquivalenceOracle; @@ -35,6 +34,7 @@ import net.automatalib.automaton.fsa.DFA; import net.automatalib.automaton.transducer.MealyMachine; import net.automatalib.automaton.transducer.MooreMachine; +import net.automatalib.common.util.collection.IteratorUtil; import net.automatalib.util.automaton.conformance.WMethodTestsIterator; import net.automatalib.word.Word; @@ -141,8 +141,8 @@ public WMethodEQOracle(MembershipOracle sulOracle, int lookahead, int expe @Override protected Stream> generateTestWords(A hypothesis, Collection inputs) { - return Streams.stream(new WMethodTestsIterator<>(hypothesis, - inputs, - Math.max(lookahead, expectedSize - hypothesis.size()))); + return IteratorUtil.stream(new WMethodTestsIterator<>(hypothesis, + inputs, + Math.max(lookahead, expectedSize - hypothesis.size()))); } } diff --git a/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/WpMethodEQOracle.java b/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/WpMethodEQOracle.java index 28e412994c..349758a97c 100644 --- a/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/WpMethodEQOracle.java +++ b/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/WpMethodEQOracle.java @@ -18,7 +18,6 @@ import java.util.Collection; import java.util.stream.Stream; -import com.google.common.collect.Streams; import de.learnlib.oracle.EquivalenceOracle.DFAEquivalenceOracle; import de.learnlib.oracle.EquivalenceOracle.MealyEquivalenceOracle; import de.learnlib.oracle.EquivalenceOracle.MooreEquivalenceOracle; @@ -35,6 +34,7 @@ import net.automatalib.automaton.fsa.DFA; import net.automatalib.automaton.transducer.MealyMachine; import net.automatalib.automaton.transducer.MooreMachine; +import net.automatalib.common.util.collection.IteratorUtil; import net.automatalib.util.automaton.conformance.WpMethodTestsIterator; import net.automatalib.word.Word; @@ -140,8 +140,8 @@ public WpMethodEQOracle(MembershipOracle sulOracle, int lookahead, int exp @Override protected Stream> generateTestWords(A hypothesis, Collection inputs) { - return Streams.stream(new WpMethodTestsIterator<>(hypothesis, - inputs, - Math.max(lookahead, expectedSize - hypothesis.size()))); + return IteratorUtil.stream(new WpMethodTestsIterator<>(hypothesis, + inputs, + Math.max(lookahead, expectedSize - hypothesis.size()))); } } diff --git a/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/mealy/RandomWalkEQOracle.java b/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/mealy/RandomWalkEQOracle.java index 5bdc892dfc..44f0d00464 100644 --- a/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/mealy/RandomWalkEQOracle.java +++ b/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/mealy/RandomWalkEQOracle.java @@ -25,7 +25,7 @@ import de.learnlib.query.DefaultQuery; import de.learnlib.sul.SUL; import net.automatalib.automaton.transducer.MealyMachine; -import net.automatalib.common.util.collection.CollectionsUtil; +import net.automatalib.common.util.collection.CollectionUtil; import net.automatalib.word.Word; import net.automatalib.word.WordBuilder; import org.checkerframework.checker.nullness.qual.Nullable; @@ -107,7 +107,7 @@ public RandomWalkEQOracle(SUL sul, double restartProbability, long maxStep return null; } - List choices = CollectionsUtil.randomAccessList(inputs); + List choices = CollectionUtil.randomAccessList(inputs); int bound = choices.size(); S cur = hypothesis.getInitialState(); WordBuilder wbIn = new WordBuilder<>(); diff --git a/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/sba/WMethodEQOracle.java b/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/sba/WMethodEQOracle.java index 82449f11d7..729cd9d74f 100644 --- a/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/sba/WMethodEQOracle.java +++ b/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/sba/WMethodEQOracle.java @@ -18,12 +18,12 @@ import java.util.Collection; import java.util.stream.Stream; -import com.google.common.collect.Streams; import de.learnlib.oracle.MembershipOracle; import de.learnlib.oracle.equivalence.AbstractTestWordEQOracle; import net.automatalib.alphabet.ProceduralInputAlphabet; import net.automatalib.automaton.concept.FiniteRepresentation; import net.automatalib.automaton.procedural.SBA; +import net.automatalib.common.util.collection.IteratorUtil; import net.automatalib.util.automaton.conformance.SBAWMethodTestsIterator; import net.automatalib.util.automaton.conformance.WMethodTestsIterator; import net.automatalib.word.Word; @@ -101,8 +101,9 @@ protected Stream> generateTestWords(SBA hypothesis, Collection alphabet = (ProceduralInputAlphabet) inputs; - return Streams.stream(new SBAWMethodTestsIterator<>(hypothesis, - alphabet, - Math.max(lookahead, expectedSize - hypothesis.size()))); + return IteratorUtil.stream(new SBAWMethodTestsIterator<>(hypothesis, + alphabet, + Math.max(lookahead, + expectedSize - hypothesis.size()))); } } diff --git a/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/spa/WMethodEQOracle.java b/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/spa/WMethodEQOracle.java index 32ea54e07c..5382c3a368 100644 --- a/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/spa/WMethodEQOracle.java +++ b/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/spa/WMethodEQOracle.java @@ -18,12 +18,12 @@ import java.util.Collection; import java.util.stream.Stream; -import com.google.common.collect.Streams; import de.learnlib.oracle.MembershipOracle; import de.learnlib.oracle.equivalence.AbstractTestWordEQOracle; import net.automatalib.alphabet.ProceduralInputAlphabet; import net.automatalib.automaton.fsa.DFA; import net.automatalib.automaton.procedural.SPA; +import net.automatalib.common.util.collection.IteratorUtil; import net.automatalib.util.automaton.conformance.SPATestsIterator; import net.automatalib.util.automaton.conformance.WMethodTestsIterator; import net.automatalib.word.Word; @@ -101,12 +101,12 @@ protected Stream> generateTestWords(SPA hypothesis, Collection alphabet = (ProceduralInputAlphabet) inputs; - return Streams.stream(new SPATestsIterator<>(hypothesis, - alphabet, - (dfa, alph) -> new WMethodTestsIterator<>(dfa, - alph, - Math.max(lookahead, - expectedSize - - dfa.size())))); + return IteratorUtil.stream(new SPATestsIterator<>(hypothesis, + alphabet, + (dfa, alph) -> new WMethodTestsIterator<>(dfa, + alph, + Math.max(lookahead, + expectedSize - + dfa.size())))); } } diff --git a/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/spa/WpMethodEQOracle.java b/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/spa/WpMethodEQOracle.java index f265d2b195..5075ed2973 100644 --- a/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/spa/WpMethodEQOracle.java +++ b/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/spa/WpMethodEQOracle.java @@ -18,12 +18,12 @@ import java.util.Collection; import java.util.stream.Stream; -import com.google.common.collect.Streams; import de.learnlib.oracle.MembershipOracle; import de.learnlib.oracle.equivalence.AbstractTestWordEQOracle; import net.automatalib.alphabet.ProceduralInputAlphabet; import net.automatalib.automaton.fsa.DFA; import net.automatalib.automaton.procedural.SPA; +import net.automatalib.common.util.collection.IteratorUtil; import net.automatalib.util.automaton.conformance.SPATestsIterator; import net.automatalib.util.automaton.conformance.WMethodTestsIterator; import net.automatalib.util.automaton.conformance.WpMethodTestsIterator; @@ -102,12 +102,12 @@ protected Stream> generateTestWords(SPA hypothesis, Collection alphabet = (ProceduralInputAlphabet) inputs; - return Streams.stream(new SPATestsIterator<>(hypothesis, - alphabet, - (dfa, alph) -> new WpMethodTestsIterator<>(dfa, - alph, - Math.max(lookahead, - expectedSize - - dfa.size())))); + return IteratorUtil.stream(new SPATestsIterator<>(hypothesis, + alphabet, + (dfa, alph) -> new WpMethodTestsIterator<>(dfa, + alph, + Math.max(lookahead, + expectedSize - + dfa.size())))); } } diff --git a/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/spmm/WMethodEQOracle.java b/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/spmm/WMethodEQOracle.java index ae8e8be4dc..9ae3971141 100644 --- a/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/spmm/WMethodEQOracle.java +++ b/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/spmm/WMethodEQOracle.java @@ -18,13 +18,13 @@ import java.util.Collection; import java.util.stream.Stream; -import com.google.common.collect.Streams; import de.learnlib.oracle.MembershipOracle; import de.learnlib.oracle.equivalence.AbstractTestWordEQOracle; import net.automatalib.alphabet.ProceduralInputAlphabet; import net.automatalib.automaton.concept.FiniteRepresentation; import net.automatalib.automaton.procedural.SBA; import net.automatalib.automaton.procedural.SPMM; +import net.automatalib.common.util.collection.IteratorUtil; import net.automatalib.util.automaton.conformance.SPMMWMethodTestsIterator; import net.automatalib.util.automaton.conformance.WMethodTestsIterator; import net.automatalib.word.Word; @@ -102,8 +102,9 @@ protected Stream> generateTestWords(SPMM hypothesis, Collect @SuppressWarnings("unchecked") final ProceduralInputAlphabet alphabet = (ProceduralInputAlphabet) inputs; - return Streams.stream(new SPMMWMethodTestsIterator<>(hypothesis, - alphabet, - Math.max(lookahead, expectedSize - hypothesis.size()))); + return IteratorUtil.stream(new SPMMWMethodTestsIterator<>(hypothesis, + alphabet, + Math.max(lookahead, + expectedSize - hypothesis.size()))); } } diff --git a/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/vpa/RandomWellMatchedWordsEQOracle.java b/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/vpa/RandomWellMatchedWordsEQOracle.java index de42d07b7f..ccf24bcc25 100644 --- a/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/vpa/RandomWellMatchedWordsEQOracle.java +++ b/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/vpa/RandomWellMatchedWordsEQOracle.java @@ -19,7 +19,6 @@ import java.util.Random; import java.util.stream.Stream; -import com.google.common.base.Preconditions; import de.learnlib.oracle.MembershipOracle; import de.learnlib.oracle.equivalence.AbstractTestWordEQOracle; import net.automatalib.alphabet.VPAlphabet; @@ -59,7 +58,9 @@ public RandomWellMatchedWordsEQOracle(Random random, int batchSize) { super(oracle, batchSize); - Preconditions.checkArgument(minLength <= maxLength, "minLength is smaller than maxLength"); + if (minLength > maxLength) { + throw new IllegalArgumentException("minLength is smaller than maxLength"); + } this.random = random; this.callProb = callProb; diff --git a/oracles/equivalence-oracles/src/main/java/module-info.java b/oracles/equivalence-oracles/src/main/java/module-info.java index 54307ad3b1..aef11e04ef 100644 --- a/oracles/equivalence-oracles/src/main/java/module-info.java +++ b/oracles/equivalence-oracles/src/main/java/module-info.java @@ -28,7 +28,6 @@ */ open module de.learnlib.oracle.equivalence { - requires com.google.common; requires de.learnlib.api; requires de.learnlib.common.util; requires net.automatalib.api; diff --git a/oracles/equivalence-oracles/src/test/java/de/learnlib/oracle/equivalence/CExFirstOracleTest.java b/oracles/equivalence-oracles/src/test/java/de/learnlib/oracle/equivalence/CExFirstOracleTest.java index c6d09d49de..578a33fbe2 100644 --- a/oracles/equivalence-oracles/src/test/java/de/learnlib/oracle/equivalence/CExFirstOracleTest.java +++ b/oracles/equivalence-oracles/src/test/java/de/learnlib/oracle/equivalence/CExFirstOracleTest.java @@ -15,9 +15,9 @@ */ package de.learnlib.oracle.equivalence; +import java.util.Arrays; import java.util.Collection; -import com.google.common.collect.Lists; import de.learnlib.oracle.BlackBoxOracle; import de.learnlib.oracle.PropertyOracle; import de.learnlib.query.DefaultQuery; @@ -61,7 +61,7 @@ public void setUp() { Mockito.when(query.getOutput()).thenReturn(Boolean.TRUE); Mockito.when(automaton.computeOutput(Mockito.any())).thenReturn(Boolean.FALSE); - oracle = new CExFirstOracle<>(Lists.newArrayList(po1, po2)); + oracle = new CExFirstOracle<>(Arrays.asList(po1, po2)); Mockito.when(po1.findCounterExample(automaton, inputs)).thenCallRealMethod(); Mockito.when(po1.doFindCounterExample(automaton, inputs)).thenReturn(query); Mockito.when(po2.findCounterExample(automaton, inputs)).thenCallRealMethod(); diff --git a/oracles/equivalence-oracles/src/test/java/de/learnlib/oracle/equivalence/DisproveFirstOracleTest.java b/oracles/equivalence-oracles/src/test/java/de/learnlib/oracle/equivalence/DisproveFirstOracleTest.java index 44f2ddcba3..3495dedc2f 100644 --- a/oracles/equivalence-oracles/src/test/java/de/learnlib/oracle/equivalence/DisproveFirstOracleTest.java +++ b/oracles/equivalence-oracles/src/test/java/de/learnlib/oracle/equivalence/DisproveFirstOracleTest.java @@ -15,9 +15,9 @@ */ package de.learnlib.oracle.equivalence; +import java.util.Arrays; import java.util.Collection; -import com.google.common.collect.Lists; import de.learnlib.oracle.BlackBoxOracle; import de.learnlib.oracle.PropertyOracle; import de.learnlib.query.DefaultQuery; @@ -61,7 +61,7 @@ public void setUp() { Mockito.when(query.getOutput()).thenReturn(Boolean.TRUE); Mockito.when(automaton.computeOutput(Mockito.any())).thenReturn(Boolean.FALSE); - oracle = new DisproveFirstOracle<>(Lists.newArrayList(po1, po2)); + oracle = new DisproveFirstOracle<>(Arrays.asList(po1, po2)); Mockito.when(po1.findCounterExample(automaton, inputs)).thenCallRealMethod(); Mockito.when(po1.doFindCounterExample(automaton, inputs)).thenReturn(query); Mockito.when(po2.findCounterExample(automaton, inputs)).thenCallRealMethod(); diff --git a/oracles/equivalence-oracles/src/test/java/de/learnlib/oracle/equivalence/sba/WMethodEQOracleTest.java b/oracles/equivalence-oracles/src/test/java/de/learnlib/oracle/equivalence/sba/WMethodEQOracleTest.java index fb5bbd8719..152522414d 100644 --- a/oracles/equivalence-oracles/src/test/java/de/learnlib/oracle/equivalence/sba/WMethodEQOracleTest.java +++ b/oracles/equivalence-oracles/src/test/java/de/learnlib/oracle/equivalence/sba/WMethodEQOracleTest.java @@ -19,12 +19,12 @@ import java.util.Random; import java.util.stream.Collectors; -import com.google.common.collect.Streams; import de.learnlib.oracle.membership.SimulatorOracle; import net.automatalib.alphabet.ProceduralInputAlphabet; import net.automatalib.alphabet.impl.Alphabets; import net.automatalib.alphabet.impl.DefaultProceduralInputAlphabet; import net.automatalib.automaton.procedural.SBA; +import net.automatalib.common.util.collection.IteratorUtil; import net.automatalib.util.automaton.conformance.SBAWMethodTestsIterator; import net.automatalib.util.automaton.random.RandomAutomata; import net.automatalib.word.Word; @@ -47,7 +47,7 @@ public void testOracle() { final List> eqWords = oracle.generateTestWords(sba, alphabet).collect(Collectors.toList()); final List> testWords = - Streams.stream(new SBAWMethodTestsIterator<>(sba, alphabet, lookahead)).collect(Collectors.toList()); + IteratorUtil.list(new SBAWMethodTestsIterator<>(sba, alphabet, lookahead)); Assert.assertEquals(eqWords, testWords); } diff --git a/oracles/equivalence-oracles/src/test/java/de/learnlib/oracle/equivalence/spa/WMethodEQOracleTest.java b/oracles/equivalence-oracles/src/test/java/de/learnlib/oracle/equivalence/spa/WMethodEQOracleTest.java index 55c2e223ba..9ebfbd83b5 100644 --- a/oracles/equivalence-oracles/src/test/java/de/learnlib/oracle/equivalence/spa/WMethodEQOracleTest.java +++ b/oracles/equivalence-oracles/src/test/java/de/learnlib/oracle/equivalence/spa/WMethodEQOracleTest.java @@ -19,12 +19,12 @@ import java.util.Random; import java.util.stream.Collectors; -import com.google.common.collect.Streams; import de.learnlib.oracle.membership.SimulatorOracle; import net.automatalib.alphabet.ProceduralInputAlphabet; import net.automatalib.alphabet.impl.Alphabets; import net.automatalib.alphabet.impl.DefaultProceduralInputAlphabet; import net.automatalib.automaton.procedural.SPA; +import net.automatalib.common.util.collection.IteratorUtil; import net.automatalib.util.automaton.conformance.SPATestsIterator; import net.automatalib.util.automaton.conformance.WMethodTestsIterator; import net.automatalib.util.automaton.random.RandomAutomata; @@ -47,12 +47,12 @@ public void testOracle() { final WMethodEQOracle oracle = new WMethodEQOracle<>(new SimulatorOracle<>(spa), lookahead); final List> eqWords = oracle.generateTestWords(spa, alphabet).collect(Collectors.toList()); - final List> testWords = Streams.stream(new SPATestsIterator<>(spa, - (dfa, alph) -> new WMethodTestsIterator<>( + final List> testWords = IteratorUtil.stream(new SPATestsIterator<>(spa, + (dfa, alph) -> new WMethodTestsIterator<>( dfa, alph, lookahead))) - .collect(Collectors.toList()); + .collect(Collectors.toList()); Assert.assertEquals(eqWords, testWords); } diff --git a/oracles/equivalence-oracles/src/test/java/de/learnlib/oracle/equivalence/spa/WpMethodEQOracleTest.java b/oracles/equivalence-oracles/src/test/java/de/learnlib/oracle/equivalence/spa/WpMethodEQOracleTest.java index ce375185ab..02e394047c 100644 --- a/oracles/equivalence-oracles/src/test/java/de/learnlib/oracle/equivalence/spa/WpMethodEQOracleTest.java +++ b/oracles/equivalence-oracles/src/test/java/de/learnlib/oracle/equivalence/spa/WpMethodEQOracleTest.java @@ -19,12 +19,12 @@ import java.util.Random; import java.util.stream.Collectors; -import com.google.common.collect.Streams; import de.learnlib.oracle.membership.SimulatorOracle; import net.automatalib.alphabet.ProceduralInputAlphabet; import net.automatalib.alphabet.impl.Alphabets; import net.automatalib.alphabet.impl.DefaultProceduralInputAlphabet; import net.automatalib.automaton.procedural.SPA; +import net.automatalib.common.util.collection.IteratorUtil; import net.automatalib.util.automaton.conformance.SPATestsIterator; import net.automatalib.util.automaton.conformance.WpMethodTestsIterator; import net.automatalib.util.automaton.random.RandomAutomata; @@ -47,12 +47,12 @@ public void testOracle() { final WpMethodEQOracle oracle = new WpMethodEQOracle<>(new SimulatorOracle<>(spa), lookahead); final List> eqWords = oracle.generateTestWords(spa, alphabet).collect(Collectors.toList()); - final List> testWords = Streams.stream(new SPATestsIterator<>(spa, - (dfa, alph) -> new WpMethodTestsIterator<>( - dfa, - alph, - lookahead))) - .collect(Collectors.toList()); + final List> testWords = IteratorUtil.stream(new SPATestsIterator<>(spa, + (dfa, alph) -> new WpMethodTestsIterator<>( + dfa, + alph, + lookahead))) + .collect(Collectors.toList()); Assert.assertEquals(eqWords, testWords); } diff --git a/oracles/equivalence-oracles/src/test/java/de/learnlib/oracle/equivalence/spmm/WMethodEQOracleTest.java b/oracles/equivalence-oracles/src/test/java/de/learnlib/oracle/equivalence/spmm/WMethodEQOracleTest.java index 863b7b5153..c5d5c9ba21 100644 --- a/oracles/equivalence-oracles/src/test/java/de/learnlib/oracle/equivalence/spmm/WMethodEQOracleTest.java +++ b/oracles/equivalence-oracles/src/test/java/de/learnlib/oracle/equivalence/spmm/WMethodEQOracleTest.java @@ -19,7 +19,6 @@ import java.util.Random; import java.util.stream.Collectors; -import com.google.common.collect.Streams; import de.learnlib.oracle.membership.SimulatorOracle; import net.automatalib.alphabet.ProceduralInputAlphabet; import net.automatalib.alphabet.ProceduralOutputAlphabet; @@ -27,6 +26,7 @@ import net.automatalib.alphabet.impl.DefaultProceduralInputAlphabet; import net.automatalib.alphabet.impl.DefaultProceduralOutputAlphabet; import net.automatalib.automaton.procedural.SPMM; +import net.automatalib.common.util.collection.IteratorUtil; import net.automatalib.util.automaton.conformance.SPMMWMethodTestsIterator; import net.automatalib.util.automaton.random.RandomAutomata; import net.automatalib.word.Word; @@ -54,8 +54,7 @@ public void testOracle() { final List> eqWords = oracle.generateTestWords(spmm, inputAlphabet).collect(Collectors.toList()); final List> testWords = - Streams.stream(new SPMMWMethodTestsIterator<>(spmm, inputAlphabet, lookahead)) - .collect(Collectors.toList()); + IteratorUtil.list(new SPMMWMethodTestsIterator<>(spmm, inputAlphabet, lookahead)); Assert.assertEquals(eqWords, testWords); } diff --git a/oracles/parallelism/pom.xml b/oracles/parallelism/pom.xml index 3c878708b7..737ad68078 100644 --- a/oracles/parallelism/pom.xml +++ b/oracles/parallelism/pom.xml @@ -46,11 +46,6 @@ limitations under the License. - - com.google.guava - guava - - net.automatalib automata-api @@ -59,10 +54,6 @@ limitations under the License. net.automatalib automata-commons-util - - net.automatalib - automata-commons-smartcollections - org.checkerframework diff --git a/oracles/parallelism/src/main/java/de/learnlib/oracle/parallelism/AbstractDynamicBatchProcessor.java b/oracles/parallelism/src/main/java/de/learnlib/oracle/parallelism/AbstractDynamicBatchProcessor.java index cd1c276ad0..73a1dcfd5c 100644 --- a/oracles/parallelism/src/main/java/de/learnlib/oracle/parallelism/AbstractDynamicBatchProcessor.java +++ b/oracles/parallelism/src/main/java/de/learnlib/oracle/parallelism/AbstractDynamicBatchProcessor.java @@ -23,12 +23,12 @@ import java.util.concurrent.Future; import java.util.function.Supplier; -import com.google.common.base.Throwables; import de.learnlib.exception.BatchInterruptedException; import de.learnlib.oracle.BatchProcessor; import de.learnlib.oracle.ThreadPool; import de.learnlib.setting.LearnLibProperty; import de.learnlib.setting.LearnLibSettings; +import net.automatalib.common.util.exception.ExceptionUtil; import org.checkerframework.checker.index.qual.NonNegative; /** @@ -115,7 +115,7 @@ public void processBatch(Collection queries) { future.get(); } } catch (ExecutionException e) { - Throwables.throwIfUnchecked(e.getCause()); + ExceptionUtil.throwIfUnchecked(e.getCause()); throw new AssertionError("Runnables must not throw checked exceptions", e); } catch (InterruptedException e) { Thread.interrupted(); diff --git a/oracles/parallelism/src/main/java/de/learnlib/oracle/parallelism/AbstractDynamicBatchProcessorBuilder.java b/oracles/parallelism/src/main/java/de/learnlib/oracle/parallelism/AbstractDynamicBatchProcessorBuilder.java index f9a70d0196..94c7338057 100644 --- a/oracles/parallelism/src/main/java/de/learnlib/oracle/parallelism/AbstractDynamicBatchProcessorBuilder.java +++ b/oracles/parallelism/src/main/java/de/learnlib/oracle/parallelism/AbstractDynamicBatchProcessorBuilder.java @@ -21,7 +21,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Supplier; -import com.google.common.base.Preconditions; import de.learnlib.oracle.BatchProcessor; import de.learnlib.oracle.ThreadPool.PoolPolicy; import net.automatalib.common.util.concurrent.ScalingThreadPoolExecutor; @@ -55,7 +54,9 @@ public AbstractDynamicBatchProcessorBuilder(Supplier oracleSupplier } public AbstractDynamicBatchProcessorBuilder(Collection oracles) { - Preconditions.checkArgument(!oracles.isEmpty(), "No oracles specified"); + if (oracles.isEmpty()) { + throw new IllegalArgumentException("No oracles specified"); + } this.oracles = oracles; this.oracleSupplier = null; } diff --git a/oracles/parallelism/src/main/java/de/learnlib/oracle/parallelism/AbstractStaticBatchProcessor.java b/oracles/parallelism/src/main/java/de/learnlib/oracle/parallelism/AbstractStaticBatchProcessor.java index c3f479c999..6a39e6caab 100644 --- a/oracles/parallelism/src/main/java/de/learnlib/oracle/parallelism/AbstractStaticBatchProcessor.java +++ b/oracles/parallelism/src/main/java/de/learnlib/oracle/parallelism/AbstractStaticBatchProcessor.java @@ -24,13 +24,13 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; -import com.google.common.base.Throwables; import de.learnlib.exception.BatchInterruptedException; import de.learnlib.oracle.BatchProcessor; import de.learnlib.oracle.ThreadPool; import de.learnlib.setting.LearnLibProperty; import de.learnlib.setting.LearnLibSettings; -import net.automatalib.common.smartcollection.ArrayStorage; +import net.automatalib.common.util.array.ArrayStorage; +import net.automatalib.common.util.exception.ExceptionUtil; import org.checkerframework.checker.index.qual.NonNegative; /** @@ -144,9 +144,9 @@ public void processBatch(Collection queries) { for (Future f : futures) { f.get(); } - } catch (ExecutionException ex) { - Throwables.throwIfUnchecked(ex.getCause()); - throw new AssertionError("Runnable must not throw checked exceptions", ex); + } catch (ExecutionException e) { + ExceptionUtil.throwIfUnchecked(e.getCause()); + throw new AssertionError("Runnable must not throw checked exceptions", e); } catch (InterruptedException ex) { Thread.interrupted(); throw new BatchInterruptedException(ex); diff --git a/oracles/parallelism/src/main/java/de/learnlib/oracle/parallelism/AbstractStaticBatchProcessorBuilder.java b/oracles/parallelism/src/main/java/de/learnlib/oracle/parallelism/AbstractStaticBatchProcessorBuilder.java index ff7cb8c1e4..06febc3490 100644 --- a/oracles/parallelism/src/main/java/de/learnlib/oracle/parallelism/AbstractStaticBatchProcessorBuilder.java +++ b/oracles/parallelism/src/main/java/de/learnlib/oracle/parallelism/AbstractStaticBatchProcessorBuilder.java @@ -20,7 +20,6 @@ import java.util.List; import java.util.function.Supplier; -import com.google.common.base.Preconditions; import de.learnlib.oracle.BatchProcessor; import de.learnlib.oracle.ThreadPool.PoolPolicy; import org.checkerframework.checker.index.qual.NonNegative; @@ -45,7 +44,9 @@ public abstract class AbstractStaticBatchProcessorBuilder oracles) { - Preconditions.checkArgument(!oracles.isEmpty(), "No oracles specified"); + if (oracles.isEmpty()) { + throw new IllegalArgumentException("No oracles specified"); + } this.oracles = oracles; this.oracleSupplier = null; } diff --git a/oracles/parallelism/src/main/java/de/learnlib/oracle/parallelism/ParallelOracleBuilders.java b/oracles/parallelism/src/main/java/de/learnlib/oracle/parallelism/ParallelOracleBuilders.java index f13a281668..e9ae0976a1 100644 --- a/oracles/parallelism/src/main/java/de/learnlib/oracle/parallelism/ParallelOracleBuilders.java +++ b/oracles/parallelism/src/main/java/de/learnlib/oracle/parallelism/ParallelOracleBuilders.java @@ -18,8 +18,6 @@ import java.util.Collection; import java.util.function.Supplier; -import com.google.common.base.Preconditions; -import com.google.common.collect.Lists; import de.learnlib.oracle.MembershipOracle; import de.learnlib.oracle.OmegaMembershipOracle; import de.learnlib.oracle.ThreadPool.PoolPolicy; @@ -29,6 +27,7 @@ import de.learnlib.sul.ObservableSUL; import de.learnlib.sul.SUL; import de.learnlib.sul.StateLocalInputSUL; +import net.automatalib.common.util.collection.CollectionUtil; import net.automatalib.word.Word; /** @@ -67,8 +66,6 @@ */ public final class ParallelOracleBuilders { - private static final String FORKABLE_SUL_ERR = "SUL must be forkable for parallel processing"; - private ParallelOracleBuilders() { // prevent instantiation } @@ -87,7 +84,7 @@ private ParallelOracleBuilders() { * @return a preconfigured oracle builder */ public static DynamicParallelOracleBuilder> newDynamicParallelOracle(SUL sul) { - Preconditions.checkArgument(sul.canFork(), FORKABLE_SUL_ERR); + checkFork(sul); return new DynamicParallelOracleBuilder<>(toSupplier(sul)); } @@ -109,7 +106,7 @@ public static DynamicParallelOracleBuilder> newDynamicParallel */ public static DynamicParallelOracleBuilder> newDynamicParallelOracle(StateLocalInputSUL sul, O undefinedInput) { - Preconditions.checkArgument(sul.canFork(), FORKABLE_SUL_ERR); + checkFork(sul); return new DynamicParallelOracleBuilder<>(toSupplier(sul, undefinedInput)); } @@ -146,7 +143,7 @@ public static DynamicParallelOracleBuilder newDynamicParallelOracle @SafeVarargs public static DynamicParallelOracleBuilder newDynamicParallelOracle(MembershipOracle firstOracle, MembershipOracle... otherOracles) { - return newDynamicParallelOracle(Lists.asList(firstOracle, otherOracles)); + return newDynamicParallelOracle(CollectionUtil.list(firstOracle, otherOracles)); } /** @@ -181,7 +178,7 @@ public static DynamicParallelOracleBuilder newDynamicParallelOracle * @return a preconfigured oracle builder */ public static DynamicParallelOmegaOracleBuilder> newDynamicParallelOmegaOracle(ObservableSUL sul) { - Preconditions.checkArgument(sul.canFork(), FORKABLE_SUL_ERR); + checkFork(sul); // instantiate inner supplier to resolve generics return new DynamicParallelOmegaOracleBuilder<>(toSupplier(sul)::get); } @@ -224,7 +221,7 @@ public static DynamicParallelOmegaOracleBuilder newDynamicPar public static DynamicParallelOmegaOracleBuilder newDynamicParallelOmegaOracle( OmegaMembershipOracle firstOracle, OmegaMembershipOracle... otherOracles) { - return newDynamicParallelOmegaOracle(Lists.asList(firstOracle, otherOracles)); + return newDynamicParallelOmegaOracle(CollectionUtil.list(firstOracle, otherOracles)); } /** @@ -262,7 +259,7 @@ public static DynamicParallelOmegaOracleBuilder newDynamicPar * @return a preconfigured oracle builder */ public static StaticParallelOracleBuilder> newStaticParallelOracle(SUL sul) { - Preconditions.checkArgument(sul.canFork(), FORKABLE_SUL_ERR); + checkFork(sul); return new StaticParallelOracleBuilder<>(toSupplier(sul)); } @@ -284,7 +281,7 @@ public static StaticParallelOracleBuilder> newStaticParallelOr */ public static StaticParallelOracleBuilder> newStaticParallelOracle(StateLocalInputSUL sul, O undefinedInput) { - Preconditions.checkArgument(sul.canFork(), FORKABLE_SUL_ERR); + checkFork(sul); return new StaticParallelOracleBuilder<>(toSupplier(sul, undefinedInput)); } @@ -323,7 +320,7 @@ public static StaticParallelOracleBuilder newStaticParallelOracle(S @SafeVarargs public static StaticParallelOracleBuilder newStaticParallelOracle(MembershipOracle firstOracle, MembershipOracle... otherOracles) { - return newStaticParallelOracle(Lists.asList(firstOracle, otherOracles)); + return newStaticParallelOracle(CollectionUtil.list(firstOracle, otherOracles)); } /** @@ -358,7 +355,7 @@ public static StaticParallelOracleBuilder newStaticParallelOracle(C * @return a preconfigured oracle builder */ public static StaticParallelOmegaOracleBuilder> newStaticParallelOmegaOracle(ObservableSUL sul) { - Preconditions.checkArgument(sul.canFork(), FORKABLE_SUL_ERR); + checkFork(sul); // instantiate inner supplier to resolve generics return new StaticParallelOmegaOracleBuilder<>(toSupplier(sul)::get); } @@ -400,7 +397,7 @@ public static StaticParallelOmegaOracleBuilder newStaticParal @SafeVarargs public static StaticParallelOmegaOracleBuilder newStaticParallelOmegaOracle(OmegaMembershipOracle firstOracle, OmegaMembershipOracle... otherOracles) { - return newStaticParallelOmegaOracle(Lists.asList(firstOracle, otherOracles)); + return newStaticParallelOmegaOracle(CollectionUtil.list(firstOracle, otherOracles)); } /** @@ -436,4 +433,10 @@ private static Supplier> toSupplier(StateL private static Supplier>> toSupplier(ObservableSUL sul) { return () -> AbstractSULOmegaOracle.newOracle(sul.fork()); } + + private static void checkFork(SUL sul) { + if (!sul.canFork()) { + throw new IllegalArgumentException("SUL must be forkable for parallel processing"); + } + } } diff --git a/oracles/parallelism/src/main/java/module-info.java b/oracles/parallelism/src/main/java/module-info.java index cf29aad47f..04216c7436 100644 --- a/oracles/parallelism/src/main/java/module-info.java +++ b/oracles/parallelism/src/main/java/module-info.java @@ -28,13 +28,11 @@ */ open module de.learnlib.oracle.parallelism { - requires com.google.common; requires de.learnlib.api; requires de.learnlib.oracle.membership; requires de.learnlib.setting; requires net.automatalib.api; requires net.automatalib.common.util; - requires net.automatalib.common.smartcollection; requires org.checkerframework.checker.qual; exports de.learnlib.oracle.parallelism; diff --git a/pom.xml b/pom.xml index 45627b027b..c3b8bd5479 100644 --- a/pom.xml +++ b/pom.xml @@ -201,6 +201,9 @@ limitations under the License. 1.8 1.8 8 + 11 + 11 + 11 @@ -238,7 +241,6 @@ limitations under the License. 1.11.1 3.40.0 9.3 - 32.1.2-jre 1.13.0 2.3.1 1.3.12 @@ -251,7 +253,6 @@ limitations under the License. http://learnlib.github.io/automatalib/maven-site/${automatalib.version}/apidocs/ https://checkerframework.org/releases/${checkerframework.version}/api/ - http://google.github.io/guava/releases/${guava.version}/api/docs/ - - com.google.guava - guava - ${guava.version} - - - com.google.code.findbugs - jsr305 - - - - com.squareup @@ -812,7 +800,6 @@ limitations under the License. true false - ${guava.apidocs} diff --git a/test-support/test-support/pom.xml b/test-support/test-support/pom.xml index 43d7c2fc29..20a2d850e3 100644 --- a/test-support/test-support/pom.xml +++ b/test-support/test-support/pom.xml @@ -40,10 +40,6 @@ - - com.google.guava - guava - com.thoughtworks.xstream xstream diff --git a/test-support/test-support/src/main/java/de/learnlib/testsupport/AbstractVisualizationTest.java b/test-support/test-support/src/main/java/de/learnlib/testsupport/AbstractVisualizationTest.java index 6e0d4facda..9def270a2f 100644 --- a/test-support/test-support/src/main/java/de/learnlib/testsupport/AbstractVisualizationTest.java +++ b/test-support/test-support/src/main/java/de/learnlib/testsupport/AbstractVisualizationTest.java @@ -18,7 +18,6 @@ import java.io.IOException; import java.io.InputStream; -import com.google.common.io.CharStreams; import de.learnlib.algorithm.LearningAlgorithm; import de.learnlib.driver.simulator.MealySimulatorSUL; import de.learnlib.query.DefaultQuery; @@ -66,7 +65,7 @@ public AbstractVisualizationTest() { protected String resourceAsString(String resourceName) throws IOException { try (InputStream is = getClass().getResourceAsStream(resourceName)) { assert is != null; - return CharStreams.toString(IOUtil.asBufferedUTF8Reader(is)); + return IOUtil.toString(IOUtil.asBufferedUTF8Reader(is)); } } diff --git a/test-support/test-support/src/main/java/module-info.java b/test-support/test-support/src/main/java/module-info.java index 7ab636a5bc..56107ca58e 100644 --- a/test-support/test-support/src/main/java/module-info.java +++ b/test-support/test-support/src/main/java/module-info.java @@ -30,7 +30,6 @@ */ open module de.learnlib.testsupport { - requires com.google.common; requires de.learnlib.api; requires de.learnlib.common.util; requires de.learnlib.driver.simulator;