GP-0 - CategoryPath changes

This commit is contained in:
ghizard 2024-02-26 17:37:51 -05:00
parent a348f2d5df
commit 2fc8f67835

View file

@ -229,7 +229,7 @@ public class CategoryPath implements Comparable<CategoryPath> {
/** /**
* Return the {@link String} representation of this category path including the category name, * Return the {@link String} representation of this category path including the category name,
* where components are delimited with a forward slash. Any occurance of a forward slash * where components are delimited with a forward slash. Any occurrence of a forward slash
* within individual path components will be escaped (e.g., {@code "\/"}). * within individual path components will be escaped (e.g., {@code "\/"}).
* @return the full category path * @return the full category path
*/ */
@ -242,7 +242,7 @@ public class CategoryPath implements Comparable<CategoryPath> {
/** /**
* Return the {@link String} representation of the specified {@code childName} within this * Return the {@link String} representation of the specified {@code childName} within this
* category path where all path components are delimited with a forward slash. Any occurance * category path where all path components are delimited with a forward slash. Any occurrence
* of a forward slash within individual path components, including the {@code childName}, will * of a forward slash within individual path components, including the {@code childName}, will
* be escaped (e.g., {@code "\/"}). * be escaped (e.g., {@code "\/"}).
* @param childName child name * @param childName child name
@ -307,7 +307,7 @@ public class CategoryPath implements Comparable<CategoryPath> {
*/ */
public boolean isAncestorOrSelf(CategoryPath candidateAncestorPath) { public boolean isAncestorOrSelf(CategoryPath candidateAncestorPath) {
// Result categoryPath This // Result candidateAncestor This
// ------ --------------------- ------------------------ // ------ --------------------- ------------------------
// True / / // True / /
// True / /apple // True / /apple
@ -344,12 +344,12 @@ public class CategoryPath implements Comparable<CategoryPath> {
*/ */
@Override @Override
public int compareTo(CategoryPath other) { public int compareTo(CategoryPath other) {
if (isRoot() && other.isRoot()) { if (isRoot()) {
return 0; return other.isRoot() ? 0 : -1;
} }
if (isRoot() || other.isRoot()) { if (other.isRoot()) {
return isRoot() ? -1 : 1; return 1;
} }
int result = parent.compareTo(other.getParent()); int result = parent.compareTo(other.getParent());