Skip to content

Commit 418e030

Browse files
authored
Drop guava (#67)
* initial removal * refactorings, documentation, tests * cleanups * refactorings * add additional utility method * bump guava version * formatting * cleanups * formatting * extract functionality * Revert "extract functionality" This reverts commit de93cd7. * simplify computation
1 parent 79650c5 commit 418e030

File tree

205 files changed

+1828
-972
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

205 files changed

+1828
-972
lines changed

CHANGELOG.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1616
* You now require at least a JDK 11 to build AutomataLib.
1717
* We use modules to better structure the aggregated JavaDoc. Since there exist breaking changes between Java 8 and Java 9 regarding documentation (see package-list vs. element-list), you can no longer link against the AutomataLib documentation on JDK 8 builds.
1818
* Split packages had to be refactored. This mainly concerns code from the `automata-core` artifact whose packages have been extended by a `.impl` suffix. This somewhat reverts the refactorings of the previous release (sorry for the back and forth) but since it only affects import statements, it should be fairly easy to address with IDE automation.
19-
* The `net:automatalib.tooling:automata-build-tools` module has been renamed to `net.automatalib:automata-build-config`.
20-
* The `Alphabets#toGrowingAlphabetOrThrowException` method has been moved to `Alphabet#asGrowingAlphabetOrThrowException` so that one does not require an `automata-core` dependency for a simple cast.
21-
* The `Visualization` factory has been moved from the `automata-core` artifact to the `automata-api` artifact. Furthermore, the previous `DummyVP` has been replaced with a `NoopVP` that does not show a swing window anymore when no proper VisualizationProvider is configured but instead logs an error message. This allows us to drop the `java.desktop` (module) dependency for headless setups and only require it in actual visualizers (DOT, JUNG, etc.).
19+
* Some other refactorings include:
20+
* The `AWUtil` class has been moved from `net.automatalib.common.util.array` to `net.automatalib.common.smartcollection` (in the `automata-commons-smartcollections` artifact).
21+
* The `{Resizing,}ArrayStorage` and `ArrayUtil` classes have been moved from `net.automatalib.common.smartcollection` to `net.automatalib.common.util.array` (in the `automata-commons-util` artifact).
22+
* `CollectionsUtil#allTuples` has been moved to `IterableUtil#allTuples`.
23+
* `CollectionsUtil#cartesianProduct` has been moved to `IterableUtil#cartesianProduct`.
24+
* `CollectionsUtil` has been renamed to `CollectionUtil`.
25+
* The `net:automatalib.tooling:automata-build-tools` module has been renamed to `net.automatalib:automata-build-config`.
26+
* The `Alphabets#toGrowingAlphabetOrThrowException` method has been moved to `Alphabet#asGrowingAlphabetOrThrowException` so that one does not require an `automata-core` dependency for a simple cast.
27+
* The `Visualization` factory has been moved from the `automata-core` artifact to the `automata-api` artifact. Furthermore, the previous `DummyVP` has been replaced with a `NoopVP` that does not show a swing window anymore when no proper VisualizationProvider is configured but instead logs an error message. This allows us to drop the `java.desktop` (module) dependency for headless setups and only require it in actual visualizers (DOT, JUNG, etc.).
2228

2329
### Removed
2430

api/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ limitations under the License.
4848
</dependency>
4949

5050
<!-- external -->
51-
<dependency>
52-
<groupId>com.google.guava</groupId>
53-
<artifactId>guava</artifactId>
54-
</dependency>
5551
<dependency>
5652
<groupId>org.slf4j</groupId>
5753
<artifactId>slf4j-api</artifactId>

api/src/main/java/module-info.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
*/
3737
open module net.automatalib.api {
3838

39-
requires com.google.common;
4039
requires net.automatalib.common.smartcollection;
4140
requires net.automatalib.common.util;
4241
requires org.checkerframework.checker.qual;

api/src/main/java/net/automatalib/automaton/fsa/FiniteStateAcceptor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
import java.util.Collections;
2121
import java.util.List;
2222

23-
import com.google.common.collect.Iterables;
2423
import net.automatalib.automaton.UniversalAutomaton;
2524
import net.automatalib.automaton.concept.OutputAutomaton;
2625
import net.automatalib.automaton.concept.SuffixOutput;
2726
import net.automatalib.automaton.graph.TransitionEdge;
2827
import net.automatalib.automaton.graph.UniversalAutomatonGraphView;
2928
import net.automatalib.automaton.visualization.FSAVisualizationHelper;
29+
import net.automatalib.common.util.collection.IterableUtil;
3030
import net.automatalib.graph.UniversalGraph;
3131
import net.automatalib.ts.acceptor.AcceptorTS;
3232
import net.automatalib.visualization.VisualizationHelper;
@@ -44,7 +44,7 @@ public interface FiniteStateAcceptor<S, I> extends AcceptorTS<S, I>,
4444

4545
@Override
4646
default Boolean computeSuffixOutput(Iterable<? extends I> prefix, Iterable<? extends I> suffix) {
47-
Iterable<I> input = Iterables.concat(prefix, suffix);
47+
Iterable<I> input = IterableUtil.concat(prefix, suffix);
4848
return computeOutput(input);
4949
}
5050

api/src/main/java/net/automatalib/automaton/helper/SimpleStateIDs.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@
1616
package net.automatalib.automaton.helper;
1717

1818
import java.util.ArrayList;
19+
import java.util.HashMap;
1920
import java.util.List;
2021
import java.util.Map;
2122

22-
import com.google.common.collect.Maps;
2323
import net.automatalib.automaton.concept.StateIDs;
2424
import net.automatalib.automaton.simple.SimpleAutomaton;
25+
import net.automatalib.common.util.HashUtil;
2526

2627
public class SimpleStateIDs<S> implements StateIDs<S> {
2728

@@ -31,7 +32,7 @@ public class SimpleStateIDs<S> implements StateIDs<S> {
3132
public SimpleStateIDs(SimpleAutomaton<S, ?> automaton) {
3233
this.states = new ArrayList<>(automaton.getStates());
3334
int numStates = this.states.size();
34-
this.stateIds = Maps.newHashMapWithExpectedSize(numStates);
35+
this.stateIds = new HashMap<>(HashUtil.capacity(numStates));
3536

3637
for (int i = 0; i < numStates; i++) {
3738
S state = this.states.get(i);

api/src/main/java/net/automatalib/automaton/helper/StateIDGrowingMapping.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package net.automatalib.automaton.helper;
1717

1818
import net.automatalib.automaton.concept.StateIDs;
19-
import net.automatalib.common.smartcollection.ResizingArrayStorage;
19+
import net.automatalib.common.util.array.ResizingArrayStorage;
2020
import net.automatalib.common.util.mapping.MutableMapping;
2121
import org.checkerframework.checker.nullness.qual.Nullable;
2222

api/src/main/java/net/automatalib/automaton/visualization/ProceduralVisualizationHelper.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717

1818
import java.util.ArrayList;
1919
import java.util.Collection;
20+
import java.util.HashMap;
2021
import java.util.List;
2122
import java.util.Map;
2223
import java.util.Map.Entry;
2324

24-
import com.google.common.collect.Maps;
2525
import net.automatalib.alphabet.Alphabet;
2626
import net.automatalib.automaton.UniversalDeterministicAutomaton;
2727
import net.automatalib.automaton.concept.StateIDs;
28+
import net.automatalib.common.util.HashUtil;
2829
import net.automatalib.common.util.Pair;
2930
import net.automatalib.common.util.Triple;
3031
import net.automatalib.visualization.DefaultVisualizationHelper;
@@ -51,7 +52,7 @@ public ProceduralVisualizationHelper(Alphabet<I> internalAlphabet,
5152
Map<I, ? extends UniversalDeterministicAutomaton<? extends S, I, ?, ?, ?>> subModels) {
5253
this.internalAlphabet = internalAlphabet;
5354
this.subModels = (Map<I, UniversalDeterministicAutomaton<S, I, ?, ?, ?>>) subModels;
54-
this.stateIDs = Maps.newHashMapWithExpectedSize(subModels.size());
55+
this.stateIDs = new HashMap<>(HashUtil.capacity(subModels.size()));
5556

5657
for (Entry<I, ? extends UniversalDeterministicAutomaton<? extends S, I, ?, ?, ?>> e : subModels.entrySet()) {
5758
this.stateIDs.put(e.getKey(), (StateIDs<S>) e.getValue().stateIDs());

api/src/main/java/net/automatalib/automaton/vpa/SEVPA.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717

1818
import java.util.List;
1919

20-
import com.google.common.collect.Iterables;
2120
import net.automatalib.alphabet.VPAlphabet;
2221
import net.automatalib.automaton.concept.FiniteRepresentation;
2322
import net.automatalib.automaton.concept.InputAlphabetHolder;
2423
import net.automatalib.automaton.concept.SuffixOutput;
2524
import net.automatalib.automaton.vpa.SEVPAGraphView.SevpaViewEdge;
25+
import net.automatalib.common.util.collection.IterableUtil;
2626
import net.automatalib.graph.Graph;
2727
import net.automatalib.graph.concept.GraphViewable;
2828
import net.automatalib.ts.acceptor.DeterministicAcceptorTS;
@@ -73,7 +73,7 @@ default Boolean computeOutput(Iterable<? extends I> input) {
7373

7474
@Override
7575
default Boolean computeSuffixOutput(Iterable<? extends I> prefix, Iterable<? extends I> suffix) {
76-
return this.accepts(Iterables.concat(prefix, suffix));
76+
return this.accepts(IterableUtil.concat(prefix, suffix));
7777
}
7878

7979
@Override

api/src/main/java/net/automatalib/graph/Graph.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@
1818
import java.util.Collection;
1919
import java.util.Iterator;
2020

21-
import com.google.common.collect.Collections2;
22-
import com.google.common.collect.Iterators;
23-
import com.google.common.collect.Lists;
21+
import net.automatalib.common.util.collection.CollectionUtil;
22+
import net.automatalib.common.util.collection.IteratorUtil;
2423
import net.automatalib.visualization.DefaultVisualizationHelper;
2524
import net.automatalib.visualization.VisualizationHelper;
2625

@@ -54,7 +53,7 @@ public interface Graph<N, E> extends IndefiniteGraph<N, E>, SimpleGraph<N> {
5453
* @return a collection containing the outgoing edges
5554
*/
5655
default Collection<N> getAdjacentNodes(N node) {
57-
return Collections2.transform(getOutgoingEdges(node), this::getTarget);
56+
return CollectionUtil.map(getOutgoingEdges(node), this::getTarget);
5857
}
5958

6059
@Override
@@ -99,15 +98,15 @@ default Iterator<E> getOutgoingEdgesIterator(int node) {
9998
* (Finite) int-abstracted version of {@link #getEdgesBetween(Object, Object)}.
10099
*/
101100
default Collection<E> getEdgesBetween(int from, int to) {
102-
return Lists.newArrayList(Iterators.filter(getOutgoingEdgesIterator(from), e -> getIntTarget(e) == to));
101+
return IteratorUtil.list(IteratorUtil.filter(getOutgoingEdgesIterator(from), e -> getIntTarget(e) == to));
103102
}
104103

105104
/**
106105
* Int-abstracted version of {@link #isConnected(Object, Object)}.
107106
*/
108107
@Override
109108
default boolean isConnected(int source, int target) {
110-
return Iterators.any(getOutgoingEdgesIterator(source), e -> getIntTarget(e) == target);
109+
return IteratorUtil.any(getOutgoingEdgesIterator(source), e -> getIntTarget(e) == target);
111110
}
112111
}
113112
}

api/src/main/java/net/automatalib/graph/IndefiniteGraph.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import java.util.Iterator;
1919
import java.util.Objects;
2020

21-
import com.google.common.collect.Iterators;
21+
import net.automatalib.common.util.collection.IteratorUtil;
2222

2323
/**
2424
* Interface for an (indefinite) graph structure. A graph consists of nodes, each of which has outgoing edges connecting
@@ -62,12 +62,12 @@ public interface IndefiniteGraph<N, E> extends IndefiniteSimpleGraph<N> {
6262
* @return an iterator over the edges between the two nodes
6363
*/
6464
default Iterator<E> getEdgesBetween(N from, N to) {
65-
return Iterators.filter(getOutgoingEdgesIterator(from), e -> Objects.equals(getTarget(e), to));
65+
return IteratorUtil.filter(getOutgoingEdgesIterator(from), e -> Objects.equals(getTarget(e), to));
6666
}
6767

6868
@Override
6969
default Iterator<N> getAdjacentNodesIterator(N node) {
70-
return Iterators.transform(getOutgoingEdgesIterator(node), this::getTarget);
70+
return IteratorUtil.map(getOutgoingEdgesIterator(node), this::getTarget);
7171
}
7272

7373
}

0 commit comments

Comments
 (0)