From 0adbc0096e26808e2cd70d9c467dbd5771f3d22f Mon Sep 17 00:00:00 2001
From: Zachary Bischoff <116595361+bischoffz@users.noreply.github.com>
Date: Fri, 8 Sep 2023 13:49:21 -0400
Subject: [PATCH] 4.0.0 release (#4)
* maven central prep (#2)
* Maven central prep (#3)
* maven central prep
* fix javadoc and format
---
.github/workflows/create_release_on_tag.yml | 43 ++
.github/workflows/dev_build.yml | 37 ++
.../workflows/update_dependant_projects.yml | 40 ++
pom.xml | 174 +++++--
src/main/java/util/annotations/UnitTag.java | 10 +-
.../util/annotations/UnitTestConstructor.java | 5 +-
.../java/util/annotations/UnitTestField.java | 4 +-
.../util/annotations/UnitTestForCoverage.java | 2 -
.../java/util/annotations/UnitTestMethod.java | 4 +-
.../java/util/delaunay/GeoDelaunaySolver.java | 35 +-
.../util/delaunay/PlanarDelaunaySolver.java | 8 +-
.../util/dimensiontree/DimensionTree.java | 313 ++++++------
.../dimensiontree/DimensionTreeError.java | 11 +-
.../VolumetricDimensionTree.java | 35 +-
src/main/java/util/earth/Earth.java | 8 +-
src/main/java/util/earth/EarthGrid.java | 32 +-
src/main/java/util/earth/LatLon.java | 14 +-
src/main/java/util/earth/LatLonAlt.java | 47 +-
src/main/java/util/errors/ContractError.java | 2 -
.../java/util/errors/ContractException.java | 27 +-
src/main/java/util/geolocator/GeoLocator.java | 73 ++-
src/main/java/util/graph/Graph.java | 19 +-
.../java/util/graph/GraphDepthEvaluator.java | 23 +-
src/main/java/util/graph/Graphs.java | 67 +--
src/main/java/util/graph/MutableGraph.java | 19 +-
src/main/java/util/maps/MapReindexer.java | 32 +-
.../classgraph/ClassGraphDriver.java | 6 +-
.../CircularClassDependencyReport.java | 33 +-
.../CircularPackageDependencyReport.java | 24 +-
.../support/ClassDependencyScan.java | 6 +-
.../support/ClassDependencyScanner.java | 4 +-
.../classgraph/support/JavaRef.java | 7 +-
.../dependency/DependencyTracer.java | 5 +-
.../util/meta/codecount/CodeCountReport.java | 3 +-
.../PackageDependencyData.java | 54 +--
.../PackageDependencyDataGenerator.java | 33 +-
.../reports/PackageDependencyReport.java | 78 +--
.../unittestcoverage/MetaInfoContainer.java | 43 +-
.../unittestcoverage/MetaInfoGenerator.java | 85 ++--
.../reports/IncompleteClassReport.java | 27 +-
.../reports/MetaInfoReport.java | 39 +-
.../reports/MissingTestsReport.java | 23 +-
.../reports/StatusReport.java | 22 +-
.../warnings/ConstructorWarning.java | 19 +-
.../warnings/FieldWarning.java | 20 +-
.../warnings/MethodWarning.java | 16 +-
.../warnings/WarningType.java | 28 +-
src/main/java/util/path/ArrayPathSolver.java | 5 +-
src/main/java/util/path/MapPathSolver.java | 23 +-
src/main/java/util/path/Path.java | 17 +-
src/main/java/util/path/PathSolver.java | 3 -
src/main/java/util/path/Paths.java | 62 ++-
.../util/random/RandomGeneratorProvider.java | 2 +-
src/main/java/util/spherical/Chirality.java | 2 -
.../MalformedSphericalArcException.java | 1 -
.../MalformedSphericalPointException.java | 3 +-
.../MalformedSphericalTriangleException.java | 1 -
.../java/util/spherical/SphericalArc.java | 55 +--
.../java/util/spherical/SphericalPoint.java | 17 +-
.../java/util/spherical/SphericalPolygon.java | 97 ++--
.../util/spherical/SphericalTriangle.java | 62 +--
src/main/java/util/stats/BinContainer.java | 37 +-
src/main/java/util/stats/ImmutableStat.java | 67 ++-
src/main/java/util/stats/KahanSum.java | 2 -
src/main/java/util/stats/MutableStat.java | 16 +-
src/main/java/util/stats/Stat.java | 27 +-
src/main/java/util/time/Stopwatch.java | 5 -
src/main/java/util/time/TimeElapser.java | 2 -
src/main/java/util/vector/Circle2D.java | 205 ++++----
.../java/util/vector/MutableVector2D.java | 108 ++---
.../java/util/vector/MutableVector3D.java | 444 ++++++++----------
src/main/java/util/vector/Vector2D.java | 104 ++--
src/main/java/util/vector/Vector3D.java | 326 ++++++-------
src/main/java/util/wrappers/MultiKey.java | 11 +-
.../java/util/wrappers/MutableBoolean.java | 20 +-
.../java/util/wrappers/MutableDouble.java | 36 +-
.../java/util/wrappers/MutableInteger.java | 30 +-
src/main/java/util/wrappers/MutableLong.java | 29 +-
.../java/util/wrappers/MutableObject.java | 4 +-
src/test/java/util/vector/MT_Circle2D.java | 1 -
80 files changed, 1729 insertions(+), 1754 deletions(-)
create mode 100644 .github/workflows/create_release_on_tag.yml
create mode 100644 .github/workflows/dev_build.yml
create mode 100644 .github/workflows/update_dependant_projects.yml
diff --git a/.github/workflows/create_release_on_tag.yml b/.github/workflows/create_release_on_tag.yml
new file mode 100644
index 0000000..d9c4ba8
--- /dev/null
+++ b/.github/workflows/create_release_on_tag.yml
@@ -0,0 +1,43 @@
+# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
+# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
+
+# This workflow uses actions that are not certified by GitHub.
+# They are provided by a third-party and are governed by
+# separate terms of service, privacy policy, and support
+# documentation.
+
+name: Create Release
+
+on:
+ push:
+ tags:
+ - 'v*'
+ branches: ["main"]
+
+jobs:
+ create-release:
+ runs-on: ubuntu-latest
+ permissions:
+ contents: write
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v3
+ - name: Set up JDK 17
+ uses: actions/setup-java@v3
+ with:
+ java-version: '17'
+ distribution: 'temurin'
+ cache: maven
+ - name: Build
+ run: mvn clean install -Prelease --file pom.xml
+ - name: Get Version
+ run: |
+ echo "version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout --file pom.xml)" >> "$GITHUB_ENV"
+ - name: Make Release
+ uses: ncipollo/release-action@v1
+ with:
+ artifacts: "target/util-${{ env.version }}.jar,target/util-${{ env.version }}-sources.jar,target/util-${{ env.version }}-javadoc.jar"
+ prerelease: ${{ endsWith(env.version, 'SNAPSHOT') || contains(env.version, '-RC') }}
+ name: "v${{ env.version }}"
+ tag: "v${{ env.version }}"
+ generateReleaseNotes: true
diff --git a/.github/workflows/dev_build.yml b/.github/workflows/dev_build.yml
new file mode 100644
index 0000000..cf423ec
--- /dev/null
+++ b/.github/workflows/dev_build.yml
@@ -0,0 +1,37 @@
+# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
+# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
+
+# This workflow uses actions that are not certified by GitHub.
+# They are provided by a third-party and are governed by
+# separate terms of service, privacy policy, and support
+# documentation.
+
+name: Development Build
+
+on:
+ push:
+ branches: [ "dev" ]
+ paths:
+ - '**.xml'
+ - '**.java'
+ pull_request:
+ branches: [ "dev", "main" ]
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout Util
+ uses: actions/checkout@v3
+ - name: Set up JDK 17
+ uses: actions/setup-java@v3
+ with:
+ java-version: '17'
+ distribution: 'temurin'
+ cache: maven
+ - name: Build Util
+ run: mvn clean package --file pom.xml
+
+ # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
+ # - name: Update dependency graph
+ # uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6
diff --git a/.github/workflows/update_dependant_projects.yml b/.github/workflows/update_dependant_projects.yml
new file mode 100644
index 0000000..e012c00
--- /dev/null
+++ b/.github/workflows/update_dependant_projects.yml
@@ -0,0 +1,40 @@
+name: Create Release
+
+on:
+ push:
+ branches: ["main"]
+
+jobs:
+ create-release:
+ runs-on: ubuntu-latest
+ permissions:
+ contents: write
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v3
+ - name: Checkout GCM
+ uses: actions/checkout@v3
+ with:
+ repository: HHS/ASPR-8
+ path: gcm
+
+ - name: Set up JDK 17
+ uses: actions/setup-java@v3
+ with:
+ java-version: '17'
+ distribution: 'temurin'
+ cache: maven
+ - name: Get Version
+ run: |
+ echo "version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout --file pom.xml)" >> "$GITHUB_ENV"
+ cd gcm
+ git checkout dev
+ git checkout -b update-util-version
+ cd gcm
+ sed -i "0,/.*<\/util.version>/s//${VERSION}<\/util.version>/g" pom.xml
+ git add pom.xml
+ git commit -m "update util version"
+ gh pr create --head --fill
+ gh pr merge --auto
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index c9ca3a5..d1e669c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,35 +1,71 @@
+
4.0.0
+
gov.hhs.aspr.ms
util
- ${revision}
+ 4.0.0
jar
- util
+ Modeling Utils
+ A suite of utility methods that are useful for simulation frameworks.
+ https://github.com/HHS/ASPR-ms-util
+
+
+
+
+ GNU GENERAL PUBLIC LICENSE v3
+ https://www.gnu.org/licenses/gpl-3.0.en.html
+
+
+
+
+
+
+ Shawn Hatch
+ shawn.r.hatch@leidos.com
+ Leidos
+ https://www.leidos.com
+
+
+ Zachary Bischoff
+ Leidos
+ zachary.bischoff@leidos.com
+ https://www.leidos.com
+
+
+
+
+
+ scm:git:git://github.com/HHS/ASPR-ms-util.git
+ scm:git:ssh://github.com:HHS/ASPR-ms-util.git
+ https://github.com/HHS/ASPR-ms-util/tree/main
+
+
+
- 4.0.0-SNAPSHOT
UTF-8
17
17
- 1.3.0
3.0.0-M5
- 3.0.0-M5
3.2.1
+ 3.5.0
-
- 5.8.2
+
3.6.1
1.0
+ 5.8.2
+ 0.8.9
+
-
org.apache.commons
commons-math3
@@ -52,37 +88,18 @@
${junit-jupiter-engine.version}
provided
+
+ org.jacoco
+ jacoco-maven-plugin
+ ${jacoco-maven-plugin.version}
+ test
+
+
-
- org.codehaus.mojo
- flatten-maven-plugin
- ${flatten-maven-plugin.version}
-
-
-
- flatten
- process-resources
-
- flatten
-
-
- true
-
-
-
-
- flatten.clean
- clean
-
- clean
-
-
-
-
-
+
org.apache.maven.plugins
maven-surefire-plugin
@@ -94,12 +111,58 @@
+
- org.apache.maven.plugins
- maven-failsafe-plugin
- ${maven-failsafe-plugin.version}
+ org.jacoco
+ jacoco-maven-plugin
+ ${jacoco-maven-plugin.version}
+
+
+ default-prepare-agent
+
+ prepare-agent
+
+
+
+ default-report
+
+ report
+
+
+
+ default-check
+
+ check
+
+
+
+
+ BUNDLE
+
+
+ LINE
+ COVEREDRATIO
+ 0.0
+
+
+ BRANCH
+ COVEREDRATIO
+ 0.0
+
+
+ INSTRUCTION
+ COVEREDRATIO
+ 0.0
+
+
+
+
+
+
+
+
org.apache.maven.plugins
maven-source-plugin
@@ -117,4 +180,39 @@
+
+
+ release
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ ${maven-javadoc-plugin.version}
+
+ all,-missing
+ false
+
+ -Xmaxerrs
+ 65536
+ -Xmaxwarns
+ 65536
+
+
+
+
+ attach-javadocs
+ verify
+
+ jar
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/util/annotations/UnitTag.java b/src/main/java/util/annotations/UnitTag.java
index 5c98945..07e78a8 100644
--- a/src/main/java/util/annotations/UnitTag.java
+++ b/src/main/java/util/annotations/UnitTag.java
@@ -2,24 +2,24 @@
public enum UnitTag {
/*
- * The test should be run as a manual test
+ * The test should be run as a manual test
*/
MANUAL,
/*
- * The test is covered by another test in the same unit test
+ * The test is covered by another test in the same unit test
*/
LOCAL_PROXY,
/*
* The test is covered by other test(s) for other classes. This is used for
- * classes that are not expected to be directly exposed to a client of GCM
- * and where the class is used exclusively by GCM.
+ * classes that are not expected to be directly exposed to a client of GCM and
+ * where the class is used exclusively by GCM.
*/
CLASS_PROXY,
/*
- * The test is not yet fully implemented
+ * The test is not yet fully implemented
*/
INCOMPLETE//
}
diff --git a/src/main/java/util/annotations/UnitTestConstructor.java b/src/main/java/util/annotations/UnitTestConstructor.java
index 0244da7..78d0910 100644
--- a/src/main/java/util/annotations/UnitTestConstructor.java
+++ b/src/main/java/util/annotations/UnitTestConstructor.java
@@ -7,9 +7,8 @@
import java.lang.annotation.Target;
/**
- * Annotation for JUnit test methods that are testing public source constructors.
- *
- *
+ * Annotation for JUnit test methods that are testing public source
+ * constructors.
*/
@Documented
diff --git a/src/main/java/util/annotations/UnitTestField.java b/src/main/java/util/annotations/UnitTestField.java
index 60f0a5c..4b18a3d 100644
--- a/src/main/java/util/annotations/UnitTestField.java
+++ b/src/main/java/util/annotations/UnitTestField.java
@@ -8,8 +8,6 @@
/**
* Annotation for JUnit test methods that are testing public source methods.
- *
- *
*/
@Documented
@@ -19,7 +17,7 @@
String name();
Class> target();
-
+
UnitTag[] tags() default {};
}
\ No newline at end of file
diff --git a/src/main/java/util/annotations/UnitTestForCoverage.java b/src/main/java/util/annotations/UnitTestForCoverage.java
index 41ac27c..0121199 100644
--- a/src/main/java/util/annotations/UnitTestForCoverage.java
+++ b/src/main/java/util/annotations/UnitTestForCoverage.java
@@ -8,8 +8,6 @@
/**
* Annotation for JUnit test methods that are testing protected source methods.
- *
- *
*/
@Documented
diff --git a/src/main/java/util/annotations/UnitTestMethod.java b/src/main/java/util/annotations/UnitTestMethod.java
index 3a7e5fc..da73e29 100644
--- a/src/main/java/util/annotations/UnitTestMethod.java
+++ b/src/main/java/util/annotations/UnitTestMethod.java
@@ -8,8 +8,6 @@
/**
* Annotation for JUnit test methods that are testing public source methods.
- *
- *
*/
@Documented
@@ -21,7 +19,7 @@
Class> target();
Class>[] args();
-
+
UnitTag[] tags() default {};
}
\ No newline at end of file
diff --git a/src/main/java/util/delaunay/GeoDelaunaySolver.java b/src/main/java/util/delaunay/GeoDelaunaySolver.java
index 70903be..89645f3 100644
--- a/src/main/java/util/delaunay/GeoDelaunaySolver.java
+++ b/src/main/java/util/delaunay/GeoDelaunaySolver.java
@@ -314,8 +314,8 @@ private void initialize() {
}
/*
- * Add vertexes for each point in the model and calculate the centroid
- * of those points
+ * Add vertexes for each point in the model and calculate the centroid of those
+ * points
*/
final MutableVector3D centroid = new MutableVector3D();
int n = points.size();
@@ -331,8 +331,8 @@ private void initialize() {
double minDotProduct = Double.POSITIVE_INFINITY;
/*
- * Find the maximum angle to any point in the data from the centroid --
- * we use dot products to avoid the acos costs
+ * Find the maximum angle to any point in the data from the centroid -- we use
+ * dot products to avoid the acos costs
*
*/
for (int i = scaffoldCount; i < vertexes.size(); i++) {
@@ -357,8 +357,8 @@ private void initialize() {
final List tangentPlaneNormals = new ArrayList<>();
/*
- * Form the vectors that will be perpendicular to the three planes that
- * are tangent to the circle formed by the max angle
+ * Form the vectors that will be perpendicular to the three planes that are
+ * tangent to the circle formed by the max angle
*
*/
for (int i = 0; i < scaffoldCount; i++) {
@@ -369,10 +369,10 @@ private void initialize() {
}
/*
- * Find the three intersections of these plane in a right handed
- * fashion. The resulting triangle will be right handed if the triangle
- * is smaller than a hemisphere and left handed otherwise. Either way,
- * the triangle will have all of the data points on its inside.
+ * Find the three intersections of these plane in a right handed fashion. The
+ * resulting triangle will be right handed if the triangle is smaller than a
+ * hemisphere and left handed otherwise. Either way, the triangle will have all
+ * of the data points on its inside.
*/
for (int i = 0; i < scaffoldCount; i++) {
final MutableVector3D v0 = tangentPlaneNormals.get(i);
@@ -386,16 +386,15 @@ private void initialize() {
}
/*
- * We choose the bounds that will fit the unit sphere since we cannot
- * easily anticipate the centroid position of each triangle, despite
- * knowing all the vertex positions. This will help the tree keep its
- * depth to a minimum.
+ * We choose the bounds that will fit the unit sphere since we cannot easily
+ * anticipate the centroid position of each triangle, despite knowing all the
+ * vertex positions. This will help the tree keep its depth to a minimum.
*/
searchTree = VolumetricDimensionTree.builder()//
- .setFastRemovals(true)//
- .setLowerBounds(new double[] { -1, -1, -1 })//
- .setUpperBounds(new double[] { 1, 1, 1 })//
- .build();//
+ .setFastRemovals(true)//
+ .setLowerBounds(new double[] { -1, -1, -1 })//
+ .setUpperBounds(new double[] { 1, 1, 1 })//
+ .build();//
addTriangle(0, 1, 2);//
}
diff --git a/src/main/java/util/delaunay/PlanarDelaunaySolver.java b/src/main/java/util/delaunay/PlanarDelaunaySolver.java
index 228e2dd..980b936 100644
--- a/src/main/java/util/delaunay/PlanarDelaunaySolver.java
+++ b/src/main/java/util/delaunay/PlanarDelaunaySolver.java
@@ -311,10 +311,10 @@ private void initialize() {
double[] upperBounds = { maxX, maxY };
searchTree = VolumetricDimensionTree.builder()//
- .setFastRemovals(true)//
- .setLowerBounds(lowerBounds)//
- .setUpperBounds(upperBounds)//
- .build();//
+ .setFastRemovals(true)//
+ .setLowerBounds(lowerBounds)//
+ .setUpperBounds(upperBounds)//
+ .build();//
double pad = 0.01;
diff --git a/src/main/java/util/dimensiontree/DimensionTree.java b/src/main/java/util/dimensiontree/DimensionTree.java
index db7fd51..b31203c 100644
--- a/src/main/java/util/dimensiontree/DimensionTree.java
+++ b/src/main/java/util/dimensiontree/DimensionTree.java
@@ -12,35 +12,31 @@
import util.errors.ContractException;
/**
- *
+ *
* Represents a multi-dimensional, generics-based, searchable tree giving
* generally log2(N) retrieval times for stored members.
- *
- *
- *
+ *
+ *
* Positions in the tree are represented as arrays of double and the number of
* dimensions in the tree are fixed by its build parameters. The tree's span in
* the multi-dimensional space will contract and expand as needed and does so
* with generally efficient performance. The tree specifically allows for a
* single object to be stored at multiple locations and allows for multiple
* objects to be stored at a single location.
- *
- *
+ *
*
* The tree supports object retrieval by:
- *
all objects in the tree
- * the closest object to a given point
- * spherical and rectanguloid intersection with the tree
- *
- *
+ *
+ * - all objects in the tree
+ * - the closest object to a given point
+ * - spherical and rectanguloid intersection with the tree
+ *
*
* The tree supports object removal in O(log2(N)) time whenever it is
* constructed with the fast removals option and O(N) without. Fast removals
* requires significantly more memory.
*
- *
- **/
-
+ */
public final class DimensionTree {
private final static int DEFAULTLEAFSIZE = 15;
@@ -54,8 +50,10 @@ private static class Data {
private double[] upperBounds;
private int leafSize = DEFAULTLEAFSIZE;
private boolean fastRemovals = false;
-
- public Data() {}
+
+ public Data() {
+ }
+
public Data(Data data) {
lowerBounds = Arrays.copyOf(data.lowerBounds, data.lowerBounds.length);
upperBounds = Arrays.copyOf(data.upperBounds, data.upperBounds.length);
@@ -72,11 +70,11 @@ private Builder() {
}
/**
- * Sets the fast removals policy. When fast removals is chosen, the tree
- * will remove objects in near constant time. This requires significant
- * memory resources and adds time to the storage and retrieval process.
- * Without fast removals, the tree must remove objects in order O(N)
- * time through exhaustive searching.
+ * Sets the fast removals policy. When fast removals is chosen, the tree will
+ * remove objects in near constant time. This requires significant memory
+ * resources and adds time to the storage and retrieval process. Without fast
+ * removals, the tree must remove objects in order O(N) time through exhaustive
+ * searching.
*/
public Builder setFastRemovals(boolean fastRemovals) {
data.fastRemovals = fastRemovals;
@@ -84,15 +82,14 @@ public Builder setFastRemovals(boolean fastRemovals) {
}
/**
- * Sets the leaf size used to determine how many objects positions can
- * be stored in any particular node of the tree. Setting the value to a
- * high number such as 100 will slow down retrieval performance, but
- * will reduce memory overhead. Low values, such as 1 will maximize
- * memory use since this will cause more nodes to come into existence.
- * Both high and low values can slow down the tree's performance when
- * adding objects. Common practice is to set the value to
- * DEFAULTLEAFSIZE (=15), which works well in most applications.
- * Defaulted to 15.
+ * Sets the leaf size used to determine how many objects positions can be stored
+ * in any particular node of the tree. Setting the value to a high number such
+ * as 100 will slow down retrieval performance, but will reduce memory overhead.
+ * Low values, such as 1 will maximize memory use since this will cause more
+ * nodes to come into existence. Both high and low values can slow down the
+ * tree's performance when adding objects. Common practice is to set the value
+ * to DEFAULTLEAFSIZE (=15), which works well in most applications. Defaulted to
+ * 15.
*/
public Builder setLeafSize(int leafSize) {
@@ -101,10 +98,10 @@ public Builder setLeafSize(int leafSize) {
}
/**
- * Sets the initial lower bounds of the tree. While the tree will expand
- * and contract as needed, it is often important to set the bounds to
- * roughly the proper magnitude to avoid some initial performance slow
- * downs. Lower bounds should not exceed upper bounds.
+ * Sets the initial lower bounds of the tree. While the tree will expand and
+ * contract as needed, it is often important to set the bounds to roughly the
+ * proper magnitude to avoid some initial performance slow downs. Lower bounds
+ * should not exceed upper bounds.
*/
public Builder setLowerBounds(double[] lowerBounds) {
data.lowerBounds = Arrays.copyOf(lowerBounds, lowerBounds.length);
@@ -112,10 +109,10 @@ public Builder setLowerBounds(double[] lowerBounds) {
}
/**
- * Sets the initial upper bounds of the tree. While the tree will expand
- * and contract as needed, it is often important to set the bounds to
- * roughly the proper magnitude to avoid some initial performance slow
- * downs. Lower bounds should not exceed upper bounds.
+ * Sets the initial upper bounds of the tree. While the tree will expand and
+ * contract as needed, it is often important to set the bounds to roughly the
+ * proper magnitude to avoid some initial performance slow downs. Lower bounds
+ * should not exceed upper bounds.
*/
public Builder setUpperBounds(double[] upperBounds) {
data.upperBounds = Arrays.copyOf(upperBounds, upperBounds.length);
@@ -125,23 +122,23 @@ public Builder setUpperBounds(double[] upperBounds) {
/**
* Builds a {@link DimensionTree} from the contributed parameters.
*
- *
* @throws ContractException
- * {@linkplain DimensionTreeError#NON_POSITIVE_LEAF_SIZE}
- * if the selected leaf size is not positive
- * {@linkplain DimensionTreeError#LOWER_BOUNDS_ARE_NULL}
- * if the lower bounds were not contributed or were
- * null
- * {@linkplain DimensionTreeError#UPPER_BOUNDS_ARE_NULL}
- * if the upper bounds were not contributed or were
- * null
- * {@linkplain DimensionTreeError#BOUNDS_MISMATCH} if
- * the lower and upper bounds do not match in length
- * {@linkplain DimensionTreeError#LOWER_BOUNDS_EXCEED_UPPER_BOUNDS}
- * if any of the lower bounds exceed the corresponding upper
- * bounds
- *
- *
+ *
+ * - {@linkplain DimensionTreeError#NON_POSITIVE_LEAF_SIZE}
+ * if the selected leaf size is not positive
+ * - {@linkplain DimensionTreeError#LOWER_BOUNDS_ARE_NULL}
+ * if the lower bounds were not contributed or
+ * were null
+ * - {@linkplain DimensionTreeError#UPPER_BOUNDS_ARE_NULL}
+ * if the upper bounds were not contributed or
+ * were null
+ * - {@linkplain DimensionTreeError#BOUNDS_MISMATCH}
+ * if the lower and upper bounds do not match in
+ * length
+ * - {@linkplain DimensionTreeError#LOWER_BOUNDS_EXCEED_UPPER_BOUNDS}
+ * if any of the lower bounds exceed the
+ * corresponding upper bounds
+ *
*/
public DimensionTree build() {
return new DimensionTree<>(new Data(data));
@@ -235,9 +232,9 @@ private void expandRootToFitPosition(double[] position) {
}
/*
- * Returns the child that should contain the position. It is assumed that
- * the position is contained in this node's bounds. If there is no such
- * child, one is created and placed in the appropriate slot of the children.
+ * Returns the child that should contain the position. It is assumed that the
+ * position is contained in this node's bounds. If there is no such child, one
+ * is created and placed in the appropriate slot of the children.
*/
private Node getChild(Node node, double[] position) {
int childIndex = node.getChildIndex(position);
@@ -270,8 +267,8 @@ private Node getChild(Node node, double[] position) {
}
/*
- * Rather than have the root node recursively push the new member into the
- * tree, we elect to avoid stack loading to save some execution time.
+ * Rather than have the root node recursively push the new member into the tree,
+ * we elect to avoid stack loading to save some execution time.
*/
@SuppressWarnings("unchecked")
private Group deep_add(double[] position, T t) {
@@ -332,15 +329,17 @@ private Group deep_add(double[] position, T t) {
* already associated with the position. Returns false otherwise.
*
* @throws RuntimeException
- * if the position is null
- * if the member is null
- * if the position does not match the dimension of this
- * {@link DimensionTree}
+ *
+ * - if the position is null
+ * - if the member is null
+ * - if the position does not match the dimension
+ * of this {@link DimensionTree}
+ *
*/
public boolean add(double[] position, T member) {
if (position == null) {
-
+
throw new RuntimeException("null position");
}
if (position.length != commonState.dimension) {
@@ -367,7 +366,6 @@ public boolean add(double[] position, T member) {
/**
* Return true if and only if the given member is contained in this
* {@link DimensionTree}
- *
*/
public boolean contains(T member) {
if (groupMap != null) {
@@ -394,9 +392,8 @@ public Optional getNearestMember(double[] position) {
}
/**
- * Retrieves all of the objects stored in this {@link DimensionTree}. This
- * may include duplicates if any object is stored in multiple locations.
- *
+ * Retrieves all of the objects stored in this {@link DimensionTree}. This may
+ * include duplicates if any object is stored in multiple locations.
*/
public List getAll() {
@@ -410,14 +407,13 @@ public List getAll() {
}
/**
- * Retrieves all of the objects stored in the tree within the
- * IDimensionalShape. The shape itself need not lie fully inside the tree's
- * volume, but must be well formed and agree with the tree's dimension.
+ * Retrieves all of the objects stored in the tree within the IDimensionalShape.
+ * The shape itself need not lie fully inside the tree's volume, but must be
+ * well formed and agree with the tree's dimension.
*
- * @param dimensionalShape
- * a non-null IDimensionalShape implementation
- * @return an ArrayList of Object containing all unique objects within
- * shape's intersection with the tree.
+ * @param dimensionalShape a non-null IDimensionalShape implementation
+ * @return an ArrayList of Object containing all unique objects within shape's
+ * intersection with the tree.
*/
private List getObjectsInDimensionalShape(Shape dimensionalShape) {
List result = new ArrayList<>();
@@ -426,23 +422,24 @@ private List getObjectsInDimensionalShape(Shape dimensionalShape) {
}
/**
- * Retrieves all of the objects within the rectanguloid formed by the lower
- * and upper bounds. This may include duplicates if any object is stored in
- * multiple locations.The rectanguloid itself need not lie fully inside this
- * tree's volume. The lengths of the lower and upper bound arrays must agree
- * with the dimension of the tree. For each dimension, lowerBounds[i] must
- * not exceed upperBounds[i].
+ * Retrieves all of the objects within the rectanguloid formed by the lower and
+ * upper bounds. This may include duplicates if any object is stored in multiple
+ * locations.The rectanguloid itself need not lie fully inside this tree's
+ * volume. The lengths of the lower and upper bound arrays must agree with the
+ * dimension of the tree. For each dimension, lowerBounds[i] must not exceed
+ * upperBounds[i].
*
- *
* @throws RuntimeException
- * if the lower bounds are null<\li>
- * if the upper bounds are null<\li>
- * if the length of the upper bounds does not match the
- * dimension of this tree<\li>
- * if the length of the lower bounds does not match the
- * dimension of this tree<\li>
- * if the values of the lower bounds exceed the
- * corresponding values of the upper bounds<\li>
+ *
+ * - if the lower bounds are null
+ * - if the upper bounds are null
+ * - if the length of the upper bounds does not
+ * match the dimension of this tree
+ * - if the length of the lower bounds does not
+ * match the dimension of this tree
+ * - if the values of the lower bounds exceed the
+ * corresponding values of the upper bounds
+ *
*/
public List getMembersInRectanguloid(double[] lowerBounds, double[] upperBounds) {
@@ -467,20 +464,18 @@ public List getMembersInRectanguloid(double[] lowerBounds, double[] upperBoun
}
/**
- * Retrieves all of the objects stored in the tree within the radius
- * distance about the position. This may include duplicates if any object is
- * stored in multiple locations. The position itself need not lie inside
- * this tree's volume.
+ * Retrieves all of the objects stored in the tree within the radius distance
+ * about the position. This may include duplicates if any object is stored in
+ * multiple locations. The position itself need not lie inside this tree's
+ * volume.
*
- *
- *
- *
- * @throw {@link RuntimeException}
- * if the radius is negative<\li>
- * if the position is null<\li>
- * if the position's length does not match the dimension of this
- * tree
- *
+ * @throws RuntimeException
+ *
+ * - if the radius is negative
+ * - if the position is null
+ * - if the position's length does not match the
+ * dimension of this tree
+ *
*/
public List getMembersInSphere(double radius, double[] position) {
if (position == null) {
@@ -504,9 +499,9 @@ public List getMembersInSphere(double radius, double[] position) {
*/
public boolean remove(T member) {
/*
- * First, get the list of member groups that contain the member. This
- * can come from the nodes via a brute force walk of the entire tree or
- * from a map of T to List
+ * First, get the list of member groups that contain the member. This can come
+ * from the nodes via a brute force walk of the entire tree or from a map of T
+ * to List
*/
List> groups;
if (groupMap == null) {
@@ -517,18 +512,18 @@ public boolean remove(T member) {
}
/*
- * For each member group we will remove the member. For those member
- * groups where the member group is now empty, we remove the member
- * group from its node and cascade member group counts upward. As we
- * move upward toward the root, we record each node that will need to
- * collapse, replacing this reference as we move up. Any node that
- * reaches a member count of zero will be removed from its parent.
+ * For each member group we will remove the member. For those member groups
+ * where the member group is now empty, we remove the member group from its node
+ * and cascade member group counts upward. As we move upward toward the root, we
+ * record each node that will need to collapse, replacing this reference as we
+ * move up. Any node that reaches a member count of zero will be removed from
+ * its parent.
*
- * If we have a node that has been selected to collapse, we command the
- * node to collapse.
+ * If we have a node that has been selected to collapse, we command the node to
+ * collapse.
*
- * We next walk downward from root looking to move the root downward
- * into the tree?
+ * We next walk downward from root looking to move the root downward into the
+ * tree?
*/
boolean result = groups != null && !groups.isEmpty();
@@ -543,8 +538,7 @@ public boolean remove(T member) {
// reduce the group count
node.groupCount--;
/*
- * If the node is now empty and has a parent, remove it
- * from its parent
+ * If the node is now empty and has a parent, remove it from its parent
*/
if (node.groupCount == 0) {
if (node.parent != null) {
@@ -552,8 +546,7 @@ public boolean remove(T member) {
}
}
/*
- * Don't select a node to collapse if it is being thrown
- * out of the tree
+ * Don't select a node to collapse if it is being thrown out of the tree
*/
if (node.groupCount != 0 && node.groupCount <= commonState.leafSize) {
collapseNode = node;
@@ -580,7 +573,6 @@ public boolean remove(T member) {
// return root.toString();
// }
-
/*
* Returns true if and only if sqrt(a) + sqrt(b) < sqrt(c). Used in distance
* comparisons where square distances are known and calculating square roots
@@ -588,9 +580,9 @@ public boolean remove(T member) {
*/
private static boolean squareRootInequality(double aSquare, double bSquare, double cSquare) {
/*
- * We want to know when a+b 0
+ * 4 a^2 b^2 < (c^2 - a^2 - b^2)^2 with the caveat that c^2 - a^2 - b^2 > 0
*/
double d = cSquare - aSquare - bSquare;
return d >= 0 && 4 * aSquare * bSquare < d * d;
}
-
+
/*
* The common parameters shared by all nodes that takes up less memory than
* storing these values on each node
@@ -626,7 +617,7 @@ public CommonState(int leafSize, int dimension) {
}
}
-
+
/*
* Represents a single node the in dimension tree.
*
@@ -705,17 +696,18 @@ public void getNearestMember(NearestMemberQuery nearestMemberData) {
}
/*
- * This method drill down to the node that that either contains the position
- * or comes fairly close. We use this to quickly reduce the volume around
- * the position where a solution might be found. If a solution is found this
- * way, there is no guarantee that it will be the best solution, but it very
- * often will be very close.
+ * This method drill down to the node that that either contains the position or
+ * comes fairly close. We use this to quickly reduce the volume around the
+ * position where a solution might be found. If a solution is found this way,
+ * there is no guarantee that it will be the best solution, but it very often
+ * will be very close.
*/
private void findInitialNearestMemberSolution(NearestMemberQuery nearestMemberData) {
if (children == null) {
for (Group memberGroup : groups) {
double squareDistance = memberGroup.squareDistanceTo(nearestMemberData.position);
- if ((squareDistance <= nearestMemberData.bestSquareDistance) || (nearestMemberData.bestSquareDistance < 0)) {
+ if ((squareDistance <= nearestMemberData.bestSquareDistance)
+ || (nearestMemberData.bestSquareDistance < 0)) {
nearestMemberData.bestSquareDistance = squareDistance;
nearestMemberData.closestObject = memberGroup.members.get(0);
}
@@ -741,18 +733,17 @@ private void findInitialNearestMemberSolution(NearestMemberQuery nearestMembe
}
/*
- * This method searches the entire tree for a solution and tries to
- * terminate branching quickly. It depends on first having found a
- * reasonable near-solution, otherwise it will walk the entire tree.
+ * This method searches the entire tree for a solution and tries to terminate
+ * branching quickly. It depends on first having found a reasonable
+ * near-solution, otherwise it will walk the entire tree.
*/
private void findBetterNearestMemberSolution(NearestMemberQuery nearestMemberData) {
/*
- * We try to exclude any calculations if this node does not overlap the
- * sphere given by the current solution. We do this by comparing the
- * radius of this node, the radius of the current solution and the
- * distance to the query position. We will sometimes fail to reject
- * further work, but this will reject most of the potential wasted
- * comparisons.
+ * We try to exclude any calculations if this node does not overlap the sphere
+ * given by the current solution. We do this by comparing the radius of this
+ * node, the radius of the current solution and the distance to the query
+ * position. We will sometimes fail to reject further work, but this will reject
+ * most of the potential wasted comparisons.
*
*/
@@ -763,14 +754,16 @@ private void findBetterNearestMemberSolution(NearestMemberQuery nearestMember
squareDistanceToPositionFromNodeCenter += delta;
}
- if (squareRootInequality(squareRadius, nearestMemberData.bestSquareDistance, squareDistanceToPositionFromNodeCenter)) {
+ if (squareRootInequality(squareRadius, nearestMemberData.bestSquareDistance,
+ squareDistanceToPositionFromNodeCenter)) {
return;
}
if (children == null) {
for (Group memberGroup : groups) {
double squareDistance = memberGroup.squareDistanceTo(nearestMemberData.position);
- if ((squareDistance <= nearestMemberData.bestSquareDistance) || (nearestMemberData.bestSquareDistance < 0)) {
+ if ((squareDistance <= nearestMemberData.bestSquareDistance)
+ || (nearestMemberData.bestSquareDistance < 0)) {
nearestMemberData.bestSquareDistance = squareDistance;
nearestMemberData.closestObject = memberGroup.members.get(0);
}
@@ -826,17 +819,17 @@ public void getObjectsInDimensionalShape(Shape dimensionalShape, List list) {
}
}
return;
- default:
+ default:
throw new RuntimeException("unhandled shape intersection type " + shapeIntersectionType);
}
}
public int getChildIndex(double[] position) {
/*
- * Rather than store an array of booleans for our analysis of child
- * bounds, we will use an index value that will be composed and then
- * decomposed to eliminate the cost of array construction and garbage
- * collection which has been shown in testing to be fairly expensive.
+ * Rather than store an array of booleans for our analysis of child bounds, we
+ * will use an index value that will be composed and then decomposed to
+ * eliminate the cost of array construction and garbage collection which has
+ * been shown in testing to be fairly expensive.
*/
int result = 0;
for (int i = 0; i < commonState.dimension; i++) {
@@ -902,7 +895,7 @@ private List toStrings() {
}
}
-
+
/*
* Represent the members that are associated with a single position. Rather than
* storing members in the leaf nodes, we store member groups. Each member group
@@ -951,7 +944,7 @@ public double squareDistanceTo(double[] p) {
}
}
-
+
/*
* Represents a rectangular box in the dimension of the tree.
*
@@ -999,7 +992,8 @@ public ShapeIntersectionType intersectsBox(Node node) {
return ShapeIntersectionType.NONE;
}
- if ((position[i] + bounds[i] > node.upperBounds[i]) && (position[i] - bounds[i] < node.lowerBounds[i])) {
+ if ((position[i] + bounds[i] > node.upperBounds[i])
+ && (position[i] - bounds[i] < node.lowerBounds[i])) {
containmentCount++;
}
}
@@ -1030,8 +1024,8 @@ private interface Shape {
/**
* Returns a ShapeIntersectionType that is the shapes determination of the
- * overlap of the shape and the given node. Used to streamline the process
- * of gathering members from nodes during intersection tests.
+ * overlap of the shape and the given node. Used to streamline the process of
+ * gathering members from nodes during intersection tests.
*/
public ShapeIntersectionType intersectsBox(Node node);
}
@@ -1137,17 +1131,16 @@ private static enum ShapeIntersectionType {
NONE,
/**
- * The shape may intersect the node. Members of the node will require
- * further comparison to the shape.
+ * The shape may intersect the node. Members of the node will require further
+ * comparison to the shape.
*/
PARTIAL,
/**
- * The shape fully contains the node and all members of the node can be
- * gathered without further comparison to the shape.
+ * The shape fully contains the node and all members of the node can be gathered
+ * without further comparison to the shape.
*/
COMPLETE;
}
-
}
\ No newline at end of file
diff --git a/src/main/java/util/dimensiontree/DimensionTreeError.java b/src/main/java/util/dimensiontree/DimensionTreeError.java
index b04fd91..0563f00 100644
--- a/src/main/java/util/dimensiontree/DimensionTreeError.java
+++ b/src/main/java/util/dimensiontree/DimensionTreeError.java
@@ -6,17 +6,12 @@
/**
* An enumeration supporting {@link ContractException} that acts as a general
* description of the exception.
- *
- *
*/
public enum DimensionTreeError implements ContractError {
- NON_POSITIVE_LEAF_SIZE("non-positive leaf size"),
- LOWER_BOUNDS_ARE_NULL("lower bounds are null"),
- UPPER_BOUNDS_ARE_NULL("upper bounds are null"),
- BOUNDS_MISMATCH("dimensional mismatch between bounds"),
- LOWER_BOUNDS_EXCEED_UPPER_BOUNDS("lower bounds exceed upper bounds"),
- ;
+ NON_POSITIVE_LEAF_SIZE("non-positive leaf size"), LOWER_BOUNDS_ARE_NULL("lower bounds are null"),
+ UPPER_BOUNDS_ARE_NULL("upper bounds are null"), BOUNDS_MISMATCH("dimensional mismatch between bounds"),
+ LOWER_BOUNDS_EXCEED_UPPER_BOUNDS("lower bounds exceed upper bounds"),;
private final String description;
diff --git a/src/main/java/util/dimensiontree/VolumetricDimensionTree.java b/src/main/java/util/dimensiontree/VolumetricDimensionTree.java
index 12102b2..9b23706 100644
--- a/src/main/java/util/dimensiontree/VolumetricDimensionTree.java
+++ b/src/main/java/util/dimensiontree/VolumetricDimensionTree.java
@@ -168,12 +168,12 @@ public boolean equals(Object obj) {
private VolumetricDimensionTree(Data data) {
this.data = data;
defaultDimensionTreeRec = new DimensionTreeRec<>();
- defaultDimensionTreeRec.dimensionTree = DimensionTree .builder()//
- .setLowerBounds(data.lowerBounds)//
- .setUpperBounds(data.upperBounds)//
- .setLeafSize(data.leafSize)//
- .setFastRemovals(data.fastRemovals)//
- .build();//
+ defaultDimensionTreeRec.dimensionTree = DimensionTree.builder()//
+ .setLowerBounds(data.lowerBounds)//
+ .setUpperBounds(data.upperBounds)//
+ .setLeafSize(data.leafSize)//
+ .setFastRemovals(data.fastRemovals)//
+ .build();//
defaultDimensionTreeRec.maxRadius = 0;
}
@@ -200,11 +200,11 @@ public void add(double[] position, double radius, T t) {
if (dimensionTreeRec == null) {
dimensionTreeRec = new DimensionTreeRec<>();
- dimensionTreeRec.dimensionTree = DimensionTree .builder().setLowerBounds(data.lowerBounds)//
- .setUpperBounds(data.upperBounds)//
- .setLeafSize(data.leafSize)//
- .setFastRemovals(data.fastRemovals)//
- .build();//
+ dimensionTreeRec.dimensionTree = DimensionTree.builder().setLowerBounds(data.lowerBounds)//
+ .setUpperBounds(data.upperBounds)//
+ .setLeafSize(data.leafSize)//
+ .setFastRemovals(data.fastRemovals)//
+ .build();//
dimensionTreeRec.maxRadius = FastMath.exp(index);
treeMap.put(index, dimensionTreeRec);
@@ -215,11 +215,11 @@ public void add(double[] position, double radius, T t) {
}
/**
- * Removes the member from this tree using the suggested radius to narrow
- * the search. If the given radius is different from any radius used to
- * store the object, there is no guarantee that the object will be removed.
- * This is not guaranteed to remove all occurrences of the member if
- * multiple radii and positions were used to add the member.
+ * Removes the member from this tree using the suggested radius to narrow the
+ * search. If the given radius is different from any radius used to store the
+ * object, there is no guarantee that the object will be removed. This is not
+ * guaranteed to remove all occurrences of the member if multiple radii and
+ * positions were used to add the member.
*/
public boolean remove(double radius, T t) {
@@ -281,7 +281,8 @@ public List getMembersInSphere(double radius, double[] position) {
result.add(locationRec.location);
}
for (DimensionTreeRec dimensionTreeRec : treeMap.values()) {
- List> potentialIntersections = dimensionTreeRec.dimensionTree.getMembersInSphere(radius + dimensionTreeRec.maxRadius, position);
+ List> potentialIntersections = dimensionTreeRec.dimensionTree
+ .getMembersInSphere(radius + dimensionTreeRec.maxRadius, position);
for (LocationRec locationRec : potentialIntersections) {
if (locationRec.containsPosition(position, radius)) {
result.add(locationRec.location);
diff --git a/src/main/java/util/earth/Earth.java b/src/main/java/util/earth/Earth.java
index fca283a..5f5fc43 100644
--- a/src/main/java/util/earth/Earth.java
+++ b/src/main/java/util/earth/Earth.java
@@ -8,8 +8,6 @@
* A spherical geo-model for converting various coordinate representations and
* calculating ground ranges. Earth instances are created from approximations to
* the WGS84 oblate earth.
- *
- *
*/
public class Earth {
@@ -17,7 +15,8 @@ public class Earth {
public final static double WGS84_POLAR_RADIUS_METERS = 6356752.314245;
- public final static double WGS84_MEAN_RADIUS_METERS = (2 * WGS84_EQUATORIAL_RADIUS_METERS + WGS84_POLAR_RADIUS_METERS) / 3;
+ public final static double WGS84_MEAN_RADIUS_METERS = (2 * WGS84_EQUATORIAL_RADIUS_METERS
+ + WGS84_POLAR_RADIUS_METERS) / 3;
private double radius;
@@ -72,7 +71,8 @@ public static double getEffectiveEarthRadius(double latitudeDegrees) {
// calculate the effective spherical earth radius for the given
// latitude from the WGS-84 oblate earth
final double lat = FastMath.toRadians(latitudeDegrees);
- return 1.0 / FastMath.sqrt(FastMath.pow(FastMath.cos(lat) / WGS84_EQUATORIAL_RADIUS_METERS, 2) + FastMath.pow(FastMath.sin(lat) / WGS84_POLAR_RADIUS_METERS, 2));
+ return 1.0 / FastMath.sqrt(FastMath.pow(FastMath.cos(lat) / WGS84_EQUATORIAL_RADIUS_METERS, 2)
+ + FastMath.pow(FastMath.sin(lat) / WGS84_POLAR_RADIUS_METERS, 2));
}
/**
diff --git a/src/main/java/util/earth/EarthGrid.java b/src/main/java/util/earth/EarthGrid.java
index 2e106bf..d6b60c5 100644
--- a/src/main/java/util/earth/EarthGrid.java
+++ b/src/main/java/util/earth/EarthGrid.java
@@ -13,8 +13,6 @@
* good approximation to the earth's surface for several kilometers. The earth
* is approximated by a sphere using the WGS84 earth radius for the latitude of
* the center of the grid.
- *
- *
*/
public final class EarthGrid {
@@ -31,23 +29,22 @@ public final class EarthGrid {
private Vector3D c;
/**
- * Constructs a new EarthGrid centered at the given LatLon where the (x,y)
- * grid is right handed from the perspective of an observer above the earth.
- * The positive y axis is aligned to the azimth. For example, an azimuth of
- * 0 degrees will align the y axis to the north and an azimuth of 90 degrees
- * will align the positive y axis to the east.
- *
- * @throws IllegalArgumentException
- * if the center point is closer than
- * EarthGrid.MIN_ANGLE_FROM_POLE=0.001 degrees from one of the
- * poles.
+ * Constructs a new EarthGrid centered at the given LatLon where the (x,y) grid
+ * is right handed from the perspective of an observer above the earth. The
+ * positive y axis is aligned to the azimth. For example, an azimuth of 0
+ * degrees will align the y axis to the north and an azimuth of 90 degrees will
+ * align the positive y axis to the east.
*
+ * @throws IllegalArgumentException if the center point is closer than
+ * EarthGrid.MIN_ANGLE_FROM_POLE=0.001
+ * degrees from one of the poles.
* @param center
* @param azimuthDegrees
*/
public EarthGrid(LatLon center, double azimuthDegrees) {
if ((FastMath.abs(center.getLatitude()) - 90) < MIN_ANGLE_FROM_POLE) {
- throw new IllegalArgumentException("Grid cannot be constructed within " + MIN_ANGLE_FROM_POLE + " degrees of a pole");
+ throw new IllegalArgumentException(
+ "Grid cannot be constructed within " + MIN_ANGLE_FROM_POLE + " degrees of a pole");
}
earth = Earth.fromLatitude(center.getLatitude());
@@ -56,9 +53,9 @@ public EarthGrid(LatLon center, double azimuthDegrees) {
z = c.normalize();
x = new Vector3D(0, 0, 1)//
- .cross(z)//
- .normalize()//
- .rotateAbout(z, -FastMath.toRadians(azimuthDegrees));//
+ .cross(z)//
+ .normalize()//
+ .rotateAbout(z, -FastMath.toRadians(azimuthDegrees));//
y = z.cross(x).normalize();
}
@@ -72,7 +69,8 @@ public Vector2D getCartesian2DCoordinate(LatLon latLon) {
}
public LatLon getLatLon(Vector2D xyCoordinate) {
- double zlength = FastMath.sqrt(earth.getRadius() * earth.getRadius() - xyCoordinate.getX() * xyCoordinate.getX() - xyCoordinate.getY() * xyCoordinate.getY()) - earth.getRadius();
+ double zlength = FastMath.sqrt(earth.getRadius() * earth.getRadius() - xyCoordinate.getX() * xyCoordinate.getX()
+ - xyCoordinate.getY() * xyCoordinate.getY()) - earth.getRadius();
MutableVector3D planarPosition = new MutableVector3D(c);
planarPosition.addScaled(y, xyCoordinate.getY());
planarPosition.addScaled(x, xyCoordinate.getX());
diff --git a/src/main/java/util/earth/LatLon.java b/src/main/java/util/earth/LatLon.java
index cde73b1..f010123 100644
--- a/src/main/java/util/earth/LatLon.java
+++ b/src/main/java/util/earth/LatLon.java
@@ -6,8 +6,6 @@
* An immutable container class for a pair of latitude/longitude values measured
* in degrees where latitude is in the interval [-90,90] and longitude is in the
* interval [-180,180]
- *
- *
*/
@Immutable
@@ -35,9 +33,12 @@ public double getLongitude() {
* Constructs a LatLon from the given latitude and longitude
*
* @throws IllegalArgumentException
- * if the latitude is not in the interval [-90,90]
- * if the longitude is not in the interval [-180,180]
- *
+ *
+ * - if the latitude is not in the
+ * interval [-90,90]
+ * - if the longitude is not in the
+ * interval [-180,180]
+ *
* @param latitude
* @param longitude
*/
@@ -61,8 +62,7 @@ public LatLon(double latitude, double longitude) {
/**
* Constructs a LatLon from the given LatLonAlt
*
- * @throws NullPointerException
- * if the latLonAlt is null
+ * @throws NullPointerException if the latLonAlt is null
* @param latLonAlt
*/
public LatLon(LatLonAlt latLonAlt) {
diff --git a/src/main/java/util/earth/LatLonAlt.java b/src/main/java/util/earth/LatLonAlt.java
index 2be2ced..13243ce 100644
--- a/src/main/java/util/earth/LatLonAlt.java
+++ b/src/main/java/util/earth/LatLonAlt.java
@@ -28,9 +28,12 @@ public double getLongitude() {
* Constructs a LatLonAlt from the given latitude and longitude
*
* @throws IllegalArgumentException
- * if the latitude is not in the interval [-90,90]
- * if the longitude is not in the interval [-180,180]
- *
+ *
+ * - if the latitude is not in the
+ * interval [-90,90]
+ * - if the longitude is not in the
+ * interval [-180,180]
+ *
* @param latitude
* @param longitude
*/
@@ -53,17 +56,17 @@ public LatLonAlt(double latitude, double longitude, double altitude) {
}
/**
- * Constructs a LatLonAlt from the given Vector3D where latitude = x,
- * longitude = y and altitude = z
+ * Constructs a LatLonAlt from the given Vector3D where latitude = x, longitude
+ * = y and altitude = z
*
- * @throws NullPointerException
- * if the vector3d is null
- *
- * @throws IllegalArgumentException
- * if the latitude(v.getX()) is not in the interval [-90,90]
- * if the longitude(v.getY()) is not in the interval
- * [-180,180]
- * @param latLonAlt
+ * @throws NullPointerException if the vector3d is null
+ * @throws IllegalArgumentException
+ *
+ * - if the latitude(v.getX()) is not in
+ * the interval [-90,90]
+ * - if the longitude(v.getY()) is not in
+ * the interval [-180,180]
+ *
*/
public LatLonAlt(Vector3D vector3d) {
if (vector3d == null) {
@@ -92,9 +95,7 @@ public LatLonAlt(Vector3D vector3d) {
/**
* Constructs a LatLonAlt from the given LatLon with altitude set to zero
*
- * @throws NullPointerException
- * if the latLon is null
- * @param latLonAlt
+ * @throws NullPointerException if the latLon is null
*/
public LatLonAlt(LatLon latLon) {
@@ -115,8 +116,8 @@ public double getAltitude() {
}
/**
- * Returns a Vector3D from this LatLonAlt where x = latitude, y = longitude
- * and z = altitude.
+ * Returns a Vector3D from this LatLonAlt where x = latitude, y = longitude and
+ * z = altitude.
*/
public Vector3D toVector3D() {
return new Vector3D(latitude, longitude, altitude);
@@ -140,9 +141,8 @@ public int hashCode() {
}
/**
- * Returns true if and only if this LatLonAlt is compared to another
- * non-null instance of LatLonAlt with matching latitude, longitude and
- * altitude values
+ * Returns true if and only if this LatLonAlt is compared to another non-null
+ * instance of LatLonAlt with matching latitude, longitude and altitude values
*/
@Override
public boolean equals(Object obj) {
@@ -163,9 +163,8 @@ public boolean equals(Object obj) {
}
/**
- * Returns a string of the form
- *
- * LatLonAlt [latitude=35.0, longitude=128.0, altitude=1000.0]
+ * Returns a string of the form LatLonAlt [latitude=35.0, longitude=128.0,
+ * altitude=1000.0]
*/
@Override
public String toString() {
diff --git a/src/main/java/util/errors/ContractError.java b/src/main/java/util/errors/ContractError.java
index 4d1c432..9a3f81d 100644
--- a/src/main/java/util/errors/ContractError.java
+++ b/src/main/java/util/errors/ContractError.java
@@ -4,8 +4,6 @@
/**
* Marker interface for the descriptions of runtime exceptions where the source
* of the error is the violation of a contract (precondition) specification.
- *
- *
*/
public interface ContractError {
public String getDescription();
diff --git a/src/main/java/util/errors/ContractException.java b/src/main/java/util/errors/ContractException.java
index 08d65a3..fa98fd3 100644
--- a/src/main/java/util/errors/ContractException.java
+++ b/src/main/java/util/errors/ContractException.java
@@ -3,8 +3,6 @@
/**
* A {@link RuntimeException} that indicates that the cause of the error as a
* precondition(contract) violation
- *
- *
*/
public final class ContractException extends RuntimeException {
@@ -17,9 +15,7 @@ public final class ContractException extends RuntimeException {
* exception's message value will be the description value of the contract
* error.
*
- * @throws NullPointerException
- * if the contract error is null
- *
+ * @throws NullPointerException if the contract error is null
*/
public ContractException(final ContractError contractError) {
super(contractError.getDescription());
@@ -27,17 +23,16 @@ public ContractException(final ContractError contractError) {
}
/**
- * Constructs the exception with the given contract error and details value.
- * The resulting exception's message value will be the description value of
- * the contract error concatenated with the details.toString().
- *
- * The result will be contractError.getDescription() + ": " +
- * details.toString())
+ * Constructs the exception with the given contract error and details value. The
+ * resulting exception's message value will be the description value of the
+ * contract error concatenated with the details.toString(). The result will be
+ * contractError.getDescription() + ": " + details.toString())
*
* @throws NullPointerException
- * if the contract error is null
- * if the details value is null
- *
+ *
+ * - if the contract error is null
+ * - if the details value is null
+ *
*/
public ContractException(final ContractError contractError, final Object details) {
super(contractError.getDescription() + ": " + details.toString());
@@ -45,8 +40,8 @@ public ContractException(final ContractError contractError, final Object details
}
/**
- * Returns the SimulationErrorType that documents the general issue that
- * caused the exception.
+ * Returns the SimulationErrorType that documents the general issue that caused
+ * the exception.
*/
public ContractError getErrorType() {
return contractError;
diff --git a/src/main/java/util/geolocator/GeoLocator.java b/src/main/java/util/geolocator/GeoLocator.java
index 370c4ac..5768131 100644
--- a/src/main/java/util/geolocator/GeoLocator.java
+++ b/src/main/java/util/geolocator/GeoLocator.java
@@ -19,8 +19,6 @@
* A generics-based utility class for managing point locations on a spherical
* earth of WGS-84 mean radius. This utility specifically finds locations based
* on lat-lon coordinates and a search radius.
- *
- *
*/
public class GeoLocator {
@@ -65,7 +63,6 @@ public Data(Data data) {
* Builder class for {@linkplain GeoLocator}. Builder instances return to an
* empty and ready state post build invocation.
*
- *
* @param
*/
public static class Builder {
@@ -84,8 +81,8 @@ public Builder addLocation(double latDegrees, double lonDegrees, T location)
}
/**
- * Returns a {@linkplain GeoLocator} containing the locations presented
- * to this builder.
+ * Returns a {@linkplain GeoLocator} containing the locations presented to this
+ * builder.
*/
public GeoLocator build() {
return new GeoLocator<>(new Data<>(data));
@@ -93,9 +90,9 @@ public GeoLocator build() {
}
/*
- * Record for holding the location data converted to Earth centered
- * coordinates (in meters) as an ECC instance. Each such record corresponds
- * to one of the location records recorded by the builder.
+ * Record for holding the location data converted to Earth centered coordinates
+ * (in meters) as an ECC instance. Each such record corresponds to one of the
+ * location records recorded by the builder.
*/
private static class LocationEccRecord {
@@ -115,16 +112,16 @@ public LocationEccRecord(Vector3D ecc, T location) {
private final DimensionTree> dimensionTree;
/*
- * A utility object for converting to and from lat/lon and ecc coordinates.
- * This is a spherical earth using a WGS84 mean earth radius.
+ * A utility object for converting to and from lat/lon and ecc coordinates. This
+ * is a spherical earth using a WGS84 mean earth radius.
*/
private final Earth earth = Earth.fromMeanRadius();
private GeoLocator(Data scaffold) {
/*
- * Create the Location Position Records(ecc-vector based) from the
- * Location Records(lat-lon based)
+ * Create the Location Position Records(ecc-vector based) from the Location
+ * Records(lat-lon based)
*/
List> locationEccRecords = scaffold.locationRecords.stream().map(rec -> {
LatLonAlt latLonAlt = new LatLonAlt(rec.latDegrees, rec.lonDegrees, 0);
@@ -133,11 +130,13 @@ private GeoLocator(Data scaffold) {
}).collect(Collectors.toList());
/*
- * Initialize the bounding box for the tree. This is not strictly
- * necessary, but it will improve the tree's performance.
+ * Initialize the bounding box for the tree. This is not strictly necessary, but
+ * it will improve the tree's performance.
*/
- double[] lowerBounds = new double[] { Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY };
- double[] upperBounds = new double[] { Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY };
+ double[] lowerBounds = new double[] { Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY,
+ Double.POSITIVE_INFINITY };
+ double[] upperBounds = new double[] { Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY,
+ Double.NEGATIVE_INFINITY };
/*
* Refine the bounding box using the Location Position Records
@@ -158,10 +157,10 @@ private GeoLocator(Data scaffold) {
/*
* Build the tree
*/
- dimensionTree = DimensionTree .builder() //
- .setLowerBounds(lowerBounds)//
- .setUpperBounds(upperBounds)//
- .build();//
+ dimensionTree = DimensionTree.builder() //
+ .setLowerBounds(lowerBounds)//
+ .setUpperBounds(upperBounds)//
+ .build();//
/*
* Load the tree with the Location Position Records
@@ -179,24 +178,24 @@ private double getLinearSearchRangeMeters(double groundRangeInMeters) {
}
/**
- * Returns the list of locations that are within the given radius in
- * kilometers from the given lat-lon position.
+ * Returns the list of locations that are within the given radius in kilometers
+ * from the given lat-lon position.
*/
public List getLocations(double latDegrees, double lonDegrees, double radiusKilometers) {
double linearSearchRangeMeters = getLinearSearchRangeMeters(radiusKilometers * 1000);
double[] position = earth.getECCFromLatLonAlt(new LatLonAlt(latDegrees, lonDegrees, 0)).toArray();
return dimensionTree.getMembersInSphere(linearSearchRangeMeters, position).stream()//
- .map(rec -> rec.location)//
- .collect(Collectors.toList());//
+ .map(rec -> rec.location)//
+ .collect(Collectors.toList());//
}
/**
- * Returns the list of locations that are within the given radius in
- * kilometers from the given lat-lon position as Pairs of location and
- * distance(km). The resulting pairs are returned in ascending order by
- * distance.
+ * Returns the list of locations that are within the given radius in kilometers
+ * from the given lat-lon position as Pairs of location and distance(km). The
+ * resulting pairs are returned in ascending order by distance.
*/
- public List> getPrioritizedLocations(double latDegrees, double lonDegrees, double radiusKilometers) {
+ public List> getPrioritizedLocations(double latDegrees, double lonDegrees,
+ double radiusKilometers) {
double linearSearchRangeMeters = getLinearSearchRangeMeters(radiusKilometers * 1000);
@@ -205,18 +204,18 @@ public List> getPrioritizedLocations(double latDegrees, double l
double[] positionArray = ecc.toArray();
return dimensionTree.getMembersInSphere(linearSearchRangeMeters, positionArray).stream()//
- .map(rec -> {
- double distance = earth.getGroundDistanceFromECC(ecc, rec.ecc);
- return new Pair<>(rec.location, distance / 1000);
- })//
- .sorted(Comparator.comparingDouble(Pair::getValue))//
- .collect(Collectors.toList());//
+ .map(rec -> {
+ double distance = earth.getGroundDistanceFromECC(ecc, rec.ecc);
+ return new Pair<>(rec.location, distance / 1000);
+ })//
+ .sorted(Comparator.comparingDouble(Pair::getValue))//
+ .collect(Collectors.toList());//
}
/**
* Returns the nearest location in this {@linkplain GeoLocator} to the given
- * lat-lon position if any can be found. Ties for nearest location result in
- * an arbitrary selection.
+ * lat-lon position if any can be found. Ties for nearest location result in an
+ * arbitrary selection.
*/
public Optional getNearestLocation(double latDegrees, double lonDegrees) {
LatLonAlt latLonAlt = new LatLonAlt(latDegrees, lonDegrees, 0);
diff --git a/src/main/java/util/graph/Graph.java b/src/main/java/util/graph/Graph.java
index 6f78a6e..d05daa7 100644
--- a/src/main/java/util/graph/Graph.java
+++ b/src/main/java/util/graph/Graph.java
@@ -14,8 +14,7 @@ public final class Graph {
}
/**
- * Returns a hash code that is the sum of the hash codes of its nodes and
- * edges.
+ * Returns a hash code that is the sum of the hash codes of its nodes and edges.
*/
@Override
public int hashCode() {
@@ -23,9 +22,9 @@ public int hashCode() {
}
/**
- * Returns true if and only if the given object is an instance of
- * {@link Graph} or {@link MutableGraph} that contains the same nodes and
- * edges as this {@link Graph}
+ * Returns true if and only if the given object is an instance of {@link Graph}
+ * or {@link MutableGraph} that contains the same nodes and edges as this
+ * {@link Graph}
*/
@Override
public boolean equals(Object obj) {
@@ -59,8 +58,8 @@ public Builder addNode(N node) {
}
/**
- * Adds the edge to this graph, possibly replacing the edge if it is
- * already in the graph. Adds the nodes if required.
+ * Adds the edge to this graph, possibly replacing the edge if it is already in
+ * the graph. Adds the nodes if required.
*/
public Builder addEdge(E edge, N originNode, N destinationNode) {
mutableGraph.addEdge(edge, originNode, destinationNode);
@@ -196,11 +195,9 @@ public List getNodes() {
}
/**
- * Supplies an iterable over the edges from the origin node to the
- * destination node.
+ * Supplies an iterable over the edges from the origin node to the destination
+ * node.
*
- * @param originNode
- * @param destinationNode
* @return
*/
public List getEdges() {
diff --git a/src/main/java/util/graph/GraphDepthEvaluator.java b/src/main/java/util/graph/GraphDepthEvaluator.java
index 0574c06..58cd4fd 100644
--- a/src/main/java/util/graph/GraphDepthEvaluator.java
+++ b/src/main/java/util/graph/GraphDepthEvaluator.java
@@ -16,12 +16,8 @@
* graphs that represent dependencies between nodes. Its is used to establish an
* ordering of nodes such that nodes that have no dependencies on other nodes
* are deemed as rank zero, nodes that depend only on rank zero nodes are deemed
- * rank 1 and so on.
- *
- * Dependency in the graph is represented by edges. An edge directed from node A
- * to node B is taken to mean that A depends on B.
- *
- *
+ * rank 1 and so on. Dependency in the graph is represented by edges. An edge
+ * directed from node A to node B is taken to mean that A depends on B.
*/
@Immutable
public final class GraphDepthEvaluator {
@@ -81,8 +77,8 @@ public int getDepth(N node) {
}
/**
- * Returns the nodes associated with the given depth. Will return an empty
- * list for depth values that are negative or exceed the max depth
+ * Returns the nodes associated with the given depth. Will return an empty list
+ * for depth values that are negative or exceed the max depth
*/
public List getNodesForDepth(int depth) {
List result = new ArrayList<>();
@@ -94,8 +90,8 @@ public List getNodesForDepth(int depth) {
}
/**
- * Returns the nodes of the graph in their ascending rank orders. Within a
- * rank, the order is arbitrary but repeatable across instances of
+ * Returns the nodes of the graph in their ascending rank orders. Within a rank,
+ * the order is arbitrary but repeatable across instances of
* {@link GraphDepthEvaluator} for any given {@link Graph}.
*/
public List getNodesInRankOrder() {
@@ -107,10 +103,9 @@ public List getNodesInRankOrder() {
}
/**
- * Static constructor for {@link GraphDepthEvaluator} that orders the nodes
- * of the given graph by the dependency relationship represented by the
- * graph's edges. Returns {@link Optional#empty()} if the graph contains any
- * cycles.
+ * Static constructor for {@link GraphDepthEvaluator} that orders the nodes of
+ * the given graph by the dependency relationship represented by the graph's
+ * edges. Returns {@link Optional#empty()} if the graph contains any cycles.
*/
public static Optional> getGraphDepthEvaluator(Graph graph) {
if (Graphs.getGraphCyclisity(graph) == Graphs.GraphCyclisity.ACYCLIC) {
diff --git a/src/main/java/util/graph/Graphs.java b/src/main/java/util/graph/Graphs.java
index 3a18901..fa98005 100644
--- a/src/main/java/util/graph/Graphs.java
+++ b/src/main/java/util/graph/Graphs.java
@@ -34,9 +34,9 @@ public static enum GraphCyclisity {
/**
* Returns the sub-graph of the input graph that has had all of its acyclic
- * parts (sources and sinks) removed. That is, the resultant graph will
- * contain only cycles. This method is commonly used to determine whether a
- * graph is acyclic, i.e. the returned graph is empty, with no nodes.
+ * parts (sources and sinks) removed. That is, the resultant graph will contain
+ * only cycles. This method is commonly used to determine whether a graph is
+ * acyclic, i.e. the returned graph is empty, with no nodes.
*/
public static Graph getSourceSinkReducedGraph(Graph graph) {
MutableGraph mutableGraph = new MutableGraph<>();
@@ -55,21 +55,20 @@ public static Graph getSourceSinkReducedGraph(Graph graph) {
}
/**
- * Returns the sub-graph of the input graph that has had all of its
- * non-cyclic edges removed. A non-cyclic edge is one
- * where there is no path through the graph from the edge's destination node
- * to its source node.
+ * Returns the sub-graph of the input graph that has had all of its non-cyclic
+ * edges removed. A non-cyclic edge is one where there is no path through the
+ * graph from the edge's destination node to its source node.
*/
public static Graph getEdgeReducedGraph(Graph graph) {
MutableGraph mutableGraph = new MutableGraph<>();
mutableGraph.addAll(graph);
List edges = graph.getEdges();
-
- for(E edge : edges) {
+
+ for (E edge : edges) {
N originNode = graph.getOriginNode(edge);
N destinationNode = graph.getDestinationNode(edge);
- Optional> optional = Paths.getPath(graph, destinationNode, originNode, (e)->1, (a,b)->0);
- if(optional.isEmpty()) {
+ Optional> optional = Paths.getPath(graph, destinationNode, originNode, (e) -> 1, (a, b) -> 0);
+ if (optional.isEmpty()) {
mutableGraph.removeEdge(edge);
}
}
@@ -78,7 +77,6 @@ public static Graph getEdgeReducedGraph(Graph graph) {
/**
* Returns the GraphCyclisity of the given graph
- *
*/
public static GraphCyclisity getGraphCyclisity(Graph graph) {
@@ -93,26 +91,17 @@ public static GraphCyclisity getGraphCyclisity(Graph graph) {
}
/**
- *
- * An enumeration of the three types of graph connectedness.
- *
- * Strongly connected graphs are ones in which for every pair (not
- * necessarily distinct) of nodes in the graph there exits a Path connecting
- * those nodes. Note that a node is not implicitly connected to itself.
- *
- * Weakly connected graphs are ones where the nodes connect to one another
- * if edge directionality is ignored. Formally, let graph G exist with edges
- * E and nodes N. Construct a graph GPrime with all of N and E(i.e. a copy
- * of G). For each edge e in E, add an oppositely directed to GPrime. G is
- * weakly connected graph if and only if GPrime is strongly connected.
- *
- * Disconnected graphs are those that are neither strongly nor weakly
- * connected.
- *
- * Note that strongly connected graphs are weakly connected. Empty graphs
- * are considered strongly connected.
- *
- *
+ * An enumeration of the three types of graph connectedness. Strongly connected
+ * graphs are ones in which for every pair (not necessarily distinct) of nodes
+ * in the graph there exits a Path connecting those nodes. Note that a node is
+ * not implicitly connected to itself. Weakly connected graphs are ones where
+ * the nodes connect to one another if edge directionality is ignored. Formally,
+ * let graph G exist with edges E and nodes N. Construct a graph GPrime with all
+ * of N and E(i.e. a copy of G). For each edge e in E, add an oppositely
+ * directed to GPrime. G is weakly connected graph if and only if GPrime is
+ * strongly connected. Disconnected graphs are those that are neither strongly
+ * nor weakly connected. Note that strongly connected graphs are weakly
+ * connected. Empty graphs are considered strongly connected.
*/
public static enum GraphConnectedness {
STRONGLYCONNECTED,
@@ -123,9 +112,7 @@ public static enum GraphConnectedness {
}
/**
- *
* Determines the connectedness of a graph
- *
*/
public static GraphConnectedness getGraphConnectedness(Graph graph) {
if (cutGraph(graph).size() == 1) {
@@ -140,11 +127,9 @@ public static GraphConnectedness getGraphConnectedness(Graph graph)
}
/**
- *
- * Separates a graph into a set of independent weakly connected and
- * disconnected sub graphs. All disconnected subgraphs will consist of
- * single nodes with no edges.
- *
+ * Separates a graph into a set of independent weakly connected and disconnected
+ * sub graphs. All disconnected subgraphs will consist of single nodes with no
+ * edges.
*/
public static List> cutGraph(Graph graph) {
// create a list to receive the graphs
@@ -239,8 +224,8 @@ public static List> cutGraph(Graph graph) {
}
/**
- * Returns a graph that has the same nodes and edges as the given graph,
- * with each edge being reversed
+ * Returns a graph that has the same nodes and edges as the given graph, with
+ * each edge being reversed
*/
public static Graph getReverseGraph(Graph graph) {
diff --git a/src/main/java/util/graph/MutableGraph.java b/src/main/java/util/graph/MutableGraph.java
index 8bc728d..2210d0e 100644
--- a/src/main/java/util/graph/MutableGraph.java
+++ b/src/main/java/util/graph/MutableGraph.java
@@ -8,12 +8,9 @@
import java.util.Set;
/**
- *
* A generics-based, mutable graph of nodes(N) and edges(E). All iterators are
* immutable and will throw UnsupportedOperationException runtime exception on
* remove().
- *
- *
*/
public final class MutableGraph {
@@ -50,8 +47,7 @@ public void addAll(Graph graph) {
/*
* Returns a {@link Graph} backed by this {@link MutableGraph}. Mutations in
- * this {@link MutableGraph} will be reflected in the resultant {@link
- * Graph}
+ * this {@link MutableGraph} will be reflected in the resultant {@link Graph}
*
* This method is package access only and should only be used to reduce the
* overhead costs of creating Graphs from MutableGraphs.
@@ -89,8 +85,8 @@ public void addAll(MutableGraph graph) {
}
/**
- * Adds the edge to this graph, possibly replacing the edge if it is already
- * in the graph. Adds the nodes if required.
+ * Adds the edge to this graph, possibly replacing the edge if it is already in
+ * the graph. Adds the nodes if required.
*/
public void addEdge(E edge, N originNode, N destinationNode) {
removeEdge(edge);
@@ -385,8 +381,7 @@ public int edgeCount(N originNode, N destinationNode) {
}
/**
- * Returns a hash code that is the sum of the hash codes of its nodes and
- * edges.
+ * Returns a hash code that is the sum of the hash codes of its nodes and edges.
*/
@Override
public int hashCode() {
@@ -403,9 +398,9 @@ public int hashCode() {
}
/**
- * Returns true if and only if the given object is an instance of
- * {@link Graph} or {@link MutableGraph} that contains the same nodes and
- * edges as this {@link MutableGraph}
+ * Returns true if and only if the given object is an instance of {@link Graph}
+ * or {@link MutableGraph} that contains the same nodes and edges as this
+ * {@link MutableGraph}
*/
@SuppressWarnings("rawtypes")
diff --git a/src/main/java/util/maps/MapReindexer.java b/src/main/java/util/maps/MapReindexer.java
index c4315c8..7332bee 100644
--- a/src/main/java/util/maps/MapReindexer.java
+++ b/src/main/java/util/maps/MapReindexer.java
@@ -5,31 +5,29 @@
import java.util.Set;
public class MapReindexer {
-
+
private MapReindexer() {
-
+
}
-
-
- public static Map getReindexedMap(Set indexingSet, Map targetMap) {
-
- Map result = new LinkedHashMap<>();
-
- for(A a : indexingSet) {
+
+ public static Map getReindexedMap(Set indexingSet, Map targetMap) {
+
+ Map result = new LinkedHashMap<>();
+
+ for (A a : indexingSet) {
B b = targetMap.get(a);
- if(b != null) {
+ if (b != null) {
result.put(a, b);
}
}
-
- for(A a : targetMap.keySet()) {
- if(!indexingSet.contains(a)) {
+
+ for (A a : targetMap.keySet()) {
+ if (!indexingSet.contains(a)) {
result.put(a, targetMap.get(a));
}
}
-
- return result;
+
+ return result;
}
-
-
+
}
diff --git a/src/main/java/util/meta/classdependency/classgraph/ClassGraphDriver.java b/src/main/java/util/meta/classdependency/classgraph/ClassGraphDriver.java
index dcd599e..b3d1d43 100644
--- a/src/main/java/util/meta/classdependency/classgraph/ClassGraphDriver.java
+++ b/src/main/java/util/meta/classdependency/classgraph/ClassGraphDriver.java
@@ -19,11 +19,11 @@ public static void main(String[] args) throws IOException {
String directoryName = args[0];
Path path = Paths.get(directoryName);
ClassDependencyScan classDependencyScan = ClassDependencyScanner.execute(path);
-
+
WildCardReport.report(classDependencyScan);
-
+
CircularPackageDependencyReport.report(classDependencyScan);
-
+
CircularClassDependencyReport.report(classDependencyScan);
}
diff --git a/src/main/java/util/meta/classdependency/classgraph/reports/CircularClassDependencyReport.java b/src/main/java/util/meta/classdependency/classgraph/reports/CircularClassDependencyReport.java
index 454fe2a..8f8cbc1 100644
--- a/src/main/java/util/meta/classdependency/classgraph/reports/CircularClassDependencyReport.java
+++ b/src/main/java/util/meta/classdependency/classgraph/reports/CircularClassDependencyReport.java
@@ -6,12 +6,12 @@
import java.util.Set;
import java.util.stream.Collectors;
-import util.meta.classdependency.classgraph.support.ClassDependencyScan;
-import util.meta.classdependency.classgraph.support.JavaDependency;
import util.graph.Graph;
import util.graph.GraphDepthEvaluator;
import util.graph.Graphs;
import util.graph.MutableGraph;
+import util.meta.classdependency.classgraph.support.ClassDependencyScan;
+import util.meta.classdependency.classgraph.support.JavaDependency;
public final class CircularClassDependencyReport {
private CircularClassDependencyReport() {
@@ -20,27 +20,26 @@ private CircularClassDependencyReport() {
public static void report(ClassDependencyScan classDependencyScan) {
System.out.println();
System.out.println("circular class dependency report");
-
Set javaDependencies = classDependencyScan.getJavaDependencies();
Set localPackageNames = classDependencyScan.getLocalPackageNames();
-
-
+
MutableGraph m = new MutableGraph<>();
for (JavaDependency javaDependency : javaDependencies) {
- String sourceFileName = javaDependency.getDependentRef().getPackageName()+"."+javaDependency.getDependentRef().getClassName();
- String importFileName = javaDependency.getSupportRef().getPackageName()+"."+javaDependency.getSupportRef().getClassName();
+ String sourceFileName = javaDependency.getDependentRef().getPackageName() + "."
+ + javaDependency.getDependentRef().getClassName();
+ String importFileName = javaDependency.getSupportRef().getPackageName() + "."
+ + javaDependency.getSupportRef().getClassName();
if (localPackageNames.contains(javaDependency.getSupportRef().getPackageName())) {
m.addEdge(new Object(), sourceFileName, importFileName);
}
}
-
Optional> optional = GraphDepthEvaluator.getGraphDepthEvaluator(m.toGraph());
if (optional.isPresent()) {
System.out.println();
System.out.println("acyclic layers");
-
+
GraphDepthEvaluator graphDepthEvaluator = optional.get();
int maxDepth = graphDepthEvaluator.getMaxDepth();
for (int i = 0; i <= maxDepth; i++) {
@@ -52,20 +51,20 @@ public static void report(ClassDependencyScan classDependencyScan) {
} else {
System.out.println();
System.out.println("cyclic groups");
-
+
Graph g = m.toGraph();
-
+
g = Graphs.getSourceSinkReducedGraph(g);
-
+
g = Graphs.getEdgeReducedGraph(g);
-
+
g = Graphs.getSourceSinkReducedGraph(g);
-
+
List> cutGraphs = Graphs.cutGraph(g);
StringBuilder sb = new StringBuilder();
String lineSeparator = System.getProperty("line.separator");
-
- for (Graph cutGraph : cutGraphs) {
+
+ for (Graph cutGraph : cutGraphs) {
sb.append(lineSeparator);
Set nodes = cutGraph.getNodes().stream().collect(Collectors.toCollection(LinkedHashSet::new));
@@ -81,6 +80,6 @@ public static void report(ClassDependencyScan classDependencyScan) {
}
System.out.println(sb);
}
-
+
}
}
diff --git a/src/main/java/util/meta/classdependency/classgraph/reports/CircularPackageDependencyReport.java b/src/main/java/util/meta/classdependency/classgraph/reports/CircularPackageDependencyReport.java
index 715fe54..7db2b93 100644
--- a/src/main/java/util/meta/classdependency/classgraph/reports/CircularPackageDependencyReport.java
+++ b/src/main/java/util/meta/classdependency/classgraph/reports/CircularPackageDependencyReport.java
@@ -6,12 +6,12 @@
import java.util.Set;
import java.util.stream.Collectors;
-import util.meta.classdependency.classgraph.support.ClassDependencyScan;
-import util.meta.classdependency.classgraph.support.JavaDependency;
import util.graph.Graph;
import util.graph.GraphDepthEvaluator;
import util.graph.Graphs;
import util.graph.MutableGraph;
+import util.meta.classdependency.classgraph.support.ClassDependencyScan;
+import util.meta.classdependency.classgraph.support.JavaDependency;
public final class CircularPackageDependencyReport {
private CircularPackageDependencyReport() {
@@ -20,12 +20,10 @@ private CircularPackageDependencyReport() {
public static void report(ClassDependencyScan classDependencyScan) {
System.out.println();
System.out.println("circular package dependency report");
-
Set javaDependencies = classDependencyScan.getJavaDependencies();
Set localPackageNames = classDependencyScan.getLocalPackageNames();
-
-
+
MutableGraph m = new MutableGraph<>();
for (JavaDependency javaDependency : javaDependencies) {
String sourcePackageName = javaDependency.getDependentRef().getPackageName();
@@ -39,7 +37,7 @@ public static void report(ClassDependencyScan classDependencyScan) {
if (optional.isPresent()) {
System.out.println();
System.out.println("acyclic layers");
-
+
GraphDepthEvaluator graphDepthEvaluator = optional.get();
int maxDepth = graphDepthEvaluator.getMaxDepth();
for (int i = 0; i <= maxDepth; i++) {
@@ -51,20 +49,20 @@ public static void report(ClassDependencyScan classDependencyScan) {
} else {
System.out.println();
System.out.println("cyclic groups");
-
+
Graph g = m.toGraph();
g = Graphs.getSourceSinkReducedGraph(g);
-
+
g = Graphs.getEdgeReducedGraph(g);
-
+
g = Graphs.getSourceSinkReducedGraph(g);
-
+
List> cutGraphs = Graphs.cutGraph(g);
StringBuilder sb = new StringBuilder();
String lineSeparator = System.getProperty("line.separator");
-
- for (Graph cutGraph : cutGraphs) {
+
+ for (Graph cutGraph : cutGraphs) {
sb.append(lineSeparator);
Set nodes = cutGraph.getNodes().stream().collect(Collectors.toCollection(LinkedHashSet::new));
@@ -80,6 +78,6 @@ public static void report(ClassDependencyScan classDependencyScan) {
}
System.out.println(sb);
}
-
+
}
}
diff --git a/src/main/java/util/meta/classdependency/classgraph/support/ClassDependencyScan.java b/src/main/java/util/meta/classdependency/classgraph/support/ClassDependencyScan.java
index a6962e5..bf9ed3a 100644
--- a/src/main/java/util/meta/classdependency/classgraph/support/ClassDependencyScan.java
+++ b/src/main/java/util/meta/classdependency/classgraph/support/ClassDependencyScan.java
@@ -14,8 +14,10 @@ private ClassDependencyScan(Data data) {
private static class Data {
private Set javaDependencies = new LinkedHashSet<>();
private Set localPackageNames = new LinkedHashSet<>();
-
- public Data() {}
+
+ public Data() {
+ }
+
public Data(Data data) {
javaDependencies.addAll(data.javaDependencies);
localPackageNames.addAll(localPackageNames);
diff --git a/src/main/java/util/meta/classdependency/classgraph/support/ClassDependencyScanner.java b/src/main/java/util/meta/classdependency/classgraph/support/ClassDependencyScanner.java
index 6db8183..0d5b89c 100644
--- a/src/main/java/util/meta/classdependency/classgraph/support/ClassDependencyScanner.java
+++ b/src/main/java/util/meta/classdependency/classgraph/support/ClassDependencyScanner.java
@@ -81,14 +81,14 @@ public FileVisitResult visitFile(final Path file, final BasicFileAttributes attr
}
}
- private ClassDependencyScanner() {
+ private ClassDependencyScanner() {
}
public static ClassDependencyScan execute(Path dir) throws IOException {
final SourceFileVisitor sourceFileVisitor = new SourceFileVisitor(dir);
Files.walkFileTree(dir, sourceFileVisitor);
return sourceFileVisitor.builder.build();
-
+
}
}
diff --git a/src/main/java/util/meta/classdependency/classgraph/support/JavaRef.java b/src/main/java/util/meta/classdependency/classgraph/support/JavaRef.java
index aaa39ba..f13fa32 100644
--- a/src/main/java/util/meta/classdependency/classgraph/support/JavaRef.java
+++ b/src/main/java/util/meta/classdependency/classgraph/support/JavaRef.java
@@ -7,7 +7,7 @@ public final class JavaRef {
private final String className;
private final String packageName;
- public JavaRef(String className, String packageName) {
+ public JavaRef(String className, String packageName) {
this.className = className;
this.packageName = packageName;
}
@@ -65,10 +65,9 @@ public String toString() {
builder.append("]");
return builder.toString();
}
-
+
public String getFullName() {
- return packageName+"."+className+".java";
+ return packageName + "." + className + ".java";
}
-
}
diff --git a/src/main/java/util/meta/classdependency/dependency/DependencyTracer.java b/src/main/java/util/meta/classdependency/dependency/DependencyTracer.java
index 22e2d4c..b175c34 100644
--- a/src/main/java/util/meta/classdependency/dependency/DependencyTracer.java
+++ b/src/main/java/util/meta/classdependency/dependency/DependencyTracer.java
@@ -81,10 +81,9 @@ private static void big() throws IOException {
Path dir = Paths.get("C:\\git_repos\\ASPR-8\\gcm4\\src\\main\\java\\plugins");
List pluginNames = new ArrayList<>();
-
-
+
pluginNames.add("globalproperties");
- pluginNames.add("groups");
+ pluginNames.add("groups");
pluginNames.add("materials");
pluginNames.add("partitions");
pluginNames.add("people");
diff --git a/src/main/java/util/meta/codecount/CodeCountReport.java b/src/main/java/util/meta/codecount/CodeCountReport.java
index f7e0d39..a5b8a66 100644
--- a/src/main/java/util/meta/codecount/CodeCountReport.java
+++ b/src/main/java/util/meta/codecount/CodeCountReport.java
@@ -76,7 +76,8 @@ public CodeCountReport build() {
codeCountReport.totalBlankLineCount = rootNode.getLineCount(LineType.BLANK);
codeCountReport.totalCodeLineCount = rootNode.getLineCount(LineType.CODE);
codeCountReport.totalCommentLineCount = rootNode.getLineCount(LineType.COMMENT);
- int totalLineCount = codeCountReport.totalBlankLineCount + codeCountReport.totalCodeLineCount + codeCountReport.totalCommentLineCount;
+ int totalLineCount = codeCountReport.totalBlankLineCount + codeCountReport.totalCodeLineCount
+ + codeCountReport.totalCommentLineCount;
StringBuilder sb = new StringBuilder();
for (LineType lineType : LineType.values()) {
diff --git a/src/main/java/util/meta/packagedependency/PackageDependencyData.java b/src/main/java/util/meta/packagedependency/PackageDependencyData.java
index 44b3cc6..f05d131 100644
--- a/src/main/java/util/meta/packagedependency/PackageDependencyData.java
+++ b/src/main/java/util/meta/packagedependency/PackageDependencyData.java
@@ -4,16 +4,15 @@
import java.util.LinkedHashSet;
import java.util.Set;
-import util.meta.packagedependency.reports.PackageDependencyReport;
import util.graph.Graph;
import util.graph.MutableGraph;
+import util.meta.packagedependency.reports.PackageDependencyReport;
/**
* An immutable container for holding the primary level of package dependency
* analysis data. It is generated by the
* {@linkplain PackageDependencyDataGenerator} and is used by the
* {@linkplain PackageDependencyReport}
- *
*/
public final class PackageDependencyData {
@@ -89,26 +88,30 @@ public String toString() {
}
private static class Data {
- private Graph graph = new MutableGraph().toGraph();
+ private Graph graph = new MutableGraph()
+ .toGraph();
private Set wildCardClasses = new LinkedHashSet<>();
private Set packagelessClasses = new LinkedHashSet<>();
private Set uncoveredClasses = new LinkedHashSet<>();
private Set inputDirectories = new LinkedHashSet<>();
private Set inputPackageNames = new LinkedHashSet<>();
private Set packageNamesFound = new LinkedHashSet<>();
- public Data() {}
+
+ public Data() {
+ }
+
public Data(Data data) {
MutableGraph m = new MutableGraph();
- for(PackageRef packageRef : data.graph.getNodes()) {
+ for (PackageRef packageRef : data.graph.getNodes()) {
m.addNode(packageRef);
}
- for(PackageDependencyDetails packageDependencyDetails : data.graph.getEdges()) {
+ for (PackageDependencyDetails packageDependencyDetails : data.graph.getEdges()) {
PackageRef originNode = data.graph.getOriginNode(packageDependencyDetails);
PackageRef destinationNode = data.graph.getDestinationNode(packageDependencyDetails);
m.addEdge(packageDependencyDetails, originNode, destinationNode);
}
graph = m.toGraph();
-
+
wildCardClasses.addAll(data.wildCardClasses);
packagelessClasses.addAll(data.packagelessClasses);
uncoveredClasses.addAll(data.uncoveredClasses);
@@ -136,8 +139,7 @@ public PackageDependencyData build() {
/**
* Adds a constructor warning
*
- * @throws NullPointerException
- * if the graph is null
+ * @throws NullPointerException if the graph is null
*/
public Builder setGraph(Graph graph) {
if (graph == null) {
@@ -151,9 +153,7 @@ public Builder setGraph(Graph graph) {
* Adds a wildcard class reference. A wildcard class is one containing a
* wildcard character in its import statements
*
- *
- * @throws NullPointerException
- * if the wildcard class is null
+ * @throws NullPointerException if the wildcard class is null
*/
public Builder addWildCardClass(String wildcardClass) {
if (wildcardClass == null) {
@@ -164,12 +164,10 @@ public Builder addWildCardClass(String wildcardClass) {
}
/**
- * Adds a packageless class reference. A packageless class is one having
- * not package statement
- *
+ * Adds a packageless class reference. A packageless class is one having not
+ * package statement
*
- * @throws NullPointerException
- * if the wildcard class is null
+ * @throws NullPointerException if the wildcard class is null
*/
public Builder addPackagelessClass(String packagelessClass) {
if (packagelessClass == null) {
@@ -181,13 +179,11 @@ public Builder addPackagelessClass(String packagelessClass) {
}
/**
- * Adds an uncovered class reference. An uncovered class is a java class
- * found in the scanned directories that does not match any of the
- * contributed package names.
- *
+ * Adds an uncovered class reference. An uncovered class is a java class found
+ * in the scanned directories that does not match any of the contributed package
+ * names.
*
- * @throws NullPointerException
- * if the wildcard class is null
+ * @throws NullPointerException if the wildcard class is null
*/
public Builder addUncoveredClass(String uncoveredClass) {
if (uncoveredClass == null) {
@@ -200,9 +196,7 @@ public Builder addUncoveredClass(String uncoveredClass) {
/**
* Adds an input directory.
*
- *
- * @throws NullPointerException
- * if the directory is null
+ * @throws NullPointerException if the directory is null
*/
public Builder addInputDirectory(Path directory) {
if (directory == null) {
@@ -215,9 +209,7 @@ public Builder addInputDirectory(Path directory) {
/**
* Adds an input package name.
*
- *
- * @throws NullPointerException
- * if the package name is null
+ * @throws NullPointerException if the package name is null
*/
public Builder addInputPackageName(String packageName) {
if (packageName == null) {
@@ -230,9 +222,7 @@ public Builder addInputPackageName(String packageName) {
/**
* Adds a found package name.
*
- *
- * @throws NullPointerException
- * if the package name is null
+ * @throws NullPointerException if the package name is null
*/
public Builder addFoundPackageName(String packageName) {
if (packageName == null) {
diff --git a/src/main/java/util/meta/packagedependency/PackageDependencyDataGenerator.java b/src/main/java/util/meta/packagedependency/PackageDependencyDataGenerator.java
index 678c8af..0cb4251 100644
--- a/src/main/java/util/meta/packagedependency/PackageDependencyDataGenerator.java
+++ b/src/main/java/util/meta/packagedependency/PackageDependencyDataGenerator.java
@@ -15,14 +15,13 @@
import java.util.Map;
import java.util.Set;
+import util.graph.MutableGraph;
import util.meta.packagedependency.PackageDependencyData.PackageDependencyDetails;
import util.meta.packagedependency.PackageDependencyData.PackageRef;
-import util.graph.MutableGraph;
/**
* An utility class for generating a {@linkplain PackageDependencyData} that
* contains an analysis of the package level java dependencies.
- *
*/
public class PackageDependencyDataGenerator {
@@ -31,7 +30,8 @@ private static boolean isJavaFile(Path file) {
}
private static String getClassName(Path sourcePath, Path file) {
- return file.toString().substring(sourcePath.toString().length() + 1, file.toString().length() - 5).replace(File.separator, ".");
+ return file.toString().substring(sourcePath.toString().length() + 1, file.toString().length() - 5)
+ .replace(File.separator, ".");
}
private static class Edge {
@@ -196,22 +196,24 @@ private static class Data {
private List nodeNames = new ArrayList<>();
private Map nodeMap = new LinkedHashMap<>();
private PackageDependencyData.Builder packageDependencyInfoBuilder = PackageDependencyData.builder();
-
- public Data() {}
+
+ public Data() {
+ }
+
public Data(Data data) {
directories.addAll(data.directories);
packageNames.addAll(data.packageNames);
- for(Node node : data.packageDependencyGraph.getNodes()) {
+ for (Node node : data.packageDependencyGraph.getNodes()) {
packageDependencyGraph.addNode(node);
}
- for(Edge edge : data.packageDependencyGraph.getEdges()) {
+ for (Edge edge : data.packageDependencyGraph.getEdges()) {
Node originNode = data.packageDependencyGraph.getOriginNode(edge);
Node destinationNode = data.packageDependencyGraph.getDestinationNode(edge);
packageDependencyGraph.addEdge(edge, originNode, destinationNode);
}
nodeNames.addAll(data.nodeNames);
nodeMap.putAll(data.nodeMap);
-
+
}
}
@@ -237,12 +239,8 @@ private void validate() {
/**
* Adds a source code directory to analyze
*
- * @throws NullPointerException
- * if the path is null
- * @throws IllegalArgumentException
- * if the path is not a directory
- *
- *
+ * @throws NullPointerException if the path is null
+ * @throws IllegalArgumentException if the path is not a directory
*/
public Builder addDirectory(Path directory) {
if (directory == null) {
@@ -257,8 +255,8 @@ public Builder addDirectory(Path directory) {
}
/**
- * Adds a packageName prefix that will be used to group source files
- * into a single node in the analysis
+ * Adds a packageName prefix that will be used to group source files into a
+ * single node in the analysis
*/
public Builder addPackageName(String packageName) {
validatePackageName(packageName);
@@ -341,7 +339,8 @@ public PackageDependencyData execute() {
for (Edge edge : data.packageDependencyGraph.getEdges()) {
Node originNode = data.packageDependencyGraph.getOriginNode(edge);
Node destinationNode = data.packageDependencyGraph.getDestinationNode(edge);
- m.addEdge(new PackageDependencyDetails(edge.classes), new PackageRef(originNode.name), new PackageRef(destinationNode.name));
+ m.addEdge(new PackageDependencyDetails(edge.classes), new PackageRef(originNode.name),
+ new PackageRef(destinationNode.name));
}
data.packageDependencyInfoBuilder.setGraph(m.toGraph());
diff --git a/src/main/java/util/meta/packagedependency/reports/PackageDependencyReport.java b/src/main/java/util/meta/packagedependency/reports/PackageDependencyReport.java
index c7b19ce..f7bcf70 100644
--- a/src/main/java/util/meta/packagedependency/reports/PackageDependencyReport.java
+++ b/src/main/java/util/meta/packagedependency/reports/PackageDependencyReport.java
@@ -7,44 +7,39 @@
import java.util.Optional;
import java.util.Set;
+import util.graph.Graph;
+import util.graph.GraphDepthEvaluator;
+import util.graph.Graphs;
import util.meta.packagedependency.PackageDependencyData;
import util.meta.packagedependency.PackageDependencyData.PackageDependencyDetails;
import util.meta.packagedependency.PackageDependencyData.PackageRef;
import util.meta.packagedependency.PackageDependencyDataGenerator;
-import util.graph.Graph;
-import util.graph.GraphDepthEvaluator;
-import util.graph.Graphs;
/**
* A console report detailing java package level dependencies across multiple
* directories. Inputs consist of 1) directories and 2) package names. The
* package names do not need to be complete. For example, if alpha.beta is a
* full package name, any of the following will work: alph, alpha, alpha.,
- * alpha.bet, etc.
- *
- * Every java class in the covered directories is scanned and the import
- * statements of the class are analyzed. Wildcard characters in the import
- * statements are tolerated, but will result in a warning that the analysis may
- * be invalid. Each import statement is assumed to occupy a single line and each
- * java file should have a package statement.
- *
- * Classes are mapped to the first package name that matches their actual
- * package name. Thus class to class dependencies are mapped to package to
- * package dependencies. Each package to package dependency retains the list of
- * classes that formed that dependency.
- *
- * The ouput consists of:
- * a summary section that lists the inputs
+ * alpha.bet, etc. Every java class in the covered directories is scanned and
+ * the import statements of the class are analyzed. Wildcard characters in the
+ * import statements are tolerated, but will result in a warning that the
+ * analysis may be invalid. Each import statement is assumed to occupy a single
+ * line and each java file should have a package statement. Classes are mapped
+ * to the first package name that matches their actual package name. Thus class
+ * to class dependencies are mapped to package to package dependencies. Each
+ * package to package dependency retains the list of classes that formed that
+ * dependency. The ouput consists of:
+ *
+ * - a summary section that lists the inputs
* - a listing of classes containing wildcard characters in their import
- * statement
- *
- a listing of classes that have no package statements
+ * statement
+ * - a listing of classes that have no package statements
* - a listing of classes that have no corresponding package name in the
- * inputs statements
+ * inputs statements
* - either a listing of any circular package dependencies found or a listinge
- * of the packages in DAG order
- *
- a listing of the package dependencies
- *
- *
+ * of the packages in DAG order
+ * - a listing of the package dependencies
+ *
*/
public class PackageDependencyReport {
@@ -155,8 +150,8 @@ public static void main(final String[] args) {
break;
case HELP:
helpCommandPresent = true;
- if(!commandBlock.arguments.isEmpty()) {
- throw new IllegalArgumentException(commandBlock.command.name()+" cannot accept arguments");
+ if (!commandBlock.arguments.isEmpty()) {
+ throw new IllegalArgumentException(commandBlock.command.name() + " cannot accept arguments");
}
break;
case PACKAGE_NAME:
@@ -166,14 +161,14 @@ public static void main(final String[] args) {
break;
case PRINT_GRAPH:
printGraph = true;
- if(!commandBlock.arguments.isEmpty()) {
- throw new IllegalArgumentException(commandBlock.command.name()+" cannot accept arguments");
+ if (!commandBlock.arguments.isEmpty()) {
+ throw new IllegalArgumentException(commandBlock.command.name() + " cannot accept arguments");
}
break;
case PRINT_FOUND_PACKAGE_NAMES:
printFoundPackageNames = true;
- if(!commandBlock.arguments.isEmpty()) {
- throw new IllegalArgumentException(commandBlock.command.name()+" cannot accept arguments");
+ if (!commandBlock.arguments.isEmpty()) {
+ throw new IllegalArgumentException(commandBlock.command.name() + " cannot accept arguments");
}
break;
default:
@@ -230,7 +225,8 @@ private static void reportGraph(PackageDependencyData packageDependencyData) {
System.out.println("package" + "\t" + "dependency" + "\t" + "class");
- Graph packageDependencyGraph = packageDependencyData.getPackageDependencyGraph();
+ Graph packageDependencyGraph = packageDependencyData
+ .getPackageDependencyGraph();
for (PackageDependencyDetails edge : packageDependencyGraph.getEdges()) {
PackageRef originNode = packageDependencyGraph.getOriginNode(edge);
PackageRef destinationNode = packageDependencyGraph.getDestinationNode(edge);
@@ -244,8 +240,10 @@ private static void reportGraph(PackageDependencyData packageDependencyData) {
private static void reportCircularity(PackageDependencyData packageDependencyData) {
System.out.println();
- Graph packageDependencyGraph = packageDependencyData.getPackageDependencyGraph();
- Optional> optional = GraphDepthEvaluator.getGraphDepthEvaluator(packageDependencyGraph);
+ Graph packageDependencyGraph = packageDependencyData
+ .getPackageDependencyGraph();
+ Optional> optional = GraphDepthEvaluator
+ .getGraphDepthEvaluator(packageDependencyGraph);
if (!optional.isPresent()) {
System.out.println("Circular dependencies were found:");
@@ -294,7 +292,8 @@ private static void reportCircularity(PackageDependencyData packageDependencyDat
System.out.println(sb);
} else {
- System.out.println("No circular package dependencies were found. The packages form an acyclic directed graph with the following levels.");
+ System.out.println(
+ "No circular package dependencies were found. The packages form an acyclic directed graph with the following levels.");
System.out.println();
GraphDepthEvaluator graphDepthEvaluator = optional.get();
int maxDepth = graphDepthEvaluator.getMaxDepth();
@@ -311,7 +310,8 @@ private static void reportWildCardClasses(PackageDependencyData packageDependenc
Set wildcardClasses = packageDependencyData.getWildcardClasses();
if (!wildcardClasses.isEmpty()) {
- System.out.println("The following classes contain wildcard characters in their import statements. All other findings are potentially invalid.");
+ System.out.println(
+ "The following classes contain wildcard characters in their import statements. All other findings are potentially invalid.");
for (String wildcardClass : wildcardClasses) {
System.out.println(wildcardClass);
@@ -322,7 +322,8 @@ private static void reportWildCardClasses(PackageDependencyData packageDependenc
private static void reportPackagelessClasses(PackageDependencyData packageDependencyData) {
Set packagelessClasses = packageDependencyData.getPackagelessClasses();
if (!packagelessClasses.isEmpty()) {
- System.out.println("The following classes do not contain package statements. All other findings are potentially invalid.");
+ System.out.println(
+ "The following classes do not contain package statements. All other findings are potentially invalid.");
for (String wildcardClass : packagelessClasses) {
System.out.println(wildcardClass);
@@ -333,7 +334,8 @@ private static void reportPackagelessClasses(PackageDependencyData packageDepend
private static void reportUncoveredClasses(PackageDependencyData packageDependencyData) {
Set uncoveredClasses = packageDependencyData.getUncoveredClasses();
if (!uncoveredClasses.isEmpty()) {
- System.out.println("The following classes are not covered in the analysis. They were encounted in the contributed directories, but do not match any of the contributed package names.");
+ System.out.println(
+ "The following classes are not covered in the analysis. They were encounted in the contributed directories, but do not match any of the contributed package names.");
for (String wildcardClass : uncoveredClasses) {
System.out.println(wildcardClass);
diff --git a/src/main/java/util/meta/unittestcoverage/MetaInfoContainer.java b/src/main/java/util/meta/unittestcoverage/MetaInfoContainer.java
index 0fb63e6..33e608e 100644
--- a/src/main/java/util/meta/unittestcoverage/MetaInfoContainer.java
+++ b/src/main/java/util/meta/unittestcoverage/MetaInfoContainer.java
@@ -3,12 +3,12 @@
import java.util.ArrayList;
import java.util.List;
-import util.meta.unittestcoverage.warnings.ConstructorWarning;
-import util.meta.unittestcoverage.warnings.FieldWarning;
-import util.meta.unittestcoverage.warnings.MethodWarning;
import util.annotations.UnitTestConstructor;
import util.annotations.UnitTestField;
import util.annotations.UnitTestMethod;
+import util.meta.unittestcoverage.warnings.ConstructorWarning;
+import util.meta.unittestcoverage.warnings.FieldWarning;
+import util.meta.unittestcoverage.warnings.MethodWarning;
public final class MetaInfoContainer {
private static class Data {
@@ -32,15 +32,14 @@ private Builder() {
private Data data = new Data();
- public MetaInfoContainer build() {
- return new MetaInfoContainer(data);
+ public MetaInfoContainer build() {
+ return new MetaInfoContainer(data);
}
/**
* Adds a constructor warning
*
- * @throws NullPointerException
- * if the constructor warning is null
+ * @throws NullPointerException if the constructor warning is null
*/
public Builder addConstructorWarning(ConstructorWarning constructorWarning) {
if (constructorWarning == null) {
@@ -53,8 +52,7 @@ public Builder addConstructorWarning(ConstructorWarning constructorWarning) {
/**
* Adds a method warning
*
- * @throws NullPointerException
- * if the method warning is null
+ * @throws NullPointerException if the method warning is null
*/
public Builder addMethodWarning(MethodWarning methodWarning) {
if (methodWarning == null) {
@@ -65,11 +63,10 @@ public Builder addMethodWarning(MethodWarning methodWarning) {
}
/**
- * Adds a validated UnitTestField. UnitTestField instances added here
- * should not correspond to a warning.
+ * Adds a validated UnitTestField. UnitTestField instances added here should not
+ * correspond to a warning.
*
- * @throws NullPointerException
- * if the unitTestField is null
+ * @throws NullPointerException if the unitTestField is null
*/
public Builder addUnitTestField(UnitTestField unitTestField) {
if (unitTestField == null) {
@@ -80,11 +77,10 @@ public Builder addUnitTestField(UnitTestField unitTestField) {
}
/**
- * Adds a validated UnitTestMethod. UnitTestMethod instances added here
- * should not correspond to a warning.
+ * Adds a validated UnitTestMethod. UnitTestMethod instances added here should
+ * not correspond to a warning.
*
- * @throws NullPointerException
- * if the unitTestMethod is null
+ * @throws NullPointerException if the unitTestMethod is null
*/
public Builder addUnitTestMethod(UnitTestMethod unitTestMethod) {
if (unitTestMethod == null) {
@@ -95,11 +91,10 @@ public Builder addUnitTestMethod(UnitTestMethod unitTestMethod) {
}
/**
- * Adds a validated UnitTestConstructor. UnitTestConstructor instances
- * added here should not correspond to a warning.
+ * Adds a validated UnitTestConstructor. UnitTestConstructor instances added
+ * here should not correspond to a warning.
*
- * @throws NullPointerException
- * if the unitTestConstructor is null
+ * @throws NullPointerException if the unitTestConstructor is null
*/
public Builder addUnitTestConstructor(UnitTestConstructor unitTestConstructor) {
if (unitTestConstructor == null) {
@@ -112,8 +107,7 @@ public Builder addUnitTestConstructor(UnitTestConstructor unitTestConstructor) {
/**
* Adds a field warning
*
- * @throws NullPointerException
- * if the field warning is null
+ * @throws NullPointerException if the field warning is null
*/
public Builder addFieldWarning(FieldWarning fieldWarning) {
if (fieldWarning == null) {
@@ -126,8 +120,7 @@ public Builder addFieldWarning(FieldWarning fieldWarning) {
/**
* Adds a method warning
*
- * @throws NullPointerException
- * if the general warning is null
+ * @throws NullPointerException if the general warning is null
*/
public Builder addGeneralWarning(String generalWarning) {
if (generalWarning == null) {
diff --git a/src/main/java/util/meta/unittestcoverage/MetaInfoGenerator.java b/src/main/java/util/meta/unittestcoverage/MetaInfoGenerator.java
index 2b7b6bd..48dc803 100644
--- a/src/main/java/util/meta/unittestcoverage/MetaInfoGenerator.java
+++ b/src/main/java/util/meta/unittestcoverage/MetaInfoGenerator.java
@@ -17,20 +17,18 @@
import org.junit.jupiter.api.Test;
-import util.meta.unittestcoverage.warnings.ConstructorWarning;
-import util.meta.unittestcoverage.warnings.FieldWarning;
-import util.meta.unittestcoverage.warnings.MethodWarning;
-import util.meta.unittestcoverage.warnings.WarningType;
import util.annotations.UnitTestConstructor;
import util.annotations.UnitTestField;
import util.annotations.UnitTestForCoverage;
import util.annotations.UnitTestMethod;
+import util.meta.unittestcoverage.warnings.ConstructorWarning;
+import util.meta.unittestcoverage.warnings.FieldWarning;
+import util.meta.unittestcoverage.warnings.MethodWarning;
+import util.meta.unittestcoverage.warnings.WarningType;
/**
* A utility class for generating various warnings on the coverage deficiencies
* of the the unit test suite.
- *
- *
*/
public class MetaInfoGenerator {
@@ -39,7 +37,8 @@ private static boolean isJavaFile(Path file) {
}
private static String getClassName(Path sourcePath, Path file) {
- return file.toString().substring(sourcePath.toString().length() + 1, file.toString().length() - 5).replace(File.separator, ".");
+ return file.toString().substring(sourcePath.toString().length() + 1, file.toString().length() - 5)
+ .replace(File.separator, ".");
}
/**
@@ -130,7 +129,8 @@ private void getClasses(Class> c, Set> set) {
if (Modifier.isStatic(subClass.getModifiers())) {
getClasses(subClass, set);
} else {
- warningContainerBuilder.addGeneralWarning(WarningType.NONSTATIC_SUBCLASS.getDescription() + " " + subClass);
+ warningContainerBuilder
+ .addGeneralWarning(WarningType.NONSTATIC_SUBCLASS.getDescription() + " " + subClass);
}
}
}
@@ -158,12 +158,14 @@ private void probeConstructorTest(Method testMethod, UnitTestConstructor unitTes
}
if (sourceConstructor != null) {
if (!sourceConstructors.contains(sourceConstructor)) {
- warningContainerBuilder.addMethodWarning(new MethodWarning(testMethod, WarningType.TEST_METHOD_NOT_MAPPED_TO_PROPER_SOURCE_CONSTRUCTOR));
+ warningContainerBuilder.addMethodWarning(
+ new MethodWarning(testMethod, WarningType.TEST_METHOD_NOT_MAPPED_TO_PROPER_SOURCE_CONSTRUCTOR));
}
coveredSourceConstructors.add(sourceConstructor);
warningContainerBuilder.addUnitTestConstructor(unitTestConstructor);
} else {
- warningContainerBuilder.addMethodWarning(new MethodWarning(testMethod, WarningType.SOURCE_CONSTRUCTOR_CANNOT_BE_RESOLVED));
+ warningContainerBuilder
+ .addMethodWarning(new MethodWarning(testMethod, WarningType.SOURCE_CONSTRUCTOR_CANNOT_BE_RESOLVED));
}
}
@@ -179,13 +181,15 @@ private void probeFieldTest(Method testMethod, UnitTestField unitTestField) {
}
if (sourceField != null) {
if (!sourceFields.contains(sourceField)) {
- warningContainerBuilder.addMethodWarning(new MethodWarning(testMethod, WarningType.TEST_METHOD_NOT_MAPPED_TO_PROPER_SOURCE_FIELD, sourceField.toString()));
+ warningContainerBuilder.addMethodWarning(new MethodWarning(testMethod,
+ WarningType.TEST_METHOD_NOT_MAPPED_TO_PROPER_SOURCE_FIELD, sourceField.toString()));
} else {
coveredSourceFields.add(sourceField);
warningContainerBuilder.addUnitTestField(unitTestField);
}
} else {
- warningContainerBuilder.addMethodWarning(new MethodWarning(testMethod, WarningType.SOURCE_FIELD_CANNOT_BE_RESOLVED, fieldExceptionMessage));
+ warningContainerBuilder.addMethodWarning(
+ new MethodWarning(testMethod, WarningType.SOURCE_FIELD_CANNOT_BE_RESOLVED, fieldExceptionMessage));
}
}
@@ -201,13 +205,15 @@ private void probeMethodTest(Method testMethod, UnitTestMethod unitTestMethod) {
}
if (sourceMethod != null) {
if (!sourceMethods.contains(sourceMethod)) {
- warningContainerBuilder.addMethodWarning(new MethodWarning(testMethod, WarningType.TEST_METHOD_NOT_MAPPED_TO_PROPER_SOURCE_METHOD, sourceMethod.toString()));
+ warningContainerBuilder.addMethodWarning(new MethodWarning(testMethod,
+ WarningType.TEST_METHOD_NOT_MAPPED_TO_PROPER_SOURCE_METHOD, sourceMethod.toString()));
} else {
coveredSourceMethods.add(sourceMethod);
warningContainerBuilder.addUnitTestMethod(unitTestMethod);
}
} else {
- warningContainerBuilder.addMethodWarning(new MethodWarning(testMethod, WarningType.SOURCE_METHOD_CANNOT_BE_RESOLVED, methodExceptionMessage));
+ warningContainerBuilder.addMethodWarning(new MethodWarning(testMethod,
+ WarningType.SOURCE_METHOD_CANNOT_BE_RESOLVED, methodExceptionMessage));
}
}
@@ -240,28 +246,36 @@ private void probeTestClass(Class> c) {
// ignore the method
break;
case 1:
- warningContainerBuilder.addMethodWarning(new MethodWarning(testMethod, WarningType.UNIT_FIELD_ANNOTATION_WITHOUT_TEST_ANNOTATION));
+ warningContainerBuilder.addMethodWarning(
+ new MethodWarning(testMethod, WarningType.UNIT_FIELD_ANNOTATION_WITHOUT_TEST_ANNOTATION));
break;
case 2:
- warningContainerBuilder.addMethodWarning(new MethodWarning(testMethod, WarningType.UNIT_METHOD_ANNOTATION_WITHOUT_TEST_ANNOTATION));
+ warningContainerBuilder.addMethodWarning(
+ new MethodWarning(testMethod, WarningType.UNIT_METHOD_ANNOTATION_WITHOUT_TEST_ANNOTATION));
break;
case 3:
- warningContainerBuilder.addMethodWarning(new MethodWarning(testMethod, WarningType.MULTIPLE_UNIT_ANNOTATIONS_PRESENT));
+ warningContainerBuilder
+ .addMethodWarning(new MethodWarning(testMethod, WarningType.MULTIPLE_UNIT_ANNOTATIONS_PRESENT));
break;
case 4:
- warningContainerBuilder.addMethodWarning(new MethodWarning(testMethod, WarningType.UNIT_CONSTRUCTOR_ANNOTATION_WITHOUT_TEST_ANNOTATION));
+ warningContainerBuilder.addMethodWarning(
+ new MethodWarning(testMethod, WarningType.UNIT_CONSTRUCTOR_ANNOTATION_WITHOUT_TEST_ANNOTATION));
break;
case 5:
- warningContainerBuilder.addMethodWarning(new MethodWarning(testMethod, WarningType.MULTIPLE_UNIT_ANNOTATIONS_PRESENT));
+ warningContainerBuilder
+ .addMethodWarning(new MethodWarning(testMethod, WarningType.MULTIPLE_UNIT_ANNOTATIONS_PRESENT));
break;
case 6:
- warningContainerBuilder.addMethodWarning(new MethodWarning(testMethod, WarningType.MULTIPLE_UNIT_ANNOTATIONS_PRESENT));
+ warningContainerBuilder
+ .addMethodWarning(new MethodWarning(testMethod, WarningType.MULTIPLE_UNIT_ANNOTATIONS_PRESENT));
break;
case 7:
- warningContainerBuilder.addMethodWarning(new MethodWarning(testMethod, WarningType.MULTIPLE_UNIT_ANNOTATIONS_PRESENT));
+ warningContainerBuilder
+ .addMethodWarning(new MethodWarning(testMethod, WarningType.MULTIPLE_UNIT_ANNOTATIONS_PRESENT));
break;
case 8:
- warningContainerBuilder.addMethodWarning(new MethodWarning(testMethod, WarningType.TEST_ANNOTATION_WITHOUT_UNIT_ANNOTATION));
+ warningContainerBuilder.addMethodWarning(
+ new MethodWarning(testMethod, WarningType.TEST_ANNOTATION_WITHOUT_UNIT_ANNOTATION));
break;
case 9:
probeFieldTest(testMethod, unitTestField);
@@ -270,19 +284,23 @@ private void probeTestClass(Class> c) {
probeMethodTest(testMethod, unitTestMethod);
break;
case 11:
- warningContainerBuilder.addMethodWarning(new MethodWarning(testMethod, WarningType.MULTIPLE_UNIT_ANNOTATIONS_PRESENT));
+ warningContainerBuilder
+ .addMethodWarning(new MethodWarning(testMethod, WarningType.MULTIPLE_UNIT_ANNOTATIONS_PRESENT));
break;
case 12:
probeConstructorTest(testMethod, unitTestConstructor);
break;
case 13:
- warningContainerBuilder.addMethodWarning(new MethodWarning(testMethod, WarningType.MULTIPLE_UNIT_ANNOTATIONS_PRESENT));
+ warningContainerBuilder
+ .addMethodWarning(new MethodWarning(testMethod, WarningType.MULTIPLE_UNIT_ANNOTATIONS_PRESENT));
break;
case 14:
- warningContainerBuilder.addMethodWarning(new MethodWarning(testMethod, WarningType.MULTIPLE_UNIT_ANNOTATIONS_PRESENT));
+ warningContainerBuilder
+ .addMethodWarning(new MethodWarning(testMethod, WarningType.MULTIPLE_UNIT_ANNOTATIONS_PRESENT));
break;
case 15:
- warningContainerBuilder.addMethodWarning(new MethodWarning(testMethod, WarningType.MULTIPLE_UNIT_ANNOTATIONS_PRESENT));
+ warningContainerBuilder
+ .addMethodWarning(new MethodWarning(testMethod, WarningType.MULTIPLE_UNIT_ANNOTATIONS_PRESENT));
break;
default:
@@ -308,8 +326,10 @@ private static class Data {
private Path sourcePath;
private Path testPath;
-
- public Data() {}
+
+ public Data() {
+ }
+
public Data(Data data) {
sourcePath = data.sourcePath;
testPath = data.testPath;
@@ -354,7 +374,8 @@ private MetaInfoGenerator(Data data) {
private void checkSourceMethodCoverage() {
for (Method method : sourceMethods) {
if (!coveredSourceMethods.contains(method)) {
- warningContainerBuilder.addMethodWarning(new MethodWarning(method, WarningType.SOURCE_METHOD_REQUIRES_TEST));
+ warningContainerBuilder
+ .addMethodWarning(new MethodWarning(method, WarningType.SOURCE_METHOD_REQUIRES_TEST));
}
}
}
@@ -362,7 +383,8 @@ private void checkSourceMethodCoverage() {
private void checkSourceFieldCoverage() {
for (Field field : sourceFields) {
if (!coveredSourceFields.contains(field)) {
- warningContainerBuilder.addFieldWarning(new FieldWarning(field, WarningType.SOURCE_FIELD_REQUIRES_TEST));
+ warningContainerBuilder
+ .addFieldWarning(new FieldWarning(field, WarningType.SOURCE_FIELD_REQUIRES_TEST));
}
}
}
@@ -370,7 +392,8 @@ private void checkSourceFieldCoverage() {
private void checkSourceConstructorCoverage() {
for (Constructor> constructor : sourceConstructors) {
if (!coveredSourceConstructors.contains(constructor)) {
- this.warningContainerBuilder.addConstructorWarning(new ConstructorWarning(constructor, WarningType.SOURCE_CONSTRUCTOR_REQUIRES_TEST));
+ this.warningContainerBuilder.addConstructorWarning(
+ new ConstructorWarning(constructor, WarningType.SOURCE_CONSTRUCTOR_REQUIRES_TEST));
}
}
}
diff --git a/src/main/java/util/meta/unittestcoverage/reports/IncompleteClassReport.java b/src/main/java/util/meta/unittestcoverage/reports/IncompleteClassReport.java
index 2467f12..586c5a1 100644
--- a/src/main/java/util/meta/unittestcoverage/reports/IncompleteClassReport.java
+++ b/src/main/java/util/meta/unittestcoverage/reports/IncompleteClassReport.java
@@ -22,32 +22,33 @@ public static void run(final String[] args) {
// Should point to src/test/java
final Path testPath = Paths.get(args[1]);
- MetaInfoContainer metaInfoContainer = MetaInfoGenerator.builder().setSourcePath(sourcePath).setTestPath(testPath).build().execute();
-
+ MetaInfoContainer metaInfoContainer = MetaInfoGenerator.builder().setSourcePath(sourcePath)
+ .setTestPath(testPath).build().execute();
+
displayWarningContainer(metaInfoContainer);
}
-
+
private static void displayWarningContainer(MetaInfoContainer metaInfoContainer) {
Set> incompleteClasses = new LinkedHashSet<>();
- for(FieldWarning fieldWarning : metaInfoContainer.getFieldWarnings()) {
- if(fieldWarning.getWarningType().equals(WarningType.SOURCE_FIELD_REQUIRES_TEST)) {
+ for (FieldWarning fieldWarning : metaInfoContainer.getFieldWarnings()) {
+ if (fieldWarning.getWarningType().equals(WarningType.SOURCE_FIELD_REQUIRES_TEST)) {
incompleteClasses.add(fieldWarning.getField().getDeclaringClass());
- }
+ }
}
- for(MethodWarning methodWarning : metaInfoContainer.getMethodWarnings()) {
- if(methodWarning.getWarningType().equals(WarningType.SOURCE_METHOD_REQUIRES_TEST)) {
+ for (MethodWarning methodWarning : metaInfoContainer.getMethodWarnings()) {
+ if (methodWarning.getWarningType().equals(WarningType.SOURCE_METHOD_REQUIRES_TEST)) {
incompleteClasses.add(methodWarning.getMethod().getDeclaringClass());
- }
+ }
}
- for(ConstructorWarning constructorWarning : metaInfoContainer.getConstructorWarnings()) {
- if(constructorWarning.getWarningType().equals(WarningType.SOURCE_CONSTRUCTOR_REQUIRES_TEST)) {
+ for (ConstructorWarning constructorWarning : metaInfoContainer.getConstructorWarnings()) {
+ if (constructorWarning.getWarningType().equals(WarningType.SOURCE_CONSTRUCTOR_REQUIRES_TEST)) {
incompleteClasses.add(constructorWarning.getConstructor().getDeclaringClass());
}
}
-
+
System.out.println("Incomplete classes");
- for(Class> c : incompleteClasses) {
+ for (Class> c : incompleteClasses) {
System.out.println(c.getName());
}
diff --git a/src/main/java/util/meta/unittestcoverage/reports/MetaInfoReport.java b/src/main/java/util/meta/unittestcoverage/reports/MetaInfoReport.java
index 2d9f3b5..f30b9c4 100644
--- a/src/main/java/util/meta/unittestcoverage/reports/MetaInfoReport.java
+++ b/src/main/java/util/meta/unittestcoverage/reports/MetaInfoReport.java
@@ -8,24 +8,22 @@
import java.util.List;
import java.util.Map;
+import util.annotations.UnitTag;
+import util.annotations.UnitTestConstructor;
+import util.annotations.UnitTestField;
+import util.annotations.UnitTestMethod;
import util.meta.unittestcoverage.MetaInfoContainer;
import util.meta.unittestcoverage.MetaInfoGenerator;
import util.meta.unittestcoverage.warnings.ConstructorWarning;
import util.meta.unittestcoverage.warnings.FieldWarning;
import util.meta.unittestcoverage.warnings.MethodWarning;
import util.meta.unittestcoverage.warnings.WarningType;
-import util.annotations.UnitTag;
-import util.annotations.UnitTestConstructor;
-import util.annotations.UnitTestField;
-import util.annotations.UnitTestMethod;
/**
* A script covering the details of the GCM Test Plan. It produces a console
* report that measures the completeness/status of the test classes. It does not
* measure the correctness of any test, but rather shows which tests exist and
* their status.
- *
- *
*/
public class MetaInfoReport {
@@ -36,11 +34,11 @@ public static void run(final String[] args) {
// Should point to src/test/java
final Path testPath = Paths.get(args[1]);
- MetaInfoContainer metaInfoContainer = MetaInfoGenerator .builder()//
- .setSourcePath(sourcePath)//
- .setTestPath(testPath)//
- .build()//
- .execute();//
+ MetaInfoContainer metaInfoContainer = MetaInfoGenerator.builder()//
+ .setSourcePath(sourcePath)//
+ .setTestPath(testPath)//
+ .build()//
+ .execute();//
reportWarnings(metaInfoContainer);
reportTags(metaInfoContainer);
@@ -53,11 +51,13 @@ private static String getFieldString(UnitTestField unitTestField) {
private static String getMethodString(UnitTestMethod unitTestMethod) {
- return "Method: " + unitTestMethod.target().getCanonicalName() + "." + unitTestMethod.name() + Arrays.toString(unitTestMethod.args());
+ return "Method: " + unitTestMethod.target().getCanonicalName() + "." + unitTestMethod.name()
+ + Arrays.toString(unitTestMethod.args());
}
private static String getConstructorString(UnitTestConstructor unitTestConstructor) {
- return "Constructor: " + unitTestConstructor.target().getCanonicalName() + "." + Arrays.toString(unitTestConstructor.args());
+ return "Constructor: " + unitTestConstructor.target().getCanonicalName() + "."
+ + Arrays.toString(unitTestConstructor.args());
}
private static void reportTags(MetaInfoContainer metaInfoContainer) {
@@ -113,11 +113,11 @@ private static void reportTags(MetaInfoContainer metaInfoContainer) {
List list = map.get(target);
count += list.size();
}
- System.out.println("Tag = " + unitTag+"("+count+")");
+ System.out.println("Tag = " + unitTag + "(" + count + ")");
for (Class> target : map.keySet()) {
List list = map.get(target);
for (String annotationString : list) {
- System.out.println("\t"+target.getSimpleName()+"\t" + annotationString);
+ System.out.println("\t" + target.getSimpleName() + "\t" + annotationString);
}
}
}
@@ -134,17 +134,20 @@ private static void reportWarnings(MetaInfoContainer metaInfoContainer) {
for (FieldWarning fieldWarning : metaInfoContainer.getFieldWarnings()) {
List list = warningMap.get(fieldWarning.getWarningType());
- list.add(fieldWarning.getField().getDeclaringClass().getSimpleName() + "\t" + fieldWarning.getField().toString() + " " + fieldWarning.getDetails());
+ list.add(fieldWarning.getField().getDeclaringClass().getSimpleName() + "\t"
+ + fieldWarning.getField().toString() + " " + fieldWarning.getDetails());
}
for (MethodWarning methodWarning : metaInfoContainer.getMethodWarnings()) {
List list = warningMap.get(methodWarning.getWarningType());
- list.add(methodWarning.getMethod().getDeclaringClass().getSimpleName() + "\t" + methodWarning.getMethod().toString() + " " + methodWarning.getDetails());
+ list.add(methodWarning.getMethod().getDeclaringClass().getSimpleName() + "\t"
+ + methodWarning.getMethod().toString() + " " + methodWarning.getDetails());
}
for (ConstructorWarning constructorWarning : metaInfoContainer.getConstructorWarnings()) {
List list = warningMap.get(constructorWarning.getWarningType());
- list.add(constructorWarning.getConstructor().getDeclaringClass().getSimpleName() + "\t" + constructorWarning.getConstructor().toString() + " " + constructorWarning.getDetails());
+ list.add(constructorWarning.getConstructor().getDeclaringClass().getSimpleName() + "\t"
+ + constructorWarning.getConstructor().toString() + " " + constructorWarning.getDetails());
}
int warningCount = 0;
diff --git a/src/main/java/util/meta/unittestcoverage/reports/MissingTestsReport.java b/src/main/java/util/meta/unittestcoverage/reports/MissingTestsReport.java
index 66dda10..7b4a942 100644
--- a/src/main/java/util/meta/unittestcoverage/reports/MissingTestsReport.java
+++ b/src/main/java/util/meta/unittestcoverage/reports/MissingTestsReport.java
@@ -16,18 +16,15 @@
/**
* A script that produces a console report shows missing unit tests.
- *
- *
*/
public class MissingTestsReport {
/**
- * Runs the test and print the result to console. The first argument is the
- * path reference to the source folder for the production code base. The
- * second argument is the path reference to the source folder for the unit
- * test code. The third argument is optional and is a filter string that
- * will exclude all source classes that do not contain(case insensitive) the
- * filter string.
+ * Runs the test and print the result to console. The first argument is the path
+ * reference to the source folder for the production code base. The second
+ * argument is the path reference to the source folder for the unit test code.
+ * The third argument is optional and is a filter string that will exclude all
+ * source classes that do not contain(case insensitive) the filter string.
*/
public static void run(final String[] args) {
@@ -37,14 +34,14 @@ public static void run(final String[] args) {
// Should point to src/test/java
final Path testPath = Paths.get(args[1]);
MetaInfoContainer metaInfoContainer = MetaInfoGenerator.builder()//
- .setSourcePath(sourcePath)//
- .setTestPath(testPath)//
- .build()//
- .execute();//
+ .setSourcePath(sourcePath)//
+ .setTestPath(testPath)//
+ .build()//
+ .execute();//
String classNameFilter = null;
if (args.length > 2) {
- classNameFilter = args[2];
+ classNameFilter = args[2];
}
reportWarnings(metaInfoContainer, classNameFilter);
diff --git a/src/main/java/util/meta/unittestcoverage/reports/StatusReport.java b/src/main/java/util/meta/unittestcoverage/reports/StatusReport.java
index d715e06..2329cca 100644
--- a/src/main/java/util/meta/unittestcoverage/reports/StatusReport.java
+++ b/src/main/java/util/meta/unittestcoverage/reports/StatusReport.java
@@ -19,21 +19,25 @@ public static void run(final String[] args) {
// Should point to src/test/java
final Path testPath = Paths.get(args[1]);
- MetaInfoContainer metaInfoContainer = MetaInfoGenerator.builder().setSourcePath(sourcePath).setTestPath(testPath).build().execute();
-
+ MetaInfoContainer metaInfoContainer = MetaInfoGenerator.builder().setSourcePath(sourcePath)
+ .setTestPath(testPath).build().execute();
+
displayWarningContainer(metaInfoContainer);
}
-
+
private static void displayWarningContainer(MetaInfoContainer metaInfoContainer) {
- for(FieldWarning fieldWarning : metaInfoContainer.getFieldWarnings()) {
- System.out.println(fieldWarning.getWarningType().getDescription()+"\t"+fieldWarning.getField()+"\t"+fieldWarning.getDetails());
+ for (FieldWarning fieldWarning : metaInfoContainer.getFieldWarnings()) {
+ System.out.println(fieldWarning.getWarningType().getDescription() + "\t" + fieldWarning.getField() + "\t"
+ + fieldWarning.getDetails());
}
- for(MethodWarning methodWarning : metaInfoContainer.getMethodWarnings()) {
- System.out.println(methodWarning.getWarningType().getDescription()+"\t"+methodWarning.getMethod()+"\t"+methodWarning.getDetails());
+ for (MethodWarning methodWarning : metaInfoContainer.getMethodWarnings()) {
+ System.out.println(methodWarning.getWarningType().getDescription() + "\t" + methodWarning.getMethod() + "\t"
+ + methodWarning.getDetails());
}
- for(ConstructorWarning constructorWarning : metaInfoContainer.getConstructorWarnings()) {
- System.out.println(constructorWarning.getWarningType().getDescription()+"\t"+constructorWarning.getConstructor()+"\t"+constructorWarning.getDetails());
+ for (ConstructorWarning constructorWarning : metaInfoContainer.getConstructorWarnings()) {
+ System.out.println(constructorWarning.getWarningType().getDescription() + "\t"
+ + constructorWarning.getConstructor() + "\t" + constructorWarning.getDetails());
}
}
diff --git a/src/main/java/util/meta/unittestcoverage/warnings/ConstructorWarning.java b/src/main/java/util/meta/unittestcoverage/warnings/ConstructorWarning.java
index 898afd5..8de1e9a 100644
--- a/src/main/java/util/meta/unittestcoverage/warnings/ConstructorWarning.java
+++ b/src/main/java/util/meta/unittestcoverage/warnings/ConstructorWarning.java
@@ -8,12 +8,14 @@ public final class ConstructorWarning {
private final String details;
/**
- * Constructs the constructor warning. Null details are replaced with an
- * empty details string.
+ * Constructs the constructor warning. Null details are replaced with an empty
+ * details string.
*
* @throws NullPointerException
- * if the constructor is null
- * if the warning type is null
+ *
+ * - if the constructor is null
+ * - if the warning type is null
+ *
*/
public ConstructorWarning(Constructor> constructor, WarningType warningType, String details) {
if (constructor == null) {
@@ -32,12 +34,13 @@ public ConstructorWarning(Constructor> constructor, WarningType warningType, S
}
/**
- * Constructs the constructor warning with a default empty string for
- * details.
+ * Constructs the constructor warning with a default empty string for details.
*
* @throws NullPointerException
- * if the constructor is null
- * if the warning type is null
+ *
+ * - if the constructor is null
+ * - if the warning type is null
+ *
*/
public ConstructorWarning(Constructor> constructor, WarningType warningType) {
if (constructor == null) {
diff --git a/src/main/java/util/meta/unittestcoverage/warnings/FieldWarning.java b/src/main/java/util/meta/unittestcoverage/warnings/FieldWarning.java
index 0acf607..b4b69c1 100644
--- a/src/main/java/util/meta/unittestcoverage/warnings/FieldWarning.java
+++ b/src/main/java/util/meta/unittestcoverage/warnings/FieldWarning.java
@@ -8,12 +8,14 @@ public final class FieldWarning {
private final String details;
/**
- * Constructs the field warning. Null details are replaced with an empty
- * details string.
+ * Constructs the field warning. Null details are replaced with an empty details
+ * string.
*
* @throws NullPointerException
- * if the field is null
- * if the warning type is null
+ *
+ * - if the field is null
+ * - if the warning type is null
+ *
*/
public FieldWarning(Field field, WarningType warningType, String details) {
if (field == null) {
@@ -30,13 +32,15 @@ public FieldWarning(Field field, WarningType warningType, String details) {
this.details = details;
}
}
+
/**
- * Constructs the field warning with a default empty string for
- * details.
+ * Constructs the field warning with a default empty string for details.
*
* @throws NullPointerException
- * if the field is null
- * if the warning type is null
+ *
+ * - if the field is null
+ * - if the warning type is null
+ *
*/
public FieldWarning(Field field, WarningType warningType) {
if (field == null) {
diff --git a/src/main/java/util/meta/unittestcoverage/warnings/MethodWarning.java b/src/main/java/util/meta/unittestcoverage/warnings/MethodWarning.java
index 665f3bb..a2e4d62 100644
--- a/src/main/java/util/meta/unittestcoverage/warnings/MethodWarning.java
+++ b/src/main/java/util/meta/unittestcoverage/warnings/MethodWarning.java
@@ -12,8 +12,10 @@ public final class MethodWarning {
* details string.
*
* @throws NullPointerException
- * if the method is null
- * if the warning type is null
+ *
+ * - if the method is null
+ * - if the warning type is null
+ *
*/
public MethodWarning(Method method, WarningType warningType, String details) {
if (method == null) {
@@ -30,13 +32,15 @@ public MethodWarning(Method method, WarningType warningType, String details) {
this.details = details;
}
}
+
/**
- * Constructs the method warning with a default empty string for
- * details.
+ * Constructs the method warning with a default empty string for details.
*
* @throws NullPointerException
- * if the method is null
- * if the warning type is null
+ *
+ * - if the method is null
+ * - if the warning type is null
+ *
*/
public MethodWarning(Method method, WarningType warningType) {
if (method == null) {
diff --git a/src/main/java/util/meta/unittestcoverage/warnings/WarningType.java b/src/main/java/util/meta/unittestcoverage/warnings/WarningType.java
index d764c10..3f538da 100644
--- a/src/main/java/util/meta/unittestcoverage/warnings/WarningType.java
+++ b/src/main/java/util/meta/unittestcoverage/warnings/WarningType.java
@@ -2,33 +2,39 @@
public enum WarningType {
- SOURCE_FIELD_CANNOT_BE_RESOLVED("The source field for a test method cannot be resolved since it lacks a class target"),
-
+ SOURCE_FIELD_CANNOT_BE_RESOLVED(
+ "The source field for a test method cannot be resolved since it lacks a class target"),
+
SOURCE_METHOD_CANNOT_BE_RESOLVED("The source method for a test method cannot be resolved"),
SOURCE_CONSTRUCTOR_CANNOT_BE_RESOLVED("The source constructor for a Test method cannot be resolved"),
TEST_METHOD_NOT_MAPPED_TO_PROPER_SOURCE_FIELD("Test method linked to unknown source field"),
-
+
TEST_METHOD_NOT_MAPPED_TO_PROPER_SOURCE_METHOD("Test method linked to unknown source method"),
TEST_METHOD_NOT_MAPPED_TO_PROPER_SOURCE_CONSTRUCTOR("Test method linked to unknown source contructor"),
SOURCE_FIELD_REQUIRES_TEST("Source field requires a test method but does not have one"),
-
+
SOURCE_METHOD_REQUIRES_TEST("Source method requires a test method but does not have one"),
SOURCE_CONSTRUCTOR_REQUIRES_TEST("Source constructor requires a test method but does not have one"),
- UNIT_CONSTRUCTOR_ANNOTATION_WITHOUT_TEST_ANNOTATION("Test method is marked with @UnitTestConstructor but does not have a corresponding @Test annotation"),
+ UNIT_CONSTRUCTOR_ANNOTATION_WITHOUT_TEST_ANNOTATION(
+ "Test method is marked with @UnitTestConstructor but does not have a corresponding @Test annotation"),
- UNIT_FIELD_ANNOTATION_WITHOUT_TEST_ANNOTATION("Test method is marked with @UnitTestField but does not have a corresponding @Test annotation"),
-
- UNIT_METHOD_ANNOTATION_WITHOUT_TEST_ANNOTATION("Test method is marked with @UnitTestMethod but does not have a corresponding @Test annotation"),
+ UNIT_FIELD_ANNOTATION_WITHOUT_TEST_ANNOTATION(
+ "Test method is marked with @UnitTestField but does not have a corresponding @Test annotation"),
- MULTIPLE_UNIT_ANNOTATIONS_PRESENT("Test method is marked with a combination of @UnitField, @UnitTestMethod and @UnitTestConstructor annotations"),
+ UNIT_METHOD_ANNOTATION_WITHOUT_TEST_ANNOTATION(
+ "Test method is marked with @UnitTestMethod but does not have a corresponding @Test annotation"),
- TEST_ANNOTATION_WITHOUT_UNIT_ANNOTATION("Test method is marked with @Test but does not have a corresponding @UnitTestField, @UnitTestMethod, @UnitTestConstructor or @UnitTestForCoverage"),
+ MULTIPLE_UNIT_ANNOTATIONS_PRESENT(
+ "Test method is marked with a combination of @UnitField, @UnitTestMethod and @UnitTestConstructor annotations"),
+
+ TEST_ANNOTATION_WITHOUT_UNIT_ANNOTATION(
+ "Test method is marked with @Test but does not have a corresponding @UnitTestField, @UnitTestMethod, @UnitTestConstructor or @UnitTestForCoverage"),
NONSTATIC_SUBCLASS("Non-static public subclasses are not testable"),
@@ -39,7 +45,7 @@ public enum WarningType {
private WarningType(String description) {
this.description = description;
}
-
+
public String getDescription() {
return description;
}
diff --git a/src/main/java/util/path/ArrayPathSolver.java b/src/main/java/util/path/ArrayPathSolver.java
index 06537ce..6f9440b 100644
--- a/src/main/java/util/path/ArrayPathSolver.java
+++ b/src/main/java/util/path/ArrayPathSolver.java
@@ -14,8 +14,6 @@
/**
* Manages shortest path solutions for a given graph with reasonable efficiency
* using arrays of previous path solutions and their sub-paths.
- *
- *
*/
public final class ArrayPathSolver implements PathSolver {
@@ -26,7 +24,8 @@ public final class ArrayPathSolver implements PathSolver {
private TravelCostEvaluator travelCostEvaluator;
@SuppressWarnings("unchecked")
- public ArrayPathSolver(Graph graph, EdgeCostEvaluator edgeCostEvaluator, TravelCostEvaluator travelCostEvaluator) {
+ public ArrayPathSolver(Graph graph, EdgeCostEvaluator edgeCostEvaluator,
+ TravelCostEvaluator travelCostEvaluator) {
this.graph = graph;
this.edgeCostEvaluator = edgeCostEvaluator;
this.travelCostEvaluator = travelCostEvaluator;
diff --git a/src/main/java/util/path/MapPathSolver.java b/src/main/java/util/path/MapPathSolver.java
index afedd9a..6b944e1 100644
--- a/src/main/java/util/path/MapPathSolver.java
+++ b/src/main/java/util/path/MapPathSolver.java
@@ -14,8 +14,6 @@
/**
* Manages shortest path solutions for a given graph with reasonable efficiency
* using maps of previous path solutions and their sub-paths.
- *
- *
*/
public class MapPathSolver implements PathSolver {
@@ -41,17 +39,19 @@ private static class SubPath {
private TravelCostEvaluator travelCostEvaluator;
/**
- * Create a path solver for the given graph using the edge cost evaluator
- * and travel cost evaluator
+ * Create a path solver for the given graph using the edge cost evaluator and
+ * travel cost evaluator
*
* @throws NullPointerException
- * if the graph is null
- * if the edge cost evaluator is null
- * if the travel cost evaluator is null
- *
- *
+ *
+ * - if the graph is null
+ * - if the edge cost evaluator is null
+ * - if the travel cost evaluator is
+ * null
+ *
*/
- public MapPathSolver(Graph graph, EdgeCostEvaluator edgeCostEvaluator, TravelCostEvaluator travelCostEvaluator) {
+ public MapPathSolver(Graph graph, EdgeCostEvaluator edgeCostEvaluator,
+ TravelCostEvaluator travelCostEvaluator) {
if (graph == null) {
throw new NullPointerException("graph is null");
}
@@ -85,7 +85,8 @@ public Optional> getPath(N originNode, N destinationNode) {
}
result = subPath.solvedPath;
} else {
- Optional> optional = Paths.getPath(graph, originNode, destinationNode, edgeCostEvaluator, travelCostEvaluator);
+ Optional> optional = Paths.getPath(graph, originNode, destinationNode, edgeCostEvaluator,
+ travelCostEvaluator);
if (!optional.isPresent()) {
return Optional.empty();
}
diff --git a/src/main/java/util/path/Path.java b/src/main/java/util/path/Path.java
index 146ad1a..3688c24 100644
--- a/src/main/java/util/path/Path.java
+++ b/src/main/java/util/path/Path.java
@@ -10,8 +10,6 @@
* any breaks. A path may be crossing or cyclic, with the getEdges() list
* containing repeated edges. A path may be a degenerate, having no edges.
* Degenerate paths are the expected results for paths that do not exist.
- *
- *
*/
@Immutable
public final class Path {
@@ -35,8 +33,8 @@ public Builder addEdge(T edge) {
return this;
}
- public Path build() {
- return new Path<>(edges);
+ public Path build() {
+ return new Path<>(edges);
}
}
@@ -47,9 +45,8 @@ private Path(List edges) {
private final List edges = new ArrayList<>();
/**
- * Returns a list over the edges in the path walk. Note that the path may
- * cross itself (revisit nodes) and even repeat edges.
- *
+ * Returns a list over the edges in the path walk. Note that the path may cross
+ * itself (revisit nodes) and even repeat edges.
*/
public List getEdges() {
return new ArrayList<>(edges);
@@ -57,10 +54,8 @@ public List getEdges() {
/**
* Returns the number of edges in the path walk through the graph. Note that
- * this is NOT necessarily the same value as returned by the edgeCount()
- * method, but rather returns a value that may be higher due to revisited
- * edges.
- *
+ * this is NOT necessarily the same value as returned by the edgeCount() method,
+ * but rather returns a value that may be higher due to revisited edges.
*/
public int length() {
diff --git a/src/main/java/util/path/PathSolver.java b/src/main/java/util/path/PathSolver.java
index a0d4bd9..bab218d 100644
--- a/src/main/java/util/path/PathSolver.java
+++ b/src/main/java/util/path/PathSolver.java
@@ -4,9 +4,6 @@
/**
* Interface for path solvers that retain previously solved paths.
- *
- *
- *
*/
public interface PathSolver {
diff --git a/src/main/java/util/path/Paths.java b/src/main/java/util/path/Paths.java
index 1a37aa4..3044dcd 100644
--- a/src/main/java/util/path/Paths.java
+++ b/src/main/java/util/path/Paths.java
@@ -12,34 +12,25 @@
import util.path.Path.Builder;
/**
- *
* Solves a shortest path through a graph from an origin node to a destination
* node.The solver uses two optional, auxiliary, client supplied objects: 1) an
* EdgeCostEvaluator which returns the cost of an edge and 2) a
* TravelCostEvaluator which determines the shortest possible cost across the
- * graph from one node to another.
- *
- * The EdgeCostEvaluator should always return a non-negative value and should
- * return a stable value over the life-span of this utility. If the
- * EdgeCostEvaluator is null, the cost of an edge is set arbitrarily to 1.
- *
- * The TravelCostEvaluator is also optional and exists to give the solver
- * insight into long distance costs. It should return a stable non-negative
- * value.
- *
- * A typical TravelCostEvaluator example would be for nodes in a graph that
- * represent physical positions. The TravelCostEvaluator could return the
- * straight-line minimum distance between nodes. Note that the nodes do not have
- * to share an edge nor even be connected in the graph. By supplying a
- * TravelCostEvaluator, the client can greatly improve this solver's performance
- * in large networks where nodes represent positions in space. Essentially, the
- * TravelCostEvaluator allows the algorithm to expand its exploration of the
- * graph in an ellipse whose major axis is aligned to the origin and
- * destination, rather than doing a expanding sphere search.
- *
- * If a path cannot be found then a degenerate, node-less path is returned.
- *
- *
+ * graph from one node to another. The EdgeCostEvaluator should always return a
+ * non-negative value and should return a stable value over the life-span of
+ * this utility. If the EdgeCostEvaluator is null, the cost of an edge is set
+ * arbitrarily to 1. The TravelCostEvaluator is also optional and exists to give
+ * the solver insight into long distance costs. It should return a stable
+ * non-negative value. A typical TravelCostEvaluator example would be for nodes
+ * in a graph that represent physical positions. The TravelCostEvaluator could
+ * return the straight-line minimum distance between nodes. Note that the nodes
+ * do not have to share an edge nor even be connected in the graph. By supplying
+ * a TravelCostEvaluator, the client can greatly improve this solver's
+ * performance in large networks where nodes represent positions in space.
+ * Essentially, the TravelCostEvaluator allows the algorithm to expand its
+ * exploration of the graph in an ellipse whose major axis is aligned to the
+ * origin and destination, rather than doing a expanding sphere search. If a
+ * path cannot be found then a degenerate, node-less path is returned.
*/
public final class Paths {
@@ -96,14 +87,17 @@ private Paths() {
* Returns an Optional containing a Path of E if such path could be found.
*
* @throws NullPointerException
- * if the graph is null
- * if the origin node is null
- * if the destination node null
- * if the edge cost evaluator is null
- * if the travel cost evaluator is null
- *
+ *
+ * - if the graph is null
+ * - if the origin node is null
+ * - if the destination node null
+ * - if the edge cost evaluator is null
+ * - if the travel cost evaluator is
+ * null
+ *
*/
- public static Optional> getPath(Graph graph, N originNode, N destinationNode, EdgeCostEvaluator edgeCostEvaluator, TravelCostEvaluator travelCostEvaluator) {
+ public static Optional> getPath(Graph graph, N originNode, N destinationNode,
+ EdgeCostEvaluator edgeCostEvaluator, TravelCostEvaluator travelCostEvaluator) {
if (graph == null) {
throw new NullPointerException("graph is null");
@@ -139,7 +133,8 @@ public static Optional> getPath(Graph graph, N originNode,
final Map> map = new HashMap<>();
PriorityQueue> priorityQueue = new PriorityQueue<>();
- CostedNode originNodeWrapper = new CostedNode<>(originNode, travelCostEvaluator.getMinimumCost(originNode, destinationNode));
+ CostedNode originNodeWrapper = new CostedNode<>(originNode,
+ travelCostEvaluator.getMinimumCost(originNode, destinationNode));
map.put(originNode, originNodeWrapper);
// Note that the first node placed on the queue will be unvisited and
@@ -178,7 +173,8 @@ public static Optional> getPath(Graph graph, N originNode,
}
if (targetNodeWrapper == null) {
- targetNodeWrapper = new CostedNode<>(targetNode, travelCostEvaluator.getMinimumCost(targetNode, destinationNode));
+ targetNodeWrapper = new CostedNode<>(targetNode,
+ travelCostEvaluator.getMinimumCost(targetNode, destinationNode));
targetNodeWrapper.cost = edgeCost;
targetNodeWrapper.edge = edge;
map.put(targetNode, targetNodeWrapper);
diff --git a/src/main/java/util/random/RandomGeneratorProvider.java b/src/main/java/util/random/RandomGeneratorProvider.java
index 3fb2486..c1662d4 100644
--- a/src/main/java/util/random/RandomGeneratorProvider.java
+++ b/src/main/java/util/random/RandomGeneratorProvider.java
@@ -4,7 +4,7 @@
import org.apache.commons.math3.random.Well44497b;
public class RandomGeneratorProvider {
-
+
private RandomGeneratorProvider() {
}
diff --git a/src/main/java/util/spherical/Chirality.java b/src/main/java/util/spherical/Chirality.java
index ba33b8f..7e54bbb 100644
--- a/src/main/java/util/spherical/Chirality.java
+++ b/src/main/java/util/spherical/Chirality.java
@@ -3,8 +3,6 @@
/**
* Enumeration representing the chirality of triangle vertex ordering on the
* surface of a sphere.
- *
- *
*/
public enum Chirality {
RIGHT_HANDED, // counter clockwise
diff --git a/src/main/java/util/spherical/MalformedSphericalArcException.java b/src/main/java/util/spherical/MalformedSphericalArcException.java
index 0f16660..a709cd9 100644
--- a/src/main/java/util/spherical/MalformedSphericalArcException.java
+++ b/src/main/java/util/spherical/MalformedSphericalArcException.java
@@ -3,7 +3,6 @@
/**
* A RuntimeException thrown when a {@link SphericalArc} cannot be formed due to
* a null input or by two vertices that are too close together.
- *
*/
public class MalformedSphericalArcException extends RuntimeException {
diff --git a/src/main/java/util/spherical/MalformedSphericalPointException.java b/src/main/java/util/spherical/MalformedSphericalPointException.java
index cec4081..4ce164e 100644
--- a/src/main/java/util/spherical/MalformedSphericalPointException.java
+++ b/src/main/java/util/spherical/MalformedSphericalPointException.java
@@ -3,7 +3,6 @@
/**
* A RuntimeException thrown when a {@link SphericalPoint} cannot be formed due
* to a non-normalizable input.
- *
*/
public class MalformedSphericalPointException extends RuntimeException {
@@ -12,7 +11,7 @@ public class MalformedSphericalPointException extends RuntimeException {
public MalformedSphericalPointException() {
super();
}
-
+
public MalformedSphericalPointException(String message) {
super(message);
}
diff --git a/src/main/java/util/spherical/MalformedSphericalTriangleException.java b/src/main/java/util/spherical/MalformedSphericalTriangleException.java
index 8ab9775..9ccca3d 100644
--- a/src/main/java/util/spherical/MalformedSphericalTriangleException.java
+++ b/src/main/java/util/spherical/MalformedSphericalTriangleException.java
@@ -2,7 +2,6 @@
/**
* A RuntimeException thrown when a {@link SphericalTriangle} cannot be formed.
- *
*/
public class MalformedSphericalTriangleException extends RuntimeException {
diff --git a/src/main/java/util/spherical/SphericalArc.java b/src/main/java/util/spherical/SphericalArc.java
index 1b6ede3..8818e00 100644
--- a/src/main/java/util/spherical/SphericalArc.java
+++ b/src/main/java/util/spherical/SphericalArc.java
@@ -11,8 +11,6 @@
/**
* Represents an immutable great arc segment on the unit sphere defined by two
* distinct SphericalPoints. Instances are created via included builder class.
- *
- *
*/
@Immutable
@@ -21,12 +19,11 @@ public class SphericalArc {
/**
* Hidden constructor
*
- * @throws MalformedSphericalArcException
- * if the two {@link SphericalPoint} values are too close
- * together to properly form a normal vector.
- *
- * @throws NullPointerException
- * if either {@link SphericalPoint} is null
+ * @throws MalformedSphericalArcException if the two {@link SphericalPoint}
+ * values are too close together to
+ * properly form a normal vector.
+ * @throws NullPointerException if either {@link SphericalPoint} is
+ * null
*/
public SphericalArc(SphericalPoint sphericalPoint1, SphericalPoint sphericalPoint2) {
@@ -58,9 +55,7 @@ public SphericalArc(SphericalPoint sphericalPoint1, SphericalPoint sphericalPoin
* Returns the {@link Chirality} of a SphericalPoint relative to this
* SphericalArc in the natural order of its SphericalPoints.
*
- * @throws NullPointerException
- * if the given {@link SphericalPoint} is null
- *
+ * @throws NullPointerException if the given {@link SphericalPoint} is null
* @param sphericalPoint
* @return
*/
@@ -82,9 +77,7 @@ public Chirality getChirality(SphericalPoint sphericalPoint) {
* Returns true if and only if this SphericalArc intersects the given
* SphericalArc at a point
*
- * @throws NullPointerException
- * if the given arc is null
- *
+ * @throws NullPointerException if the given arc is null
* @param arc
* @return
*/
@@ -99,11 +92,8 @@ public boolean intersectsArc(SphericalArc arc) {
/**
* Returns the SphericalPoint associated with the index
*
- * @param index
- * Values may be 0 or 1
- *
- * @throws IndexOutOfBoundsException
- * if any other index is used
+ * @param index Values may be 0 or 1
+ * @throws IndexOutOfBoundsException if any other index is used
*/
public SphericalPoint getSphericalPoint(int index) {
return sphericalPoints[index];
@@ -135,17 +125,16 @@ public SphericalPoint getInterSection(SphericalArc arc) {
Vector3D b = sphericalPoints[1].getPosition();
/*
- * The normal vector to each arc's plane will be perpendicular to the
- * solution, thus the solution is the cross product of these two
- * normals, or their reverse.
+ * The normal vector to each arc's plane will be perpendicular to the solution,
+ * thus the solution is the cross product of these two normals, or their
+ * reverse.
*/
Vector3D solution = perp.cross(arc.perp);
/*
- * Does the solution lie on the first arc? It will lie on the arc's
- * plane. Thus, if we can show that the intersection lies between the
- * arc's end points then the solution is correct. Otherwise, the
- * solution must be reversed.
+ * Does the solution lie on the first arc? It will lie on the arc's plane. Thus,
+ * if we can show that the intersection lies between the arc's end points then
+ * the solution is correct. Otherwise, the solution must be reversed.
*
*/
boolean containedOnArc = a.cross(solution).dot(perp) >= 0 && b.cross(solution).dot(perp) <= 0;
@@ -159,16 +148,14 @@ public SphericalPoint getInterSection(SphericalArc arc) {
/**
* Returns the distance from the given {@linkplain SphericalPoint} to this
*
- * @throws NullPointerException
- * if the given {@link SphericalPoint} is null
+ * @throws NullPointerException if the given {@link SphericalPoint} is null
*/
public double distanceTo(SphericalPoint sphericalPoint) {
Vector3D a = sphericalPoints[0].getPosition();
Vector3D b = sphericalPoints[1].getPosition();
/*
- * Create a normal unit vector to the plane containing the two end
- * points --
+ * Create a normal unit vector to the plane containing the two end points --
*/
MutableVector3D p = new MutableVector3D(a);
p.cross(b);
@@ -190,8 +177,8 @@ public double distanceTo(SphericalPoint sphericalPoint) {
double angle = q.angle(qOnPlane);
/*
- * If q lies between the end points, then return angle, otherwise return
- * the angle between q and the closest end point.
+ * If q lies between the end points, then return angle, otherwise return the
+ * angle between q and the closest end point.
*/
MutableVector3D v = new MutableVector3D(qOnPlane);
@@ -203,8 +190,8 @@ public double distanceTo(SphericalPoint sphericalPoint) {
double bDot = v.dot(p);// positive if clockwise from b
if (bDot >= 0) {
/*
- * qOnPlane, from the perspective of the normal, is CCW from A
- * and CW from B, so it lies between them
+ * qOnPlane, from the perspective of the normal, is CCW from A and CW from B, so
+ * it lies between them
*/
return angle;
}
diff --git a/src/main/java/util/spherical/SphericalPoint.java b/src/main/java/util/spherical/SphericalPoint.java
index b016d81..2fb6b30 100644
--- a/src/main/java/util/spherical/SphericalPoint.java
+++ b/src/main/java/util/spherical/SphericalPoint.java
@@ -7,8 +7,6 @@
/**
* Represents an immutable point on the unit sphere. Instances are created via
* included builder class.
- *
- *
*/
@Immutable
public final class SphericalPoint {
@@ -16,11 +14,10 @@ public final class SphericalPoint {
/**
* Creates a new {@link SphericalPoint} from the given {@link Vector3D}
*
- * @throws MalformedSphericalPointException
- * if the given {@link Vector3D} is not normalizable
- * @throws NullPointerException
- * if the given {@link Vector3D} is null
- *
+ * @throws MalformedSphericalPointException if the given {@link Vector3D} is not
+ * normalizable
+ * @throws NullPointerException if the given {@link Vector3D} is
+ * null
*/
public SphericalPoint(Vector3D v) {
@@ -33,10 +30,10 @@ public SphericalPoint(Vector3D v) {
}
/**
- * Creates a new {@link SphericalPoint} from the given {@link muVector3D}
+ * Creates a new {@link SphericalPoint} from the given {@link MutableVector3D}
*
- * @throws MalformedSphericalPointException
- * if the given {@link Vector3D} is not normalizable
+ * @throws MalformedSphericalPointException if the given {@link Vector3D} is not
+ * normalizable
*/
public SphericalPoint(MutableVector3D v) {
position = new Vector3D(v).normalize();
diff --git a/src/main/java/util/spherical/SphericalPolygon.java b/src/main/java/util/spherical/SphericalPolygon.java
index e8d79de..d2810df 100644
--- a/src/main/java/util/spherical/SphericalPolygon.java
+++ b/src/main/java/util/spherical/SphericalPolygon.java
@@ -12,8 +12,6 @@
/**
* Represents an immutable, non-crossing polygon on the surface of a unit
* sphere.
- *
- *
*/
@Immutable
@@ -32,15 +30,13 @@ private static class Data {
/**
* Builder class for {@link SphericalPolygon}
- *
- *
*/
public static class Builder {
/**
- * Adds a {@link SphericalPoint} to the {@link SphericalPolygon}. Order
- * of addition dictates the order of the vertices of the polygon.
- * Winding order may be either left or right handed.
+ * Adds a {@link SphericalPoint} to the {@link SphericalPolygon}. Order of
+ * addition dictates the order of the vertices of the polygon. Winding order may
+ * be either left or right handed.
*/
public Builder addSphericalPoint(SphericalPoint sphericalPoint) {
data.sphericalPoints.add(sphericalPoint);
@@ -48,8 +44,8 @@ public Builder addSphericalPoint(SphericalPoint sphericalPoint) {
}
/**
- * Sets the useSearchTree policy for the {@link SphericalPolygon}.
- * Default is true;
+ * Sets the useSearchTree policy for the {@link SphericalPolygon}. Default is
+ * true;
*/
public Builder setUseSearchTree(boolean useSearchTree) {
data.useSearchTree = useSearchTree;
@@ -66,18 +62,23 @@ private Builder() {
}
/**
- * Builds a {@link SphericalPolygon} from the supplied
- * {@link SphericalPoint} values.
+ * Builds a {@link SphericalPolygon} from the supplied {@link SphericalPoint}
+ * values.
*
* @throws MalformedSphericalPolygonException
- *
- * if any of the {@link SphericalPoint} values are null
- * if there are fewer than three {@link SphericalPoint}
- * values
- * if the {@link SphericalPoint} values form a crossing
- * polygon
- * if the polygon is ambiguous
- *
+ *
+ * - if any of the
+ * {@link SphericalPoint} values
+ * are null
+ * - if there are fewer than
+ * three {@link SphericalPoint}
+ * values
+ * - if the
+ * {@link SphericalPoint} values
+ * form a crossing polygon
+ * - if the polygon is
+ * ambiguous
+ *
*/
public SphericalPolygon build() {
return new SphericalPolygon(data);
@@ -114,8 +115,8 @@ public List getSphericalTriangles() {
private final VolumetricDimensionTree searchTree;
/**
- * Returns the {@link Chirality} of this {@link SphericalPolygon} relative
- * to the natural order of its SphericalPoints.
+ * Returns the {@link Chirality} of this {@link SphericalPolygon} relative to
+ * the natural order of its SphericalPoints.
*/
public Chirality getChirality() {
return chirality;
@@ -133,7 +134,8 @@ public boolean containsPosition(SphericalPoint sphericalPoint) {
}
}
} else {
- List membersInSphere = searchTree.getMembersInSphere(0, sphericalPoint.getPosition().toArray());
+ List membersInSphere = searchTree.getMembersInSphere(0,
+ sphericalPoint.getPosition().toArray());
for (SphericalTriangle sphericalTriangle : membersInSphere) {
if (sphericalTriangle.contains(sphericalPoint)) {
return true;
@@ -145,8 +147,8 @@ public boolean containsPosition(SphericalPoint sphericalPoint) {
}
/**
- * Returns true if this {@link SphericalPolygon} overlaps with any part of
- * the given {@link SphericalPolygon}
+ * Returns true if this {@link SphericalPolygon} overlaps with any part of the
+ * given {@link SphericalPolygon}
*/
public boolean intersects(SphericalPolygon sphericalPolygon) {
for (SphericalTriangle triangle1 : sphericalTriangles) {
@@ -169,8 +171,8 @@ public List getSphericalPoints() {
}
/**
- * Returns true if this {@link SphericalPolygon} overlaps with any part of
- * the given {@link SphericalArc}
+ * Returns true if this {@link SphericalPolygon} overlaps with any part of the
+ * given {@link SphericalArc}
*/
public boolean intersects(SphericalArc sphericalArc) {
for (SphericalTriangle triangle : sphericalTriangles) {
@@ -182,8 +184,8 @@ public boolean intersects(SphericalArc sphericalArc) {
}
/**
- * Returns true if this {@link SphericalPolygon} overlaps with any part of
- * the given {@link SphericalTriangle}
+ * Returns true if this {@link SphericalPolygon} overlaps with any part of the
+ * given {@link SphericalTriangle}
*/
public boolean intersects(SphericalTriangle sphericalTriangle) {
for (SphericalTriangle triangle : sphericalTriangles) {
@@ -196,7 +198,8 @@ public boolean intersects(SphericalTriangle sphericalTriangle) {
private static SphericalTriangle popEar(int index, List points, Chirality chirality) {
// form the triangle from the index
- SphericalTriangle t = new SphericalTriangle(points.get((index + -1 + points.size()) % points.size()), points.get(index), points.get((index + 1) % points.size()));
+ SphericalTriangle t = new SphericalTriangle(points.get((index + -1 + points.size()) % points.size()),
+ points.get(index), points.get((index + 1) % points.size()));
/*
* if the triangle does not agree with chirality then we are done
@@ -205,8 +208,8 @@ private static SphericalTriangle popEar(int index, List points,
return null;
}
/*
- * if the triangle's new side crosses any of the non-attached legs, then
- * we are done
+ * if the triangle's new side crosses any of the non-attached legs, then we are
+ * done
*/
// here are the indices of the attached legs. We will not attempt to
@@ -244,10 +247,10 @@ private static SphericalTriangle popEar(int index, List points,
private static List triangulate(List sphericalPoints, Chirality chirality) {
/*
- * We will attempt to remove nodes from the list one by one by popping
- * an ear off the polygon -- that is, we will remove a triangle and get
- * an increasingly simple polygon. If all goes well, we will be left
- * with a degenerate polygon (one that has no nodes)
+ * We will attempt to remove nodes from the list one by one by popping an ear
+ * off the polygon -- that is, we will remove a triangle and get an increasingly
+ * simple polygon. If all goes well, we will be left with a degenerate polygon
+ * (one that has no nodes)
*
*/
@@ -255,10 +258,10 @@ private static List triangulate(List spherica
List points = new ArrayList<>(sphericalPoints);
/*
- * Roll around the polygon, trying to pop off a node and its
- * corresponding triangle. Popping an ear is successful only when the
- * triangle so formed is fully inside the polygon. If we fail
- * repeatedly, we stop once we have come full circle.
+ * Roll around the polygon, trying to pop off a node and its corresponding
+ * triangle. Popping an ear is successful only when the triangle so formed is
+ * fully inside the polygon. If we fail repeatedly, we stop once we have come
+ * full circle.
*
*/
@@ -306,7 +309,8 @@ private SphericalPolygon(Data data) {
centroid = new SphericalPoint(v);
if (!centroid.getPosition().isFinite()) {
- throw new MalformedSphericalPolygonException("the spherical polygon formed from the given spherical points is ambiguous");
+ throw new MalformedSphericalPolygonException(
+ "the spherical polygon formed from the given spherical points is ambiguous");
}
double r = Double.NEGATIVE_INFINITY;
@@ -338,10 +342,10 @@ private SphericalPolygon(Data data) {
if (sphericalTriangles.size() > SEARCH_TREE_THRESHOLD && data.useSearchTree) {
searchTree = VolumetricDimensionTree.builder()//
- .setFastRemovals(true)//
- .setLowerBounds(new double[] { -1, -1, -1 })//
- .setUpperBounds(new double[] { 1, 1, 1 })//
- .build();//
+ .setFastRemovals(true)//
+ .setLowerBounds(new double[] { -1, -1, -1 })//
+ .setUpperBounds(new double[] { 1, 1, 1 })//
+ .build();//
for (SphericalTriangle sphericalTriangle : sphericalTriangles) {
double[] triangleCenter = sphericalTriangle.getCentroid().toArray();
@@ -363,9 +367,8 @@ public double getRadius() {
/**
* Returns the center of this {@link SphericalPolygon}. All vertices of this
- * polygon lie with the radius around the centroid. The centroid is
- * calculated as the numerical average of the points that compose the
- * polygon.
+ * polygon lie with the radius around the centroid. The centroid is calculated
+ * as the numerical average of the points that compose the polygon.
*/
public SphericalPoint getCentroid() {
return centroid;
diff --git a/src/main/java/util/spherical/SphericalTriangle.java b/src/main/java/util/spherical/SphericalTriangle.java
index c9789e5..a0ff5aa 100644
--- a/src/main/java/util/spherical/SphericalTriangle.java
+++ b/src/main/java/util/spherical/SphericalTriangle.java
@@ -8,16 +8,14 @@
/**
* Represents an immutable triangle on the unit sphere.
- *
- *
*/
@Immutable
public class SphericalTriangle {
/**
- * Returns the shortest distance from the point to this triangle. Points on
- * the inside of the triangle will return 0.
+ * Returns the shortest distance from the point to this triangle. Points on the
+ * inside of the triangle will return 0.
*/
public double distanceTo(SphericalPoint sphericalPoint) {
@@ -46,15 +44,13 @@ private static double getTangentialAngle(Vector3D v1, Vector3D v2, Vector3D v3)
}
/**
- * Constructs a {@link SphericalTriangle} from the given
- * {@link SphericalPoint} values.
- *
- * @throws MalformedSphericalTriangleException
- * if a spherical point is null
- *
+ * Constructs a {@link SphericalTriangle} from the given {@link SphericalPoint}
+ * values.
*
+ * @throws MalformedSphericalTriangleException if a spherical point is null
*/
- public SphericalTriangle(SphericalPoint sphericalPoint1, SphericalPoint sphericalPoint2, SphericalPoint sphericalPoint3) {
+ public SphericalTriangle(SphericalPoint sphericalPoint1, SphericalPoint sphericalPoint2,
+ SphericalPoint sphericalPoint3) {
if (sphericalPoint1 == null) {
throw new MalformedSphericalTriangleException("null spherical point");
@@ -151,32 +147,31 @@ public double getArea() {
}
/**
- * Returns the centroid point (a unit vector) of this
- * {@link SphericalTriangle}
+ * Returns the centroid point (a unit vector) of this {@link SphericalTriangle}
*/
public Vector3D getCentroid() {
return centroid;
}
/**
- * Returns the radius of this {@link SphericalTriangle}. The radius is
- * defined as the distance to the centroid from the vertices.
+ * Returns the radius of this {@link SphericalTriangle}. The radius is defined
+ * as the distance to the centroid from the vertices.
*/
public double getRadius() {
return radius;
}
/**
- * Returns the {@link Chirality} of this {@link SphericalTriangle} relative
- * to the natural order of its SphericalPoints.
+ * Returns the {@link Chirality} of this {@link SphericalTriangle} relative to
+ * the natural order of its SphericalPoints.
*/
public Chirality getChirality() {
return chirality;
}
/**
- * Returns true if this {@link SphericalTriangle} overlaps with any part of
- * the given {@link SphericalTriangle}
+ * Returns true if this {@link SphericalTriangle} overlaps with any part of the
+ * given {@link SphericalTriangle}
*/
public boolean intersects(SphericalTriangle sphericalTriangle) {
for (int i = 0; i < 3; i++) {
@@ -198,32 +193,25 @@ public boolean intersects(SphericalTriangle sphericalTriangle) {
}
/**
- * Returns the {@link SphericalArc} that corresponds to the index. These
- * arcs are formed from the original {@link SphericalPoint} members that
- * define this {@link SphericalTriangle}. Arc[0] is formed(in order) from
- * Point[0] and Point[1]. Arc[1] is formed(in order) from Point[1] and
- * Point[2]. Arc[2] is formed(in order) from Point[2] and Point[0].
- *
- * @param index
- * Values may be 0, 1 or 2
+ * Returns the {@link SphericalArc} that corresponds to the index. These arcs
+ * are formed from the original {@link SphericalPoint} members that define this
+ * {@link SphericalTriangle}. Arc[0] is formed(in order) from Point[0] and
+ * Point[1]. Arc[1] is formed(in order) from Point[1] and Point[2]. Arc[2] is
+ * formed(in order) from Point[2] and Point[0].
*
- * @throws IndexOutOfBoundsException
- * if any other index is used
+ * @param index Values may be 0, 1 or 2
+ * @throws IndexOutOfBoundsException if any other index is used
*/
public SphericalArc getSphericalArc(int index) {
return sphericalArcs[index];
}
/**
- * Returns the {@link SphericalPoint} that corresponds to the index and was
- * used to construct this {@link SphericalTriangle}
- *
- * @param index
- * Values may be 0, 1 or 2
- *
- * @throws IndexOutOfBoundsException
- * if any other index is used
+ * Returns the {@link SphericalPoint} that corresponds to the index and was used
+ * to construct this {@link SphericalTriangle}
*
+ * @param index Values may be 0, 1 or 2
+ * @throws IndexOutOfBoundsException if any other index is used
*/
public SphericalPoint getSphericalPoint(int index) {
return sphericalPoints[index];
diff --git a/src/main/java/util/stats/BinContainer.java b/src/main/java/util/stats/BinContainer.java
index 25b09be..acff2bc 100644
--- a/src/main/java/util/stats/BinContainer.java
+++ b/src/main/java/util/stats/BinContainer.java
@@ -10,7 +10,6 @@ public final class BinContainer {
/**
* Constructs the {@link BinContainer} from the given binSize.
- *
*/
private BinContainer(MutableBinContainer mutableBinContainer) {
this.lowIndex = mutableBinContainer.lowIndex;
@@ -34,8 +33,7 @@ private BinContainer(MutableBinContainer mutableBinContainer) {
/**
* Creates a builder for a bin container
*
- * @throws IllegalArgumentException
- * if the bin size was non-positive
+ * @throws IllegalArgumentException if the bin size was non-positive
*/
public static Builder builder(double binSize) {
return new Builder(binSize);
@@ -50,26 +48,24 @@ public static Builder builder(double binSize) {
private final int highIndex;
public static class Builder {
-
+
private MutableBinContainer mutableBinContainer;
- private Builder(double binSize) {
+ private Builder(double binSize) {
mutableBinContainer = new MutableBinContainer(binSize);
}
/**
* Builds the {@link BinContainer} from the contributed values.
- *
*/
- public BinContainer build() {
- return new BinContainer(mutableBinContainer);
+ public BinContainer build() {
+ return new BinContainer(mutableBinContainer);
}
/**
* Adds the given value by the given number of times.
*
- * @throws IllegalArgumentException
- * if the count is negative
+ * @throws IllegalArgumentException if the count is negative
*/
public Builder addValue(double value, int count) {
mutableBinContainer.addValue(value, count);
@@ -79,12 +75,9 @@ public Builder addValue(double value, int count) {
}
/**
- * Represents a half open interval [lowerBound,upperBound) that contains a
- * count of values.
- *
- *
+ * Represents a half open interval [lowerBound,upperBound) that contains a count
+ * of values.
*/
-
public final static class Bin {
private final double lowerBound;
private final double upperBound;
@@ -152,8 +145,11 @@ public double getUpperBound() {
* Constructs the Bin
*
* @throws IllegalArgumentException
- * if the lower bound exceeds the upper bound
- * if the count is negative
+ *
+ * - if the lower bound exceeds the upper
+ * bound
+ * - if the count is negative
+ *
*/
public Bin(double lowerBound, double upperBound, int count) {
if (lowerBound > upperBound) {
@@ -220,8 +216,7 @@ private MutableBinContainer(double binSize) {
/**
* Adds a value to the container
*
- * @throws IllegalArgumentException
- * if the count is negative
+ * @throws IllegalArgumentException if the count is negative
*/
public void addValue(double value, int count) {
if (count < 0) {
@@ -247,8 +242,8 @@ public int binCount() {
}
/**
- * Returns the bin associated with the given index. Bins are indexed from 0
- * to binCount-1.
+ * Returns the bin associated with the given index. Bins are indexed from 0 to
+ * binCount-1.
*/
public Bin getBin(int index) {
if (index < 0) {
diff --git a/src/main/java/util/stats/ImmutableStat.java b/src/main/java/util/stats/ImmutableStat.java
index 3ea2ee1..c4aa25a 100644
--- a/src/main/java/util/stats/ImmutableStat.java
+++ b/src/main/java/util/stats/ImmutableStat.java
@@ -8,16 +8,12 @@
/**
* A {@link Stat} implementor that is immutable and is constructed via the
* contained builder class.
- *
- *
*/
@ThreadSafe
public final class ImmutableStat implements Stat {
/**
* A container for collecting the five characteristics of a Stat
- *
- *
*/
private static class Data {
private double mean;
@@ -47,8 +43,6 @@ public static Builder builder() {
/**
* A builder class for {@link ImmutableStat}
- *
- *
*/
@NotThreadSafe
public static class Builder {
@@ -62,18 +56,21 @@ private Builder() {
* Builds the ImmutableStat
*
* @throws IllegalArgumentException
- * if the size is negative
- * if the size value is one and the min mean and max are
- * not equal
- * if the size value is one and the variance is not zero
- * if the size value is greater than one and the min
- * exceeds the max
- * if the size value is greater than one and the min
- * exceeds the mean
- * if the size value is greater than one and the mean
- * exceeds the max
- * if the size value is greater than one and the
- * variance is negative
+ *
+ * - if the size is negative
+ * - if the size value is one and the min
+ * mean and max are not equal
+ * - if the size value is one and the
+ * variance is not zero
+ * - if the size value is greater than
+ * one and the min exceeds the max
+ * - if the size value is greater than
+ * one and the min exceeds the mean
+ * - if the size value is greater than
+ * one and the mean exceeds the max
+ * - if the size value is greater than
+ * one and the variance is negative
+ *
*/
public ImmutableStat build() {
validate();
@@ -120,27 +117,25 @@ public Builder setSize(int size) {
return this;
}
- /*
+ /**
* Validates the content of the Stat
*
* @throws IllegalArgumentException
- *
- * if the size is negative
- *
- * if the size value is one and the min mean and max are not equal
- *
- * if the size value is one and the variance is not zero
- *
- * if the size value is greater than one and the min exceeds the max
- *
- * if the size value is greater than one and the min exceeds the
- * mean
- *
- * if the size value is greater than one and the mean exceeds the
- * max
- *
- * if the size value is greater than one and the variance is
- * negative
+ *
+ * - if the size is negative
+ *
- if the size value is one and the min
+ * mean and max are not equal
+ *
- if the size value is one and the
+ * variance is not zero
+ *
- if the size value is greater than
+ * one and the min exceeds the max
+ *
- if the size value is greater than
+ * one and the min exceeds the mean
+ *
- if the size value is greater than
+ * one and the mean exceeds the max
+ *
- if the size value is greater than
+ * one and the variance is negative
+ *
*/
private void validate() {
if (data.size < 0) {
diff --git a/src/main/java/util/stats/KahanSum.java b/src/main/java/util/stats/KahanSum.java
index 7c11f8a..bb1cbcc 100644
--- a/src/main/java/util/stats/KahanSum.java
+++ b/src/main/java/util/stats/KahanSum.java
@@ -3,8 +3,6 @@
/**
* Implements the error reducing methodology for sums of floating point numbers
* developed by mathematician William Kahan.
- *
- *
*/
public final class KahanSum {
diff --git a/src/main/java/util/stats/MutableStat.java b/src/main/java/util/stats/MutableStat.java
index fd1e097..09b0997 100644
--- a/src/main/java/util/stats/MutableStat.java
+++ b/src/main/java/util/stats/MutableStat.java
@@ -9,11 +9,8 @@
* Implements B.P. Welford's method for determining sample variance without
* maintaining sample values. Corrects for a significant portion of the rounding
* errors associated with a large number of sample values. Corrects for errors
- * that arise from high mean and low variance sample populations.
- *
- * Adapted from https://www.johndcook.com/blog/standard_deviation/
- *
- *
+ * that arise from high mean and low variance sample populations. Adapted from
+ * https://www.johndcook.com/blog/standard_deviation/
*/
@NotThreadSafe
public final class MutableStat implements Stat {
@@ -27,9 +24,7 @@ public static Stat combineStatsCollection(Collection extends Stat> stats) {
/**
* Combines several stats
*
- * @throws NullPointerException
- * if the stats are null
- *
+ * @throws NullPointerException if the stats are null
*/
public static Stat combineStats(Stat... stats) {
@@ -143,9 +138,8 @@ public void add(double value) {
}
/*
- * Using Welford's method we update the mean and variance. Both are
- * kept in Kahan Sums rather than doubles to help reduce the
- * accumulation of error.
+ * Using Welford's method we update the mean and variance. Both are kept in
+ * Kahan Sums rather than doubles to help reduce the accumulation of error.
*/
double oldMean = mean.getSum();
mean.add((value - oldMean) / count);
diff --git a/src/main/java/util/stats/Stat.java b/src/main/java/util/stats/Stat.java
index 8d2958e..5286c94 100644
--- a/src/main/java/util/stats/Stat.java
+++ b/src/main/java/util/stats/Stat.java
@@ -5,42 +5,37 @@
/**
* Stat contains the values of several useful statistical values for a sequence,
* but not the values in the sequence.
- *
- *
*/
public interface Stat {
/**
- * Returns the mean of the sequence. Empty sequences do not have a defined
- * mean and the Optional will reflect that no mean value is present.
+ * Returns the mean of the sequence. Empty sequences do not have a defined mean
+ * and the Optional will reflect that no mean value is present.
*/
public Optional getMean();
/**
- * Returns the variance of the sequence. Empty sequences do not have a
- * defined variance and the Optional will reflect that no variance value is
- * present.
+ * Returns the variance of the sequence. Empty sequences do not have a defined
+ * variance and the Optional will reflect that no variance value is present.
*/
public Optional getVariance();
/**
- * Returns the standard deviation of the sequence. Empty sequences do not
- * have a defined standard deviation and the Optional will reflect that no
- * standard deviation value is present.
+ * Returns the standard deviation of the sequence. Empty sequences do not have a
+ * defined standard deviation and the Optional will reflect that no standard
+ * deviation value is present.
*/
public Optional getStandardDeviation();
/**
- * Returns the max value of the sequence. Empty sequences do not have a
- * defined max value and the Optional will reflect that no max value value
- * is present.
+ * Returns the max value of the sequence. Empty sequences do not have a defined
+ * max value and the Optional will reflect that no max value value is present.
*/
public Optional getMax();
/**
- * Returns the min value of the sequence. Empty sequences do not have a
- * defined min value and the Optional will reflect that no min value value
- * is present.
+ * Returns the min value of the sequence. Empty sequences do not have a defined
+ * min value and the Optional will reflect that no min value value is present.
*/
public Optional getMin();
diff --git a/src/main/java/util/time/Stopwatch.java b/src/main/java/util/time/Stopwatch.java
index 77b24e1..fbbdd12 100644
--- a/src/main/java/util/time/Stopwatch.java
+++ b/src/main/java/util/time/Stopwatch.java
@@ -1,14 +1,9 @@
package util.time;
-
-
/**
* A nano-time based accumulator of elapsed time that allows the client to start
* and stop accumulation.
- *
- *
*/
-
public final class Stopwatch {
private boolean running;
diff --git a/src/main/java/util/time/TimeElapser.java b/src/main/java/util/time/TimeElapser.java
index 436169f..b16ef9a 100644
--- a/src/main/java/util/time/TimeElapser.java
+++ b/src/main/java/util/time/TimeElapser.java
@@ -2,8 +2,6 @@
/**
* A debug-convenience class for measuring elapsed time via System.nanoTime()
- *
- *
*/
public final class TimeElapser {
diff --git a/src/main/java/util/vector/Circle2D.java b/src/main/java/util/vector/Circle2D.java
index 0e4b1e5..8d73314 100644
--- a/src/main/java/util/vector/Circle2D.java
+++ b/src/main/java/util/vector/Circle2D.java
@@ -9,32 +9,21 @@
/**
* A utility for calculating the smallest circle that encompasses a set of 2D
- * points.
- *
- * The utility can use any of four algorithms for forming the circle.
- *
- * CENTROID - The centroid of the points is used as the center of the circle with
- * the radius being the largest distance from any point to that centroid.
- * Solution is order O(n).
- *
- * N3 - The order O(n^3) version of the N4 algorithm. It is a bit more complex
- * than N4, but is just a streamlined version of N4 and should return the same
- * circle within precision error.
- *
- * N4 - The order O(n^4) algorithm that returns the smallest circle that will
- * contain all of the points. This will return the same solution as Nimrod
- * Megiddo's O(n) algorithm.
- *
- * COLLAPSING_BUBBLE - An order O(n) algorithm that returns the same solution as
- * N4 approximately 80+% of the time. The remaining ~20% the algorithm returns
- * circles that are generally a fraction of percent larger than the optimal
- * solution of N4 and Megiddo's O(n) algorithm.
- *
- * Future improvements to this class would likely include an implementation of
+ * points. The utility can use any of four algorithms for forming the circle.
+ * CENTROID - The centroid of the points is used as the center of the circle
+ * with the radius being the largest distance from any point to that centroid.
+ * Solution is order O(n). N3 - The order O(n^3) version of the N4 algorithm. It
+ * is a bit more complex than N4, but is just a streamlined version of N4 and
+ * should return the same circle within precision error. N4 - The order O(n^4)
+ * algorithm that returns the smallest circle that will contain all of the
+ * points. This will return the same solution as Nimrod Megiddo's O(n)
+ * algorithm. COLLAPSING_BUBBLE - An order O(n) algorithm that returns the same
+ * solution as N4 approximately 80+% of the time. The remaining ~20% the
+ * algorithm returns circles that are generally a fraction of percent larger
+ * than the optimal solution of N4 and Megiddo's O(n) algorithm. Future
+ * improvements to this class would likely include an implementation of
* Megiddo's O(n) algorithm as well as a version of this utility for spherical
* polygons.
- *
- *
*/
@Immutable
public class Circle2D {
@@ -66,8 +55,8 @@ public double getRadius() {
}
/**
- * Returns true if and only if both the center and radius of this circle
- * contain finite values
+ * Returns true if and only if both the center and radius of this circle contain
+ * finite values
*/
public boolean isFinite() {
return Double.isFinite(radius) && center.isFinite();
@@ -92,7 +81,7 @@ private Circle2D(Vector2D a) {
private Circle2D(Vector2D a, double radius) {
center = a;
- if (radius < 0) {
+ if (radius < 0) {
throw new RuntimeException("negative radius");
}
this.radius = radius;
@@ -111,8 +100,8 @@ public boolean contains(Vector2D point) {
}
/**
- * Returns true if and only if no point is outside of this circle. An empty
- * list of points will return true.
+ * Returns true if and only if no point is outside of this circle. An empty list
+ * of points will return true.
*/
public boolean contains(List points) {
for (Vector2D point : points) {
@@ -125,26 +114,19 @@ public boolean contains(List points) {
/**
* Constructs a {@link Circle2D} from the given points via the selected
- * algorithm.
- *
- * N3 and N4 will return the smallest circle possible. N3 is O(n^3) while N4
- * is O(n^4).
- *
- * CENTROID is the fastest O(n), but in practice may occasionally return a
- * circle that may be up to 30% larger than the optimal solution provided by
- * N3
- *
- * COLLAPSING_BUBBLE a O(n) algorithm that is a bit slower than CENTROID but
- * returns the smallest possible circle about 80% of the time. The remaining
- * cases will be generally a fraction of a percent larger than optimal. This
- * is the current best option for most purposes.
+ * algorithm. N3 and N4 will return the smallest circle possible. N3 is O(n^3)
+ * while N4 is O(n^4). CENTROID is the fastest O(n), but in practice may
+ * occasionally return a circle that may be up to 30% larger than the optimal
+ * solution provided by N3 COLLAPSING_BUBBLE a O(n) algorithm that is a bit
+ * slower than CENTROID but returns the smallest possible circle about 80% of
+ * the time. The remaining cases will be generally a fraction of a percent
+ * larger than optimal. This is the current best option for most purposes.
*/
public Circle2D(List points, SolutionAlgorithm solutionAlgorithm) {
/*
- * The presumption is that the points will nearly always be distinct.
- * Some of the algorithms below work only when given at least three
- * points, even when they are not distinct. Thus we handle the first
- * three cases here.
+ * The presumption is that the points will nearly always be distinct. Some of
+ * the algorithms below work only when given at least three points, even when
+ * they are not distinct. Thus we handle the first three cases here.
*/
Circle2D c;
@@ -172,7 +154,7 @@ public Circle2D(List points, SolutionAlgorithm solutionAlgorithm) {
case COLLAPSING_BUBBLE:
c = getCollapsingBubbleSolution(points);
break;
- default:
+ default:
throw new RuntimeException("unhandled case " + solutionAlgorithm);
}
break;
@@ -203,10 +185,10 @@ private Circle2D getCentroidSolution(List points) {
/*
* Uses a centroid calculation to find a first point of contact between the
* circle and the points. This circle is then collapsed by moving the center
- * toward the first contact point until a second contact point is
- * established. The center is then moved toward the midpoint between the
- * first two contact points until either a third contact point is found or
- * the center reaches the midpoint of the chord.
+ * toward the first contact point until a second contact point is established.
+ * The center is then moved toward the midpoint between the first two contact
+ * points until either a third contact point is found or the center reaches the
+ * midpoint of the chord.
*/
private Circle2D getCollapsingBubbleSolution(List points) {
@@ -232,7 +214,7 @@ private Circle2D getCollapsingBubbleSolution(List points) {
Vector2D point = points.get(i);
double distance = cen.distanceTo(point);
if (distance > r) {
- a = point;
+ a = point;
r = distance;
}
}
@@ -276,8 +258,8 @@ private Circle2D getCollapsingBubbleSolution(List points) {
cen = m1.sub(cen).scale(minJ).add(cen);
/*
- * determine the radius from all the points to ensure every point will
- * be inside the circle
+ * determine the radius from all the points to ensure every point will be inside
+ * the circle
*/
r = Double.NEGATIVE_INFINITY;
for (int i = 0; i < points.size(); i++) {
@@ -301,7 +283,8 @@ public Interval(double lowerBound, double upperBound) {
}
public Interval intersect(Interval interval) {
- return new Interval(FastMath.max(lowerBound, interval.lowerBound), FastMath.min(upperBound, interval.upperBound));
+ return new Interval(FastMath.max(lowerBound, interval.lowerBound),
+ FastMath.min(upperBound, interval.upperBound));
}
public boolean isNaN() {
@@ -325,13 +308,12 @@ public String toString() {
}
/*
- * Returns the range of positions that could act as the center of a circle
- * that would have a and b on its circumference and would contain c in its
- * interior.
+ * Returns the range of positions that could act as the center of a circle that
+ * would have a and b on its circumference and would contain c in its interior.
*
- * The positions are returned as an interval [j,inf) or (-inf,j] where j is
- * the signed distance from the midpoint of the chord formed by a and b and
- * the right hand perpendicular bisector of that chord.
+ * The positions are returned as an interval [j,inf) or (-inf,j] where j is the
+ * signed distance from the midpoint of the chord formed by a and b and the
+ * right hand perpendicular bisector of that chord.
*/
private Interval getInterval(Vector2D a, Vector2D b, Vector2D c) {
Interval result;
@@ -349,11 +331,10 @@ private Interval getInterval(Vector2D a, Vector2D b, Vector2D c) {
}
/*
- * Returns the smallest circle that has a and b on its circumference where
- * the signed distance along the right hand perpendicular bisector of the
- * chord formed by a and b is a value in the given interval. This will only
- * be valid if the interval was formed from a and b in the getInterval()
- * method.
+ * Returns the smallest circle that has a and b on its circumference where the
+ * signed distance along the right hand perpendicular bisector of the chord
+ * formed by a and b is a value in the given interval. This will only be valid
+ * if the interval was formed from a and b in the getInterval() method.
*
*/
private Circle2D getCircle(Vector2D a, Vector2D b, Interval interval) {
@@ -372,8 +353,8 @@ private Circle2D getCircle(Vector2D a, Vector2D b, Interval interval) {
/*
* For each pair of points, determine for each of the remaining points where
- * center of the smallest circle might be. The result will be the smallest
- * such circle.
+ * center of the smallest circle might be. The result will be the smallest such
+ * circle.
*/
private Circle2D getN3Solution(List points) {
/*
@@ -381,42 +362,38 @@ private Circle2D getN3Solution(List points) {
*/
Circle2D result = new Circle2D();
/*
- * Loop through each pair of points. If the pair can be on a the
- * circumference of a circle that contains all the points, the smallest
- * such circle will be produced.
+ * Loop through each pair of points. If the pair can be on a the circumference
+ * of a circle that contains all the points, the smallest such circle will be
+ * produced.
*/
for (int i = 0; i < points.size() - 1; i++) {
for (int j = i + 1; j < points.size(); j++) {
/*
- * Assume that the full set of points that form the
- * perpendicular bisector of the chord formed by points i and j
- * will be valid centers a circle containing the remaining
- * points.
+ * Assume that the full set of points that form the perpendicular bisector of
+ * the chord formed by points i and j will be valid centers a circle containing
+ * the remaining points.
*
*/
Interval intervalForIJ = new Interval(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
for (int k = 0; k < points.size(); k++) {
if (k != i && k != j) {
/*
- * Determine the subset of the bisector that will allow
- * the kth point to be in a circle that has point i and
- * point j on its circumference
+ * Determine the subset of the bisector that will allow the kth point to be in a
+ * circle that has point i and point j on its circumference
*/
Interval intervalForK = getInterval(points.get(i), points.get(j), points.get(k));
/*
- * Intersect this set of the points with the set so far
- * collected. If a NaN has occured in the interval
- * solution, we should ignore that solution. This
- * indicates that the kth point is VERY close to either
- * the ith or jth point.
+ * Intersect this set of the points with the set so far collected. If a NaN has
+ * occured in the interval solution, we should ignore that solution. This
+ * indicates that the kth point is VERY close to either the ith or jth point.
*/
if (!intervalForK.isNaN()) {
intervalForIJ = intervalForIJ.intersect(intervalForK);
}
/*
- * If the interval for the i,j pair becomes empty, we
- * need not examine the remaining kth points
+ * If the interval for the i,j pair becomes empty, we need not examine the
+ * remaining kth points
*/
if (intervalForIJ.isEmpty()) {
break;
@@ -424,8 +401,7 @@ private Circle2D getN3Solution(List points) {
}
}
/*
- * If the interval is not empty, then determine the center from
- * the interval
+ * If the interval is not empty, then determine the center from the interval
*/
if (!intervalForIJ.isEmpty()) {
Circle2D circle = getCircle(points.get(i), points.get(j), intervalForIJ);
@@ -456,29 +432,27 @@ private Circle2D getN4Solution(List