Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
* You now require at least a JDK 11 to build AutomataLib.
* 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.
* 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.
* The `net:automatalib.tooling:automata-build-tools` module has been renamed to `net.automatalib:automata-build-config`.
* The `Alphabets#toGrowingAlphabetOrThrowException` method has been moved to `Alphabet#asGrowingAlphabetOrThrowException` so that one does not require an `automata-core` dependency for a simple cast.
* 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.).
* Some other refactorings include:
* The `AWUtil` class has been moved from `net.automatalib.common.util.array` to `net.automatalib.common.smartcollection` (in the `automata-commons-smartcollections` artifact).
* 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).
* `CollectionsUtil#allTuples` has been moved to `IterableUtil#allTuples`.
* `CollectionsUtil#cartesianProduct` has been moved to `IterableUtil#cartesianProduct`.
* `CollectionsUtil` has been renamed to `CollectionUtil`.
* The `net:automatalib.tooling:automata-build-tools` module has been renamed to `net.automatalib:automata-build-config`.
* The `Alphabets#toGrowingAlphabetOrThrowException` method has been moved to `Alphabet#asGrowingAlphabetOrThrowException` so that one does not require an `automata-core` dependency for a simple cast.
* 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.).

### Removed

Expand Down
4 changes: 0 additions & 4 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ limitations under the License.
</dependency>

