You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2018/07/20 10:33:33 UTC
[commons-geometry] 02/09: GEOMETRY-4: updating CheckStyle fix in
BSPTree.visit() to throw an exception in the default clause of the order
switch statement instead of silently performing the last operation;
the default clause should never be reached since all possibilities are
handled in the switch statement
This is an automated email from the ASF dual-hosted git repository.
erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-geometry.git
commit ebc752bba877bf8df69fdea7772e549993cb98ab
Author: Matt Juntunen <ma...@hotmail.com>
AuthorDate: Sun Jun 3 15:35:48 2018 -0400
GEOMETRY-4: updating CheckStyle fix in BSPTree.visit() to throw an exception in the default clause of the order switch statement instead of silently performing the last operation; the default clause should never be reached since all possibilities are handled in the switch statement
---
.../org/apache/commons/geometry/core/partitioning/BSPTree.java | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/BSPTree.java b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/BSPTree.java
index 7e2ddde..e74614b 100644
--- a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/BSPTree.java
+++ b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/BSPTree.java
@@ -20,6 +20,7 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.commons.geometry.core.Point;
+import org.apache.commons.geometry.core.partitioning.BSPTreeVisitor.Order;
/** This class represent a Binary Space Partition tree.
@@ -239,7 +240,8 @@ public class BSPTree<P extends Point<P>> {
if (cut == null) {
visitor.visitLeafNode(this);
} else {
- switch (visitor.visitOrder(this)) {
+ Order order = visitor.visitOrder(this);
+ switch (order) {
case PLUS_MINUS_SUB:
plus.visit(visitor);
minus.visit(visitor);
@@ -266,13 +268,15 @@ public class BSPTree<P extends Point<P>> {
minus.visit(visitor);
break;
case SUB_MINUS_PLUS:
- default:
visitor.visitInternalNode(this);
minus.visit(visitor);
plus.visit(visitor);
break;
+ default:
+ // we shouldn't end up here since all possibilities are
+ // covered above
+ throw new IllegalStateException("Invalid node visit order: " + order);
}
-
}
}