Skip to content

Commit

Permalink
Drop guava (#119)
Browse files Browse the repository at this point in the history
* initial removal

* cleanups
  • Loading branch information
mtf90 authored Jan 16, 2024
1 parent 41f7555 commit 90e8553
Show file tree
Hide file tree
Showing 112 changed files with 324 additions and 432 deletions.
5 changes: 0 additions & 5 deletions algorithms/active/aaar/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ limitations under the License.
</dependency>

<!-- external -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>

<dependency>
<groupId>net.automatalib</groupId>
<artifactId>automata-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -83,7 +84,7 @@ public AbstractExplicitAAARLearner(LearnerConstructor<L, CI, D> 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);
Expand Down
1 change: 0 additions & 1 deletion algorithms/active/aaar/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -50,7 +50,7 @@ public AbstractAAARTest(LearningExample<I, A> learningExample) {
public void testAbstractHypothesisEquivalence() {

final WpMethodTestsIterator<I> iter = new WpMethodTestsIterator<>(automaton, alphabet);
final ArrayList<Word<I>> testCases = Lists.newArrayList(iter);
final List<Word<I>> testCases = IteratorUtil.list(iter);

final SampleSetEQOracle<I, D> eqo = new SampleSetEQOracle<>(false);
eqo.addAll(new SimulatorOracle<>(automaton), testCases);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 0 additions & 5 deletions algorithms/active/adt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ limitations under the License.
</dependency>

<!-- external -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>

<dependency>
<groupId>net.automatalib</groupId>
<artifactId>automata-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

Expand Down Expand Up @@ -62,7 +62,7 @@ public <S, I, O> Set<ReplacementResult<S, I, O>> computeReplacements(MealyMachin
final PriorityQueue<Set<S>> queue = new PriorityQueue<>(candidates.size(), Comparator.comparingInt(Set::size));
for (ADTNode<S, I, O> node : candidates) {
final Set<ADTNode<S, I, O>> leaves = ADTUtil.collectLeaves(node);
final Set<S> set = Sets.newHashSetWithExpectedSize(leaves.size());
final Set<S> set = new HashSet<>(HashUtil.capacity(leaves.size()));

for (ADTNode<S, I, O> l : leaves) {
set.add(l.getHypothesisState());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -52,17 +52,18 @@ public <S, I, O> Set<ReplacementResult<S, I, O>> computeReplacements(MealyMachin

final Set<ADTNode<S, I, O>> candidates = ADTUtil.collectADSNodes(adt.getRoot());
candidates.remove(adt.getRoot());
final Map<ADTNode<S, I, O>, 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<ADTNode<S, I, O>> sortedCandidates = new ArrayList<>(candidates);
sortedCandidates.sort(Comparator.comparingDouble(candidatesScore::get));
// cache scores to prevent expensive recalculations during sorting
final List<Pair<ADTNode<S, I, O>, Double>> sortedCandidates = new ArrayList<>(candidates.size());
for (ADTNode<S, I, O> 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<S, I, O> node : sortedCandidates) {
for (Pair<ADTNode<S, I, O>, Double> candidate : sortedCandidates) {
final ADTNode<S, I, O> node = candidate.getFirst();
final Set<S> targetStates = ADTUtil.collectHypothesisStates(node);

// check if we can extendLeaf the parent ADS
Expand Down
1 change: 0 additions & 1 deletion algorithms/active/adt/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 0 additions & 5 deletions algorithms/active/dhc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ limitations under the License.
</dependency>

<!-- external -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>

<dependency>
<groupId>net.automatalib</groupId>
<artifactId>automata-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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<Word<O>> 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
Expand All @@ -179,7 +175,7 @@ public void startLearning() {
// assemble output signature
List<Word<O>> sig = new ArrayList<>(splitters.size());
for (DefaultQuery<I, Word<O>> query : queries) {
sig.add(deduplicator.intern(query.getOutput()));
sig.add(query.getOutput());
}

Integer sibling = signatures.get(sig);
Expand Down Expand Up @@ -257,7 +253,7 @@ public void addAlphabetSymbol(I symbol) {
if (!this.splitters.contains(Word.fromLetter(symbol))) {
final Iterator<Word<I>> splitterIterator = this.splitters.iterator();
final LinkedHashSet<Word<I>> 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++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -42,7 +43,7 @@ public class MealyDHCState<I, O> {
MutableMapping<Integer, MealyDHC.QueueElement<I, O>> 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<I, O> elem = accessSequences.get(s);
Expand Down
1 change: 0 additions & 1 deletion algorithms/active/dhc/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion algorithms/active/kearns-vazirani/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ limitations under the License.
</dependency>
<dependency>
<groupId>net.automatalib</groupId>
<artifactId>automata-commons-smartcollections</artifactId>
<artifactId>automata-commons-util</artifactId>
</dependency>
<dependency>
<groupId>net.automatalib</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 0 additions & 5 deletions algorithms/active/observation-pack-vpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ limitations under the License.
</dependency>

<!-- external -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>

<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -134,7 +134,7 @@ protected class PrefixTransformAcex extends AbstractBaseCounterexample<Boolean>
public PrefixTransformAcex(Word<I> word, ContextPair<I> 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<HypLoc<I>> getBaseState() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 90e8553

Please sign in to comment.