<!-- external -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand Down
1 change: 0 additions & 1 deletion api/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
*/
open module net.automatalib.api {

requires com.google.common;
requires net.automatalib.common.smartcollection;
requires net.automatalib.common.util;
requires org.checkerframework.checker.qual;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
import java.util.Collections;
import java.util.List;

import com.google.common.collect.Iterables;
import net.automatalib.automaton.UniversalAutomaton;
import net.automatalib.automaton.concept.OutputAutomaton;
import net.automatalib.automaton.concept.SuffixOutput;
import net.automatalib.automaton.graph.TransitionEdge;
import net.automatalib.automaton.graph.UniversalAutomatonGraphView;
import net.automatalib.automaton.visualization.FSAVisualizationHelper;
import net.automatalib.common.util.collection.IterableUtil;
import net.automatalib.graph.UniversalGraph;
import net.automatalib.ts.acceptor.AcceptorTS;
import net.automatalib.visualization.VisualizationHelper;
Expand All @@ -44,7 +44,7 @@ public interface FiniteStateAcceptor<S, I> extends AcceptorTS<S, I>,

@Override
default Boolean computeSuffixOutput(Iterable<? extends I> prefix, Iterable<? extends I> suffix) {
Iterable<I> input = Iterables.concat(prefix, suffix);
Iterable<I> input = IterableUtil.concat(prefix, suffix);
return computeOutput(input);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
package net.automatalib.automaton.helper;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.common.collect.Maps;
import net.automatalib.automaton.concept.StateIDs;
import net.automatalib.automaton.simple.SimpleAutomaton;
import net.automatalib.common.util.HashUtil;

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

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

for (int i = 0; i < numStates; i++) {
S state = this.states.get(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package net.automatalib.automaton.helper;

import net.automatalib.automaton.concept.StateIDs;
import net.automatalib.common.smartcollection.ResizingArrayStorage;
import net.automatalib.common.util.array.ResizingArrayStorage;
import net.automatalib.common.util.mapping.MutableMapping;
import org.checkerframework.checker.nullness.qual.Nullable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.google.common.collect.Maps;
import net.automatalib.alphabet.Alphabet;
import net.automatalib.automaton.UniversalDeterministicAutomaton;
import net.automatalib.automaton.concept.StateIDs;
import net.automatalib.common.util.HashUtil;
import net.automatalib.common.util.Pair;
import net.automatalib.common.util.Triple;
import net.automatalib.visualization.DefaultVisualizationHelper;
Expand All @@ -51,7 +52,7 @@ public ProceduralVisualizationHelper(Alphabet<I> internalAlphabet,
Map<I, ? extends UniversalDeterministicAutomaton<? extends S, I, ?, ?, ?>> subModels) {
this.internalAlphabet = internalAlphabet;
this.subModels = (Map<I, UniversalDeterministicAutomaton<S, I, ?, ?, ?>>) subModels;
this.stateIDs = Maps.newHashMapWithExpectedSize(subModels.size());
this.stateIDs = new HashMap<>(HashUtil.capacity(subModels.size()));

for (Entry<I, ? extends UniversalDeterministicAutomaton<? extends S, I, ?, ?, ?>> e : subModels.entrySet()) {
this.stateIDs.put(e.getKey(), (StateIDs<S>) e.getValue().stateIDs());
Expand Down
4 changes: 2 additions & 2 deletions api/src/main/java/net/automatalib/automaton/vpa/SEVPA.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

import java.util.List;

import com.google.common.collect.Iterables;
import net.automatalib.alphabet.VPAlphabet;
import net.automatalib.automaton.concept.FiniteRepresentation;
import net.automatalib.automaton.concept.InputAlphabetHolder;
import net.automatalib.automaton.concept.SuffixOutput;
import net.automatalib.automaton.vpa.SEVPAGraphView.SevpaViewEdge;
import net.automatalib.common.util.collection.IterableUtil;
import net.automatalib.graph.Graph;
import net.automatalib.graph.concept.GraphViewable;
import net.automatalib.ts.acceptor.DeterministicAcceptorTS;
Expand Down Expand Up @@ -73,7 +73,7 @@ default Boolean computeOutput(Iterable<? extends I> input) {

@Override
default Boolean computeSuffixOutput(Iterable<? extends I> prefix, Iterable<? extends I> suffix) {
return this.accepts(Iterables.concat(prefix, suffix));
return this.accepts(IterableUtil.concat(prefix, suffix));
}

@Override
Expand Down
11 changes: 5 additions & 6 deletions api/src/main/java/net/automatalib/graph/Graph.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
import java.util.Collection;
import java.util.Iterator;

import com.google.common.collect.Collections2;
import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import net.automatalib.common.util.collection.CollectionUtil;
import net.automatalib.common.util.collection.IteratorUtil;
import net.automatalib.visualization.DefaultVisualizationHelper;
import net.automatalib.visualization.VisualizationHelper;

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

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

/**
* Int-abstracted version of {@link #isConnected(Object, Object)}.
*/
@Override
default boolean isConnected(int source, int target) {
return Iterators.any(getOutgoingEdgesIterator(source), e -> getIntTarget(e) == target);
return IteratorUtil.any(getOutgoingEdgesIterator(source), e -> getIntTarget(e) == target);
}
}
}
6 changes: 3 additions & 3 deletions api/src/main/java/net/automatalib/graph/IndefiniteGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import java.util.Iterator;
import java.util.Objects;

import com.google.common.collect.Iterators;
import net.automatalib.common.util.collection.IteratorUtil;

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

@Override
default Iterator<N> getAdjacentNodesIterator(N node) {
return Iterators.transform(getOutgoingEdgesIterator(node), this::getTarget);
return IteratorUtil.map(getOutgoingEdgesIterator(node), this::getTarget);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import java.util.Iterator;
import java.util.Objects;

import com.google.common.collect.Iterators;
import net.automatalib.common.util.collection.IteratorUtil;
import net.automatalib.common.util.mapping.MapMapping;
import net.automatalib.common.util.mapping.MutableMapping;
import org.checkerframework.checker.nullness.qual.Nullable;
Expand Down Expand Up @@ -53,7 +53,7 @@ public interface IndefiniteSimpleGraph<N> extends Iterable<N> {
* @return {@code true} if the nodes are connect, {@code false} otherwise
*/
default boolean isConnected(N source, N target) {
return Iterators.any(getAdjacentNodesIterator(source), n -> Objects.equals(n, target));
return IteratorUtil.any(getAdjacentNodesIterator(source), n -> Objects.equals(n, target));
}

/**
Expand Down
3 changes: 1 addition & 2 deletions api/src/main/java/net/automatalib/graph/SimpleGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.util.Collection;
import java.util.Iterator;

import com.google.common.collect.Iterators;
import net.automatalib.automaton.concept.FiniteRepresentation;
import net.automatalib.graph.concept.NodeIDs;
import net.automatalib.graph.helper.SimpleNodeIDs;
Expand Down Expand Up @@ -55,7 +54,7 @@ default NodeIDs<N> nodeIDs() {

@Override
default Iterator<N> iterator() {
return Iterators.unmodifiableIterator(getNodes().iterator());
return getNodes().iterator();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
package net.automatalib.graph.helper;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.common.collect.Maps;
import net.automatalib.common.util.HashUtil;
import net.automatalib.graph.SimpleGraph;
import net.automatalib.graph.concept.NodeIDs;

Expand All @@ -31,7 +32,7 @@ public class SimpleNodeIDs<N> implements NodeIDs<N> {
public SimpleNodeIDs(SimpleGraph<N> graph) {
this.nodes = new ArrayList<>(graph.getNodes());
int numNodes = this.nodes.size();
this.nodeIds = Maps.newHashMapWithExpectedSize(numNodes);
this.nodeIds = new HashMap<>(HashUtil.capacity(numNodes));

for (int i = 0; i < numNodes; i++) {
N node = this.nodes.get(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.google.common.collect.Maps;
import net.automatalib.common.util.HashUtil;
import net.automatalib.common.util.Pair;
import net.automatalib.graph.ProceduralModalProcessGraph;
import net.automatalib.visualization.DefaultVisualizationHelper;
Expand All @@ -36,7 +37,7 @@ public class CFMPSVisualizationHelper<N, L, E> extends DefaultVisualizationHelpe
@SuppressWarnings("unchecked")
public CFMPSVisualizationHelper(Map<L, ? extends ProceduralModalProcessGraph<? extends N, L, ? extends E, ?, ?>> pmpgs) {

this.visualizers = Maps.newHashMapWithExpectedSize(pmpgs.size());
this.visualizers = new HashMap<>(HashUtil.capacity(pmpgs.size()));
this.initialNodes = new ArrayList<>(pmpgs.size());

for (Entry<L, ? extends ProceduralModalProcessGraph<? extends N, L, ? extends E, ?, ?>> e : pmpgs.entrySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import java.util.Collection;
import java.util.Iterator;

import com.google.common.collect.Iterables;
import net.automatalib.automaton.concept.SuffixOutput;
import net.automatalib.common.util.collection.IterableUtil;
import net.automatalib.ts.DeterministicTransitionSystem;
import net.automatalib.ts.UniversalDTS;

Expand All @@ -39,7 +39,7 @@ default Boolean computeOutput(Iterable<? extends I> input) {

@Override
default Boolean computeSuffixOutput(Iterable<? extends I> prefix, Iterable<? extends I> suffix) {
return computeOutput(Iterables.concat(prefix, suffix));
return computeOutput(IterableUtil.concat(prefix, suffix));
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/net/automatalib/word/Word.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
import net.automatalib.AutomataLibProperty;
import net.automatalib.AutomataLibSettings;
import net.automatalib.alphabet.Alphabet;
import net.automatalib.common.smartcollection.AWUtil;
import net.automatalib.common.smartcollection.ArrayWritable;
import net.automatalib.common.smartcollection.IntSeq;
import net.automatalib.common.util.array.AWUtil;
import net.automatalib.common.util.string.AbstractPrintable;
import org.checkerframework.checker.nullness.qual.Nullable;

Expand Down
4 changes: 2 additions & 2 deletions api/src/main/java/net/automatalib/word/WordBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import java.util.Arrays;
import java.util.List;

import net.automatalib.common.smartcollection.ArrayUtil;
import net.automatalib.common.smartcollection.ResizingArrayStorage;
import net.automatalib.common.util.array.ArrayUtil;
import net.automatalib.common.util.array.ResizingArrayStorage;
import org.checkerframework.checker.nullness.qual.Nullable;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ limitations under the License.
<Match>
<Bug pattern="CN_IDIOM_NO_SUPER_CALL"/>
<!-- we want to cut cloning hierarchy here -->
<Class name="net.automatalib.common.smartcollection.ArrayStorage"/>
<Class name="net.automatalib.common.util.array.ArrayStorage"/>
</Match>
<Match>
<Bug pattern="DM_DEFAULT_ENCODING,URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD,SBSC_USE_STRINGBUFFER_CONCATENATION,SF_SWITCH_NO_DEFAULT,UC_USELESS_VOID_METHOD,MS_SHOULD_BE_FINAL,URF_UNREAD_FIELD,UCF_USELESS_CONTROL_FLOW"/>
Expand Down
5 changes: 1 addition & 4 deletions build-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,7 @@ limitations under the License.
^net.automatalib.modelchecker.ltsmin.(Internal.*|Token.*|SimpleCharStream)|\
^net.automatalib.modelchecker.m3c.formula.parser.(Internal.*|Token.*|SimpleCharStream)|\
</arg>
<arg>-AskipUses=^com.google.*|\
^java.(awt.*|util.Arrays|io.StreamTokenizer)|\
^javax.swing.*|\
</arg>
<arg>-AskipUses=^java.(awt.*|util.Arrays|io.StreamTokenizer)|^javax.swing.*</arg>
<arg>-AsuppressWarnings=uninitialized</arg>
<arg>-AassumeAssertionsAreEnabled</arg>
<arg>-Astubs=jdk8.astub:collection-object-parameters-may-be-null.astub</arg>
Expand Down
6 changes: 3 additions & 3 deletions commons/smartcollections/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ limitations under the License.
</description>

<dependencies>
<!-- external -->
<!-- internal -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<groupId>net.automatalib</groupId>
<artifactId>automata-commons-util</artifactId>
</dependency>

<!-- build -->
Expand Down
2 changes: 1 addition & 1 deletion commons/smartcollections/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
open module net.automatalib.common.smartcollection {

requires com.google.common;
requires net.automatalib.common.util;
requires org.checkerframework.checker.qual;

exports net.automatalib.common.smartcollection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.automatalib.common.util.array;
package net.automatalib.common.smartcollection;

import java.util.Arrays;

import net.automatalib.common.smartcollection.ArrayWritable;

/**
* Utility class for writing containers to arrays.
* <p>
Expand Down
Loading