Skip to content

Commit

Permalink
Merge pull request #374 from gdgib/G2-1644-CreatePath
Browse files Browse the repository at this point in the history
G2-1644 Create ax-path module & sketch API
  • Loading branch information
gdgib authored Sep 21, 2024
2 parents bced865 + e0d0de2 commit a9c8c21
Show file tree
Hide file tree
Showing 48 changed files with 464 additions and 44 deletions.
5 changes: 5 additions & 0 deletions ax-adt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,10 @@
<artifactId>ax-analysis</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.g2forge.alexandria</groupId>
<artifactId>ax-collection</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
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;
import com.g2forge.alexandria.adt.graph.v2.DiGraph.VertexData;
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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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<V, E, Result> extends IGraphGeneric<V, E> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions ax-collection/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/.settings/
/target/
/.classpath
/.project
*.factorypath
18 changes: 18 additions & 0 deletions ax-collection/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>
<artifactId>ax-collection</artifactId>

<parent>
<groupId>com.g2forge.alexandria</groupId>
<artifactId>ax-project</artifactId>
<version>0.0.19-SNAPSHOT</version>
<relativePath>../ax-project/pom.xml</relativePath>
</parent>

<name>Alexandria Collections</name>
<description>Extended Collections API.</description>
</project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.g2forge.alexandria.adt.collection;
package com.g2forge.alexandria.collection;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.g2forge.alexandria.adt.collection;
package com.g2forge.alexandria.collection;

import java.util.Collection;
import java.util.Collections;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.g2forge.alexandria.adt.collection;
package com.g2forge.alexandria.collection;

import java.util.Iterator;
import java.util.stream.Stream;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.g2forge.alexandria.adt.collection;
package com.g2forge.alexandria.collection;

import java.util.Collection;
import java.util.stream.Collectors;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.g2forge.alexandria.adt.collection;
package com.g2forge.alexandria.collection;

import java.util.Collection;
import java.util.Iterator;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.g2forge.alexandria.adt.collection;
package com.g2forge.alexandria.collection;

import java.util.Collection;
import java.util.Collections;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.g2forge.alexandria.adt.collection;
package com.g2forge.alexandria.collection;

import com.g2forge.alexandria.java.close.ICloseable;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.g2forge.alexandria.adt.collection;
package com.g2forge.alexandria.collection;

import java.util.Collection;
import java.util.stream.Stream;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.g2forge.alexandria.adt.collection;
package com.g2forge.alexandria.collection;

import java.util.AbstractList;
import java.util.function.IntFunction;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.g2forge.alexandria.adt.collection;
package com.g2forge.alexandria.collection;

import java.util.AbstractList;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.g2forge.alexandria.adt.collection;
package com.g2forge.alexandria.collection;

import java.util.AbstractList;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.g2forge.alexandria.adt.collection;
package com.g2forge.alexandria.collection;

import java.util.Collection;
import java.util.Collections;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.g2forge.alexandria.adt.collection.collector;
package com.g2forge.alexandria.collection.collector;

import com.g2forge.alexandria.java.function.ISupplier;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.g2forge.alexandria.adt.collection.collector;
package com.g2forge.alexandria.collection.collector;

public interface ICollector<T> {
public default ICollector<T> add(Iterable<? extends T> values) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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<T> implements ITuple1_S<T> {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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<T> implements ICollector<T> {
protected final StringBuilder internal = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
@@ -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<C extends Collection<T>, T> implements ICollectionStrategy<C, T> {
protected class Builder extends CollectionCollectionBuilder<C, T> {
Expand Down
Original file line number Diff line number Diff line change
@@ -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<C, T> {
public ICollectionBuilder<C, T> builder();
Expand Down
Original file line number Diff line number Diff line change
@@ -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<T> extends ACollectionStrategy<Collection<T>, T> {
protected ArrayList<T> create(Collection<T> copy) {
Expand Down
5 changes: 5 additions & 0 deletions ax-path/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/.settings/
/target/
/.classpath
/.project
*.factorypath
27 changes: 27 additions & 0 deletions ax-path/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>
<artifactId>ax-path</artifactId>

<parent>
<groupId>com.g2forge.alexandria</groupId>
<artifactId>ax-project</artifactId>
<version>0.0.19-SNAPSHOT</version>
<relativePath>../ax-project/pom.xml</relativePath>
</parent>

<name>Alexandria Paths</name>
<description>Generic Path API - flexible enough to be used for loca &amp;
remote filesystems or even abstract tree data structures.</description>

<dependencies>
<dependency>
<groupId>com.g2forge.alexandria</groupId>
<artifactId>ax-collection</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
11 changes: 11 additions & 0 deletions ax-path/src/main/java/com/g2forge/alexandria/path/IPath.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.g2forge.alexandria.path;

import com.g2forge.alexandria.collection.ICollection;

public interface IPath<T> {
public ICollection<T> getComponents();

public IPath<T> resolve(IPath<T> subpath);

public boolean isEmpty();
}
47 changes: 47 additions & 0 deletions ax-path/src/main/java/com/g2forge/alexandria/path/Path.java
Original file line number Diff line number Diff line change
@@ -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<T> implements IPath<T> {
protected static final Path<Object> EMPTY = new Path<>();

@SuppressWarnings("unchecked")
public static <T> Path<T> createEmpty() {
return (Path<T>) EMPTY;
}

protected final ICollection<T> components;

public Path(Collection<T> 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<T> resolve(IPath<T> subpath) {
if (isEmpty()) return subpath;
if (subpath.isEmpty()) return this;
return new Path<>(HCollection.concatenate(getComponents().toCollection(), subpath.getComponents().toCollection()));
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.g2forge.alexandria.path.directory;

import com.g2forge.alexandria.path.IPath;

public interface IDirectorySystem<T> {
public IPath<T> normalize(IPath<T> path);
}
Loading

0 comments on commit a9c8c21

Please sign in to comment.