diff --git a/ax-adt/pom.xml b/ax-adt/pom.xml index f827e087..0c91b9d8 100644 --- a/ax-adt/pom.xml +++ b/ax-adt/pom.xml @@ -20,5 +20,10 @@ ax-analysis ${project.version} + + com.g2forge.alexandria + ax-collection + ${project.version} + diff --git a/ax-adt/src/main/java/com/g2forge/alexandria/adt/graph/v2/DiGraphBuilder.java b/ax-adt/src/main/java/com/g2forge/alexandria/adt/graph/v2/DiGraphBuilder.java index 8f2ab821..008fc77a 100644 --- a/ax-adt/src/main/java/com/g2forge/alexandria/adt/graph/v2/DiGraphBuilder.java +++ b/ax-adt/src/main/java/com/g2forge/alexandria/adt/graph/v2/DiGraphBuilder.java @@ -5,7 +5,6 @@ import java.util.LinkedHashSet; import java.util.Set; -import com.g2forge.alexandria.adt.collection.ICollection; import com.g2forge.alexandria.adt.graph.v2.DiGraph.EdgeData; import com.g2forge.alexandria.adt.graph.v2.DiGraph.ILockableGraphKey; import com.g2forge.alexandria.adt.graph.v2.DiGraph.ImmutableGraphKey; @@ -13,6 +12,7 @@ import com.g2forge.alexandria.adt.graph.v2.member.IMemberDataStrategy; import com.g2forge.alexandria.annotations.note.Note; import com.g2forge.alexandria.annotations.note.NoteType; +import com.g2forge.alexandria.collection.ICollection; import lombok.AccessLevel; import lombok.AllArgsConstructor; diff --git a/ax-adt/src/main/java/com/g2forge/alexandria/adt/graph/v2/IGraphModifier.java b/ax-adt/src/main/java/com/g2forge/alexandria/adt/graph/v2/IGraphModifier.java index b1733d92..31f7953f 100644 --- a/ax-adt/src/main/java/com/g2forge/alexandria/adt/graph/v2/IGraphModifier.java +++ b/ax-adt/src/main/java/com/g2forge/alexandria/adt/graph/v2/IGraphModifier.java @@ -1,7 +1,7 @@ package com.g2forge.alexandria.adt.graph.v2; -import com.g2forge.alexandria.adt.collection.CollectionCollection; -import com.g2forge.alexandria.adt.collection.ICollection; +import com.g2forge.alexandria.collection.CollectionCollection; +import com.g2forge.alexandria.collection.ICollection; import com.g2forge.alexandria.java.function.builder.IModifier; public interface IGraphModifier extends IGraphGeneric { diff --git a/ax-adt/src/main/java/com/g2forge/alexandria/adt/graph/v2/MutableDiGraph.java b/ax-adt/src/main/java/com/g2forge/alexandria/adt/graph/v2/MutableDiGraph.java index 027b0329..04682747 100644 --- a/ax-adt/src/main/java/com/g2forge/alexandria/adt/graph/v2/MutableDiGraph.java +++ b/ax-adt/src/main/java/com/g2forge/alexandria/adt/graph/v2/MutableDiGraph.java @@ -2,7 +2,7 @@ import java.util.LinkedHashSet; -import com.g2forge.alexandria.adt.collection.ICollection; +import com.g2forge.alexandria.collection.ICollection; import lombok.AccessLevel; import lombok.Getter; diff --git a/ax-collection/.gitignore b/ax-collection/.gitignore new file mode 100644 index 00000000..99b82028 --- /dev/null +++ b/ax-collection/.gitignore @@ -0,0 +1,5 @@ +/.settings/ +/target/ +/.classpath +/.project +*.factorypath diff --git a/ax-collection/pom.xml b/ax-collection/pom.xml new file mode 100644 index 00000000..5d18a18f --- /dev/null +++ b/ax-collection/pom.xml @@ -0,0 +1,18 @@ + + + + 4.0.0 + ax-collection + + + com.g2forge.alexandria + ax-project + 0.0.19-SNAPSHOT + ../ax-project/pom.xml + + + Alexandria Collections + Extended Collections API. + diff --git a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/CircularBuffer.java b/ax-collection/src/main/java/com/g2forge/alexandria/collection/CircularBuffer.java similarity index 94% rename from ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/CircularBuffer.java rename to ax-collection/src/main/java/com/g2forge/alexandria/collection/CircularBuffer.java index 7126e21a..7b538353 100644 --- a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/CircularBuffer.java +++ b/ax-collection/src/main/java/com/g2forge/alexandria/collection/CircularBuffer.java @@ -1,4 +1,4 @@ -package com.g2forge.alexandria.adt.collection; +package com.g2forge.alexandria.collection; import java.util.ArrayList; import java.util.List; diff --git a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/CollectionCollection.java b/ax-collection/src/main/java/com/g2forge/alexandria/collection/CollectionCollection.java similarity index 94% rename from ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/CollectionCollection.java rename to ax-collection/src/main/java/com/g2forge/alexandria/collection/CollectionCollection.java index bfb6dd71..7b1ccb1d 100644 --- a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/CollectionCollection.java +++ b/ax-collection/src/main/java/com/g2forge/alexandria/collection/CollectionCollection.java @@ -1,4 +1,4 @@ -package com.g2forge.alexandria.adt.collection; +package com.g2forge.alexandria.collection; import java.util.Collection; import java.util.Collections; diff --git a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/DCollectionCollection.java b/ax-collection/src/main/java/com/g2forge/alexandria/collection/DCollectionCollection.java similarity index 92% rename from ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/DCollectionCollection.java rename to ax-collection/src/main/java/com/g2forge/alexandria/collection/DCollectionCollection.java index 83676335..f4e9f94e 100644 --- a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/DCollectionCollection.java +++ b/ax-collection/src/main/java/com/g2forge/alexandria/collection/DCollectionCollection.java @@ -1,4 +1,4 @@ -package com.g2forge.alexandria.adt.collection; +package com.g2forge.alexandria.collection; import java.util.Iterator; import java.util.stream.Stream; diff --git a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/DIteratorCollection.java b/ax-collection/src/main/java/com/g2forge/alexandria/collection/DIteratorCollection.java similarity index 92% rename from ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/DIteratorCollection.java rename to ax-collection/src/main/java/com/g2forge/alexandria/collection/DIteratorCollection.java index 5aa8f373..fe5541a4 100644 --- a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/DIteratorCollection.java +++ b/ax-collection/src/main/java/com/g2forge/alexandria/collection/DIteratorCollection.java @@ -1,4 +1,4 @@ -package com.g2forge.alexandria.adt.collection; +package com.g2forge.alexandria.collection; import java.util.Collection; import java.util.stream.Collectors; diff --git a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/DStreamCollection.java b/ax-collection/src/main/java/com/g2forge/alexandria/collection/DStreamCollection.java similarity index 92% rename from ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/DStreamCollection.java rename to ax-collection/src/main/java/com/g2forge/alexandria/collection/DStreamCollection.java index 29b26432..8789ae63 100644 --- a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/DStreamCollection.java +++ b/ax-collection/src/main/java/com/g2forge/alexandria/collection/DStreamCollection.java @@ -1,4 +1,4 @@ -package com.g2forge.alexandria.adt.collection; +package com.g2forge.alexandria.collection; import java.util.Collection; import java.util.Iterator; diff --git a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/EmptyCollection.java b/ax-collection/src/main/java/com/g2forge/alexandria/collection/EmptyCollection.java similarity index 94% rename from ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/EmptyCollection.java rename to ax-collection/src/main/java/com/g2forge/alexandria/collection/EmptyCollection.java index b13c260f..b4e4c821 100644 --- a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/EmptyCollection.java +++ b/ax-collection/src/main/java/com/g2forge/alexandria/collection/EmptyCollection.java @@ -1,4 +1,4 @@ -package com.g2forge.alexandria.adt.collection; +package com.g2forge.alexandria.collection; import java.util.Collection; import java.util.Collections; diff --git a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/ICloseableCollection.java b/ax-collection/src/main/java/com/g2forge/alexandria/collection/ICloseableCollection.java similarity index 88% rename from ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/ICloseableCollection.java rename to ax-collection/src/main/java/com/g2forge/alexandria/collection/ICloseableCollection.java index 43545bfb..5950b641 100644 --- a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/ICloseableCollection.java +++ b/ax-collection/src/main/java/com/g2forge/alexandria/collection/ICloseableCollection.java @@ -1,4 +1,4 @@ -package com.g2forge.alexandria.adt.collection; +package com.g2forge.alexandria.collection; import com.g2forge.alexandria.java.close.ICloseable; diff --git a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/ICollection.java b/ax-collection/src/main/java/com/g2forge/alexandria/collection/ICollection.java similarity index 92% rename from ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/ICollection.java rename to ax-collection/src/main/java/com/g2forge/alexandria/collection/ICollection.java index 89cad870..9f34acd7 100644 --- a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/ICollection.java +++ b/ax-collection/src/main/java/com/g2forge/alexandria/collection/ICollection.java @@ -1,4 +1,4 @@ -package com.g2forge.alexandria.adt.collection; +package com.g2forge.alexandria.collection; import java.util.Collection; import java.util.stream.Stream; diff --git a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/IndexedGeneratorList.java b/ax-collection/src/main/java/com/g2forge/alexandria/collection/IndexedGeneratorList.java similarity index 90% rename from ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/IndexedGeneratorList.java rename to ax-collection/src/main/java/com/g2forge/alexandria/collection/IndexedGeneratorList.java index 44fe20c3..6cb7404f 100644 --- a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/IndexedGeneratorList.java +++ b/ax-collection/src/main/java/com/g2forge/alexandria/collection/IndexedGeneratorList.java @@ -1,4 +1,4 @@ -package com.g2forge.alexandria.adt.collection; +package com.g2forge.alexandria.collection; import java.util.AbstractList; import java.util.function.IntFunction; diff --git a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/IntegerRangeList.java b/ax-collection/src/main/java/com/g2forge/alexandria/collection/IntegerRangeList.java similarity index 87% rename from ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/IntegerRangeList.java rename to ax-collection/src/main/java/com/g2forge/alexandria/collection/IntegerRangeList.java index fe25141b..184508c4 100644 --- a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/IntegerRangeList.java +++ b/ax-collection/src/main/java/com/g2forge/alexandria/collection/IntegerRangeList.java @@ -1,4 +1,4 @@ -package com.g2forge.alexandria.adt.collection; +package com.g2forge.alexandria.collection; import java.util.AbstractList; diff --git a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/LongRangeList.java b/ax-collection/src/main/java/com/g2forge/alexandria/collection/LongRangeList.java similarity index 87% rename from ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/LongRangeList.java rename to ax-collection/src/main/java/com/g2forge/alexandria/collection/LongRangeList.java index d73f4afb..53a4aa5b 100644 --- a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/LongRangeList.java +++ b/ax-collection/src/main/java/com/g2forge/alexandria/collection/LongRangeList.java @@ -1,4 +1,4 @@ -package com.g2forge.alexandria.adt.collection; +package com.g2forge.alexandria.collection; import java.util.AbstractList; diff --git a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/SingleCollection.java b/ax-collection/src/main/java/com/g2forge/alexandria/collection/SingleCollection.java similarity index 93% rename from ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/SingleCollection.java rename to ax-collection/src/main/java/com/g2forge/alexandria/collection/SingleCollection.java index 0c76e39e..106f1b80 100644 --- a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/SingleCollection.java +++ b/ax-collection/src/main/java/com/g2forge/alexandria/collection/SingleCollection.java @@ -1,4 +1,4 @@ -package com.g2forge.alexandria.adt.collection; +package com.g2forge.alexandria.collection; import java.util.Collection; import java.util.Collections; diff --git a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/collector/ICollectionBuilder.java b/ax-collection/src/main/java/com/g2forge/alexandria/collection/collector/ICollectionBuilder.java similarity index 89% rename from ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/collector/ICollectionBuilder.java rename to ax-collection/src/main/java/com/g2forge/alexandria/collection/collector/ICollectionBuilder.java index 766c6efa..138510ad 100644 --- a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/collector/ICollectionBuilder.java +++ b/ax-collection/src/main/java/com/g2forge/alexandria/collection/collector/ICollectionBuilder.java @@ -1,4 +1,4 @@ -package com.g2forge.alexandria.adt.collection.collector; +package com.g2forge.alexandria.collection.collector; import com.g2forge.alexandria.java.function.ISupplier; diff --git a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/collector/ICollector.java b/ax-collection/src/main/java/com/g2forge/alexandria/collection/collector/ICollector.java similarity index 85% rename from ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/collector/ICollector.java rename to ax-collection/src/main/java/com/g2forge/alexandria/collection/collector/ICollector.java index e725bb07..6175b216 100644 --- a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/collector/ICollector.java +++ b/ax-collection/src/main/java/com/g2forge/alexandria/collection/collector/ICollector.java @@ -1,4 +1,4 @@ -package com.g2forge.alexandria.adt.collection.collector; +package com.g2forge.alexandria.collection.collector; public interface ICollector { public default ICollector add(Iterable values) { diff --git a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/collector/implementations/CollectionCollectionBuilder.java b/ax-collection/src/main/java/com/g2forge/alexandria/collection/collector/implementations/CollectionCollectionBuilder.java similarity index 84% rename from ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/collector/implementations/CollectionCollectionBuilder.java rename to ax-collection/src/main/java/com/g2forge/alexandria/collection/collector/implementations/CollectionCollectionBuilder.java index 26e48cc9..b3a61e33 100644 --- a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/collector/implementations/CollectionCollectionBuilder.java +++ b/ax-collection/src/main/java/com/g2forge/alexandria/collection/collector/implementations/CollectionCollectionBuilder.java @@ -1,10 +1,10 @@ -package com.g2forge.alexandria.adt.collection.collector.implementations; +package com.g2forge.alexandria.collection.collector.implementations; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import com.g2forge.alexandria.adt.collection.collector.ICollectionBuilder; +import com.g2forge.alexandria.collection.collector.ICollectionBuilder; import lombok.RequiredArgsConstructor; diff --git a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/collector/implementations/CollectorSetter.java b/ax-collection/src/main/java/com/g2forge/alexandria/collection/collector/implementations/CollectorSetter.java similarity index 77% rename from ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/collector/implementations/CollectorSetter.java rename to ax-collection/src/main/java/com/g2forge/alexandria/collection/collector/implementations/CollectorSetter.java index d5ca5cf6..e2892101 100644 --- a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/collector/implementations/CollectorSetter.java +++ b/ax-collection/src/main/java/com/g2forge/alexandria/collection/collector/implementations/CollectorSetter.java @@ -1,6 +1,6 @@ -package com.g2forge.alexandria.adt.collection.collector.implementations; +package com.g2forge.alexandria.collection.collector.implementations; -import com.g2forge.alexandria.adt.collection.collector.ICollector; +import com.g2forge.alexandria.collection.collector.ICollector; import com.g2forge.alexandria.java.adt.tuple.ITuple1_S; public class CollectorSetter implements ITuple1_S { diff --git a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/collector/implementations/FixedCollectionBuilder.java b/ax-collection/src/main/java/com/g2forge/alexandria/collection/collector/implementations/FixedCollectionBuilder.java similarity index 82% rename from ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/collector/implementations/FixedCollectionBuilder.java rename to ax-collection/src/main/java/com/g2forge/alexandria/collection/collector/implementations/FixedCollectionBuilder.java index 773989c0..cdec657c 100644 --- a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/collector/implementations/FixedCollectionBuilder.java +++ b/ax-collection/src/main/java/com/g2forge/alexandria/collection/collector/implementations/FixedCollectionBuilder.java @@ -1,8 +1,8 @@ -package com.g2forge.alexandria.adt.collection.collector.implementations; +package com.g2forge.alexandria.collection.collector.implementations; import java.util.Collection; -import com.g2forge.alexandria.adt.collection.collector.ICollectionBuilder; +import com.g2forge.alexandria.collection.collector.ICollectionBuilder; import lombok.RequiredArgsConstructor; diff --git a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/collector/implementations/SeparatingCollector.java b/ax-collection/src/main/java/com/g2forge/alexandria/collection/collector/implementations/SeparatingCollector.java similarity index 84% rename from ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/collector/implementations/SeparatingCollector.java rename to ax-collection/src/main/java/com/g2forge/alexandria/collection/collector/implementations/SeparatingCollector.java index e321059b..d8e749b8 100644 --- a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/collector/implementations/SeparatingCollector.java +++ b/ax-collection/src/main/java/com/g2forge/alexandria/collection/collector/implementations/SeparatingCollector.java @@ -1,6 +1,6 @@ -package com.g2forge.alexandria.adt.collection.collector.implementations; +package com.g2forge.alexandria.collection.collector.implementations; -import com.g2forge.alexandria.adt.collection.collector.ICollector; +import com.g2forge.alexandria.collection.collector.ICollector; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/collector/implementations/StringCollector.java b/ax-collection/src/main/java/com/g2forge/alexandria/collection/collector/implementations/StringCollector.java similarity index 71% rename from ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/collector/implementations/StringCollector.java rename to ax-collection/src/main/java/com/g2forge/alexandria/collection/collector/implementations/StringCollector.java index 53cb97c6..55572916 100644 --- a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/collector/implementations/StringCollector.java +++ b/ax-collection/src/main/java/com/g2forge/alexandria/collection/collector/implementations/StringCollector.java @@ -1,8 +1,8 @@ -package com.g2forge.alexandria.adt.collection.collector.implementations; +package com.g2forge.alexandria.collection.collector.implementations; import java.util.Objects; -import com.g2forge.alexandria.adt.collection.collector.ICollector; +import com.g2forge.alexandria.collection.collector.ICollector; public class StringCollector implements ICollector { protected final StringBuilder internal = new StringBuilder(); diff --git a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/strategy/ACollectionStrategy.java b/ax-collection/src/main/java/com/g2forge/alexandria/collection/strategy/ACollectionStrategy.java similarity index 71% rename from ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/strategy/ACollectionStrategy.java rename to ax-collection/src/main/java/com/g2forge/alexandria/collection/strategy/ACollectionStrategy.java index 73d10bb8..b07822d8 100644 --- a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/strategy/ACollectionStrategy.java +++ b/ax-collection/src/main/java/com/g2forge/alexandria/collection/strategy/ACollectionStrategy.java @@ -1,9 +1,9 @@ -package com.g2forge.alexandria.adt.collection.strategy; +package com.g2forge.alexandria.collection.strategy; import java.util.Collection; -import com.g2forge.alexandria.adt.collection.collector.ICollectionBuilder; -import com.g2forge.alexandria.adt.collection.collector.implementations.CollectionCollectionBuilder; +import com.g2forge.alexandria.collection.collector.ICollectionBuilder; +import com.g2forge.alexandria.collection.collector.implementations.CollectionCollectionBuilder; public abstract class ACollectionStrategy, T> implements ICollectionStrategy { protected class Builder extends CollectionCollectionBuilder { diff --git a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/strategy/ICollectionStrategy.java b/ax-collection/src/main/java/com/g2forge/alexandria/collection/strategy/ICollectionStrategy.java similarity index 51% rename from ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/strategy/ICollectionStrategy.java rename to ax-collection/src/main/java/com/g2forge/alexandria/collection/strategy/ICollectionStrategy.java index 4af5188e..691c3a26 100644 --- a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/strategy/ICollectionStrategy.java +++ b/ax-collection/src/main/java/com/g2forge/alexandria/collection/strategy/ICollectionStrategy.java @@ -1,6 +1,6 @@ -package com.g2forge.alexandria.adt.collection.strategy; +package com.g2forge.alexandria.collection.strategy; -import com.g2forge.alexandria.adt.collection.collector.ICollectionBuilder; +import com.g2forge.alexandria.collection.collector.ICollectionBuilder; public interface ICollectionStrategy { public ICollectionBuilder builder(); diff --git a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/strategy/implementations/CollectionStrategy.java b/ax-collection/src/main/java/com/g2forge/alexandria/collection/strategy/implementations/CollectionStrategy.java similarity index 65% rename from ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/strategy/implementations/CollectionStrategy.java rename to ax-collection/src/main/java/com/g2forge/alexandria/collection/strategy/implementations/CollectionStrategy.java index 7c57797e..04579dc5 100644 --- a/ax-adt/src/main/java/com/g2forge/alexandria/adt/collection/strategy/implementations/CollectionStrategy.java +++ b/ax-collection/src/main/java/com/g2forge/alexandria/collection/strategy/implementations/CollectionStrategy.java @@ -1,9 +1,9 @@ -package com.g2forge.alexandria.adt.collection.strategy.implementations; +package com.g2forge.alexandria.collection.strategy.implementations; import java.util.ArrayList; import java.util.Collection; -import com.g2forge.alexandria.adt.collection.strategy.ACollectionStrategy; +import com.g2forge.alexandria.collection.strategy.ACollectionStrategy; public class CollectionStrategy extends ACollectionStrategy, T> { protected ArrayList create(Collection copy) { diff --git a/ax-path/.gitignore b/ax-path/.gitignore new file mode 100644 index 00000000..99b82028 --- /dev/null +++ b/ax-path/.gitignore @@ -0,0 +1,5 @@ +/.settings/ +/target/ +/.classpath +/.project +*.factorypath diff --git a/ax-path/pom.xml b/ax-path/pom.xml new file mode 100644 index 00000000..2fc339db --- /dev/null +++ b/ax-path/pom.xml @@ -0,0 +1,27 @@ + + + + 4.0.0 + ax-path + + + com.g2forge.alexandria + ax-project + 0.0.19-SNAPSHOT + ../ax-project/pom.xml + + + Alexandria Paths + Generic Path API - flexible enough to be used for loca & + remote filesystems or even abstract tree data structures. + + + + com.g2forge.alexandria + ax-collection + ${project.version} + + + diff --git a/ax-path/src/main/java/com/g2forge/alexandria/path/IPath.java b/ax-path/src/main/java/com/g2forge/alexandria/path/IPath.java new file mode 100644 index 00000000..178690cb --- /dev/null +++ b/ax-path/src/main/java/com/g2forge/alexandria/path/IPath.java @@ -0,0 +1,11 @@ +package com.g2forge.alexandria.path; + +import com.g2forge.alexandria.collection.ICollection; + +public interface IPath { + public ICollection getComponents(); + + public IPath resolve(IPath subpath); + + public boolean isEmpty(); +} diff --git a/ax-path/src/main/java/com/g2forge/alexandria/path/Path.java b/ax-path/src/main/java/com/g2forge/alexandria/path/Path.java new file mode 100644 index 00000000..1ed255f0 --- /dev/null +++ b/ax-path/src/main/java/com/g2forge/alexandria/path/Path.java @@ -0,0 +1,47 @@ +package com.g2forge.alexandria.path; + +import java.util.Collection; + +import com.g2forge.alexandria.collection.CollectionCollection; +import com.g2forge.alexandria.collection.EmptyCollection; +import com.g2forge.alexandria.collection.ICollection; +import com.g2forge.alexandria.java.core.helpers.HCollection; + +import lombok.Builder; +import lombok.Data; +import lombok.RequiredArgsConstructor; + +@Data +@Builder(toBuilder = true) +@RequiredArgsConstructor +public class Path implements IPath { + protected static final Path EMPTY = new Path<>(); + + @SuppressWarnings("unchecked") + public static Path createEmpty() { + return (Path) EMPTY; + } + + protected final ICollection components; + + public Path(Collection components) { + this(components.size() < 1 ? EmptyCollection.create() : new CollectionCollection<>(components)); + } + + @SafeVarargs + public Path(T... components) { + this(components.length < 1 ? EmptyCollection.create() : new CollectionCollection<>(components)); + } + + @Override + public boolean isEmpty() { + return getComponents().isEmpty(); + } + + @Override + public IPath resolve(IPath subpath) { + if (isEmpty()) return subpath; + if (subpath.isEmpty()) return this; + return new Path<>(HCollection.concatenate(getComponents().toCollection(), subpath.getComponents().toCollection())); + } +} diff --git a/ax-path/src/main/java/com/g2forge/alexandria/path/directory/DirectorySystem.java b/ax-path/src/main/java/com/g2forge/alexandria/path/directory/DirectorySystem.java new file mode 100644 index 00000000..665ed951 --- /dev/null +++ b/ax-path/src/main/java/com/g2forge/alexandria/path/directory/DirectorySystem.java @@ -0,0 +1,22 @@ +package com.g2forge.alexandria.path.directory; + +import com.g2forge.alexandria.java.core.enums.EnumException; +import com.g2forge.alexandria.java.platform.HPlatform; +import com.g2forge.alexandria.java.platform.PlatformCategory; + +public enum DirectorySystem implements IStandardDirectorySystem { + Microsoft, + POSIX; + + public static DirectorySystem getDirectorySystem() { + final PlatformCategory category = HPlatform.getPlatform().getCategory(); + switch (category) { + case Microsoft: + return DirectorySystem.Microsoft; + case Posix: + return DirectorySystem.POSIX; + default: + throw new EnumException(PlatformCategory.class, category); + } + } +} diff --git a/ax-path/src/main/java/com/g2forge/alexandria/path/directory/IDirectorySystem.java b/ax-path/src/main/java/com/g2forge/alexandria/path/directory/IDirectorySystem.java new file mode 100644 index 00000000..3832448b --- /dev/null +++ b/ax-path/src/main/java/com/g2forge/alexandria/path/directory/IDirectorySystem.java @@ -0,0 +1,7 @@ +package com.g2forge.alexandria.path.directory; + +import com.g2forge.alexandria.path.IPath; + +public interface IDirectorySystem { + public IPath normalize(IPath path); +} diff --git a/ax-path/src/main/java/com/g2forge/alexandria/path/directory/IStandardDirectorySystem.java b/ax-path/src/main/java/com/g2forge/alexandria/path/directory/IStandardDirectorySystem.java new file mode 100644 index 00000000..68bfa1c4 --- /dev/null +++ b/ax-path/src/main/java/com/g2forge/alexandria/path/directory/IStandardDirectorySystem.java @@ -0,0 +1,33 @@ +package com.g2forge.alexandria.path.directory; + +import java.util.ArrayList; +import java.util.List; + +import com.g2forge.alexandria.path.IPath; +import com.g2forge.alexandria.path.Path; + +public interface IStandardDirectorySystem extends IDirectorySystem { + public default String getSelf() { + return "."; + } + + public default String getParent() { + return ".."; + } + + @Override + public default IPath normalize(IPath path) { + if (path.isEmpty()) return path; + + final List retVal = new ArrayList<>(path.getComponents().toCollection()); + for (int i = 0; i < retVal.size(); i++) { + final String current = retVal.get(i); + if (getSelf().equals(current)) retVal.remove(i--); + else if (getParent().equals(current) && (i > 0) && !getParent().equals(retVal.get(i - 1))) { + retVal.remove(i--); + retVal.remove(i--); + } + } + return new Path<>(retVal); + } +} diff --git a/ax-path/src/main/java/com/g2forge/alexandria/path/file/IFile.java b/ax-path/src/main/java/com/g2forge/alexandria/path/file/IFile.java new file mode 100644 index 00000000..cdf872a5 --- /dev/null +++ b/ax-path/src/main/java/com/g2forge/alexandria/path/file/IFile.java @@ -0,0 +1,13 @@ +package com.g2forge.alexandria.path.file; + +import com.g2forge.alexandria.path.directory.IDirectorySystem; + +public interface IFile { + public IDirectorySystem getDirectorySystem(); + + public IFile getParent(); + + public IFile get(T filename); + + public boolean isDirectory(); +} diff --git a/ax-path/src/main/java/com/g2forge/alexandria/path/file/LocalFile.java b/ax-path/src/main/java/com/g2forge/alexandria/path/file/LocalFile.java new file mode 100644 index 00000000..3d813937 --- /dev/null +++ b/ax-path/src/main/java/com/g2forge/alexandria/path/file/LocalFile.java @@ -0,0 +1,42 @@ +package com.g2forge.alexandria.path.file; + +import java.nio.file.Files; +import java.nio.file.Path; + +import com.g2forge.alexandria.path.directory.DirectorySystem; +import com.g2forge.alexandria.path.directory.IDirectorySystem; + +import lombok.Builder; +import lombok.Data; + +@Data +@Builder(toBuilder = true) +public class LocalFile implements IFile { + protected final Path path; + + public LocalFile(Path path) { + this.path = path.normalize(); + } + + @Override + public IFile get(String filename) { + final Path resolved = getPath().resolve(filename); + if (!Files.exists(resolved)) return null; + return new LocalFile(resolved); + } + + @Override + public IDirectorySystem getDirectorySystem() { + return DirectorySystem.getDirectorySystem(); + } + + @Override + public IFile getParent() { + return new LocalFile(getPath().getParent()); + } + + @Override + public boolean isDirectory() { + return Files.isDirectory(getPath()); + } +} diff --git a/ax-path/src/main/java/com/g2forge/alexandria/path/format/IPathFormat.java b/ax-path/src/main/java/com/g2forge/alexandria/path/format/IPathFormat.java new file mode 100644 index 00000000..2e31188c --- /dev/null +++ b/ax-path/src/main/java/com/g2forge/alexandria/path/format/IPathFormat.java @@ -0,0 +1,9 @@ +package com.g2forge.alexandria.path.format; + +import com.g2forge.alexandria.path.IPath; + +public interface IPathFormat { + public String toString(IPath path); + + public String toString(T component); +} diff --git a/ax-path/src/main/java/com/g2forge/alexandria/path/format/IStandardPathFormat.java b/ax-path/src/main/java/com/g2forge/alexandria/path/format/IStandardPathFormat.java new file mode 100644 index 00000000..e4650b15 --- /dev/null +++ b/ax-path/src/main/java/com/g2forge/alexandria/path/format/IStandardPathFormat.java @@ -0,0 +1,14 @@ +package com.g2forge.alexandria.path.format; + +import java.util.stream.Collectors; + +import com.g2forge.alexandria.path.IPath; + +public interface IStandardPathFormat extends IPathFormat { + public String getSeparator(); + + @Override + public default String toString(IPath path) { + return path.getComponents().stream().map(this::toString).collect(Collectors.joining(getSeparator())); + } +} diff --git a/ax-path/src/main/java/com/g2forge/alexandria/path/format/PathFormat.java b/ax-path/src/main/java/com/g2forge/alexandria/path/format/PathFormat.java new file mode 100644 index 00000000..8d530d36 --- /dev/null +++ b/ax-path/src/main/java/com/g2forge/alexandria/path/format/PathFormat.java @@ -0,0 +1,18 @@ +package com.g2forge.alexandria.path.format; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public enum PathFormat implements IStandardPathFormat { + Microsoft("\\"), + POSIX("/"); + + protected final String separator; + + @Override + public String toString(String component) { + return component; + } +} diff --git a/ax-path/src/test/java/com/g2forge/alexandria/path/TestPath.java b/ax-path/src/test/java/com/g2forge/alexandria/path/TestPath.java new file mode 100644 index 00000000..0cd197a7 --- /dev/null +++ b/ax-path/src/test/java/com/g2forge/alexandria/path/TestPath.java @@ -0,0 +1,25 @@ +package com.g2forge.alexandria.path; + +import org.junit.Test; + +import com.g2forge.alexandria.path.Path; +import com.g2forge.alexandria.test.HAssert; + +public class TestPath { + @Test + public void resolveA0() { + final Path a = new Path<>("a"); + HAssert.assertSame(a, a.resolve(Path.createEmpty())); + } + + @Test + public void resolve0A() { + final Path a = new Path<>("a"); + HAssert.assertSame(a, Path.createEmpty().resolve(a)); + } + + @Test + public void resolveAB() { + HAssert.assertEquals(new Path<>("a", "b"), new Path<>("a").resolve(new Path<>("b"))); + } +} diff --git a/ax-path/src/test/java/com/g2forge/alexandria/path/directory/TestDirectorySystem.java b/ax-path/src/test/java/com/g2forge/alexandria/path/directory/TestDirectorySystem.java new file mode 100644 index 00000000..fb63a7ef --- /dev/null +++ b/ax-path/src/test/java/com/g2forge/alexandria/path/directory/TestDirectorySystem.java @@ -0,0 +1,78 @@ +package com.g2forge.alexandria.path.directory; + +import java.util.Collection; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; + +import com.g2forge.alexandria.path.Path; +import com.g2forge.alexandria.test.HAssert; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@RunWith(Parameterized.class) +@RequiredArgsConstructor +@Getter +public class TestDirectorySystem { + @Parameters + public static Collection data() { + return Stream.of(DirectorySystem.values()).map(s -> new Object[] { s }).collect(Collectors.toList()); + } + + protected final IStandardDirectorySystem system; + + @Test + public void empty() { + HAssert.assertEquals(Path.createEmpty(), getSystem().normalize(Path.createEmpty())); + } + + @Test + public void parentEnd() { + HAssert.assertEquals(new Path<>("a"), getSystem().normalize(new Path<>("a", "b", getSystem().getParent()))); + } + + @Test + public void parentMid() { + HAssert.assertEquals(new Path<>("b"), getSystem().normalize(new Path<>("a", getSystem().getParent(), "b"))); + } + + @Test + public void parentMulti() { + HAssert.assertEquals(new Path<>(getSystem().getParent()), getSystem().normalize(new Path<>("a", getSystem().getParent(), getSystem().getParent()))); + } + + @Test + public void parentSimple() { + HAssert.assertEquals(new Path<>(getSystem().getParent()), getSystem().normalize(new Path<>(getSystem().getParent()))); + } + + @Test + public void parentStart() { + HAssert.assertEquals(new Path<>(getSystem().getParent(), "a"), getSystem().normalize(new Path<>(getSystem().getParent(), "a"))); + } + + @Test + public void selfEnd() { + HAssert.assertEquals(new Path<>("a"), getSystem().normalize(new Path<>("a", getSystem().getSelf()))); + } + + @Test + public void selfMid() { + HAssert.assertEquals(new Path<>("a", "b"), getSystem().normalize(new Path<>("a", getSystem().getSelf(), "b"))); + } + + @Test + public void selfSimple() { + HAssert.assertEquals(Path.createEmpty(), getSystem().normalize(new Path<>(getSystem().getSelf()))); + } + + @Test + public void selfStart() { + HAssert.assertEquals(new Path<>("a"), getSystem().normalize(new Path<>(getSystem().getSelf(), "a"))); + } +} diff --git a/ax-path/src/test/java/com/g2forge/alexandria/path/format/TestPathFormat.java b/ax-path/src/test/java/com/g2forge/alexandria/path/format/TestPathFormat.java new file mode 100644 index 00000000..8d1eabc9 --- /dev/null +++ b/ax-path/src/test/java/com/g2forge/alexandria/path/format/TestPathFormat.java @@ -0,0 +1,39 @@ +package com.g2forge.alexandria.path.format; + +import org.junit.Test; + +import com.g2forge.alexandria.path.Path; +import com.g2forge.alexandria.path.format.PathFormat; +import com.g2forge.alexandria.test.HAssert; + +public class TestPathFormat { + @Test + public void microsoft0() { + HAssert.assertEquals("", PathFormat.Microsoft.toString(Path.createEmpty())); + } + + @Test + public void microsoft1() { + HAssert.assertEquals("a", PathFormat.Microsoft.toString(new Path("a"))); + } + + @Test + public void microsoftN() { + HAssert.assertEquals("a\\b\\c", PathFormat.Microsoft.toString(new Path("a", "b", "c"))); + } + + @Test + public void posix0() { + HAssert.assertEquals("", PathFormat.POSIX.toString(Path.createEmpty())); + } + + @Test + public void posix1() { + HAssert.assertEquals("a", PathFormat.POSIX.toString(new Path("a"))); + } + + @Test + public void posixN() { + HAssert.assertEquals("a/b/c", PathFormat.POSIX.toString(new Path("a", "b", "c"))); + } +} diff --git a/ax-reflection/src/main/java/com/g2forge/alexandria/reflection/object/HReflection.java b/ax-reflection/src/main/java/com/g2forge/alexandria/reflection/object/HReflection.java index cd53d1f5..b9b7d831 100644 --- a/ax-reflection/src/main/java/com/g2forge/alexandria/reflection/object/HReflection.java +++ b/ax-reflection/src/main/java/com/g2forge/alexandria/reflection/object/HReflection.java @@ -4,8 +4,8 @@ import java.lang.reflect.Type; import java.util.Collection; -import com.g2forge.alexandria.adt.collection.strategy.ICollectionStrategy; -import com.g2forge.alexandria.adt.collection.strategy.implementations.CollectionStrategy; +import com.g2forge.alexandria.collection.strategy.ICollectionStrategy; +import com.g2forge.alexandria.collection.strategy.implementations.CollectionStrategy; import com.g2forge.alexandria.generic.type.environment.ITypeEnvironment; import com.g2forge.alexandria.generic.type.environment.implementations.EmptyTypeEnvironment; import com.g2forge.alexandria.generic.type.java.IJavaUntype; diff --git a/ax-service/src/main/java/com/g2forge/alexandria/service/BasicServiceLoader.java b/ax-service/src/main/java/com/g2forge/alexandria/service/BasicServiceLoader.java index 75eeffab..bd245151 100644 --- a/ax-service/src/main/java/com/g2forge/alexandria/service/BasicServiceLoader.java +++ b/ax-service/src/main/java/com/g2forge/alexandria/service/BasicServiceLoader.java @@ -17,8 +17,8 @@ import java.util.Objects; import java.util.ServiceConfigurationError; -import com.g2forge.alexandria.adt.collection.DIteratorCollection; -import com.g2forge.alexandria.adt.collection.ICollection; +import com.g2forge.alexandria.collection.DIteratorCollection; +import com.g2forge.alexandria.collection.ICollection; import com.g2forge.alexandria.java.function.type.ITypeFunction1; import com.g2forge.alexandria.java.function.type.TypeMapIterator; diff --git a/ax-service/src/main/java/com/g2forge/alexandria/service/FeatureServiceLoader.java b/ax-service/src/main/java/com/g2forge/alexandria/service/FeatureServiceLoader.java index f1921241..2cba3325 100644 --- a/ax-service/src/main/java/com/g2forge/alexandria/service/FeatureServiceLoader.java +++ b/ax-service/src/main/java/com/g2forge/alexandria/service/FeatureServiceLoader.java @@ -13,9 +13,9 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import com.g2forge.alexandria.adt.collection.CollectionCollection; -import com.g2forge.alexandria.adt.collection.DIteratorCollection; -import com.g2forge.alexandria.adt.collection.ICollection; +import com.g2forge.alexandria.collection.CollectionCollection; +import com.g2forge.alexandria.collection.DIteratorCollection; +import com.g2forge.alexandria.collection.ICollection; import com.g2forge.alexandria.java.function.type.ITypeFunction1; import com.g2forge.alexandria.java.function.type.TypeMapIterator; diff --git a/ax-service/src/main/java/com/g2forge/alexandria/service/IServiceLoader.java b/ax-service/src/main/java/com/g2forge/alexandria/service/IServiceLoader.java index b492f32f..8480c227 100644 --- a/ax-service/src/main/java/com/g2forge/alexandria/service/IServiceLoader.java +++ b/ax-service/src/main/java/com/g2forge/alexandria/service/IServiceLoader.java @@ -2,8 +2,8 @@ import java.util.stream.Stream; -import com.g2forge.alexandria.adt.collection.DStreamCollection; -import com.g2forge.alexandria.adt.collection.ICollection; +import com.g2forge.alexandria.collection.DStreamCollection; +import com.g2forge.alexandria.collection.ICollection; import com.g2forge.alexandria.java.core.helpers.HStream; public interface IServiceLoader { diff --git a/pom.xml b/pom.xml index ef7f7e48..6ee9e8de 100644 --- a/pom.xml +++ b/pom.xml @@ -26,6 +26,8 @@ ax-environment ax-reflection ax-type + ax-collection + ax-path ax-adt ax-compiler ax-expression