From 3c4c49744a9bb5c8ee1db328121fe8bfb832443a Mon Sep 17 00:00:00 2001
From: Peter Powers <pmpowers@usgs.gov>
Date: Tue, 24 May 2022 15:40:50 -0600
Subject: [PATCH] allowing logicGroup branch scale to be zero

---
 .../java/gov/usgs/earthquake/nshmp/tree/GroupBranch.java     | 4 ++--
 src/main/java/gov/usgs/earthquake/nshmp/tree/LogicGroup.java | 5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/main/java/gov/usgs/earthquake/nshmp/tree/GroupBranch.java b/src/main/java/gov/usgs/earthquake/nshmp/tree/GroupBranch.java
index 129e37bb..a7396550 100644
--- a/src/main/java/gov/usgs/earthquake/nshmp/tree/GroupBranch.java
+++ b/src/main/java/gov/usgs/earthquake/nshmp/tree/GroupBranch.java
@@ -1,7 +1,7 @@
 package gov.usgs.earthquake.nshmp.tree;
 
 import static com.google.common.base.Preconditions.checkNotNull;
-import static gov.usgs.earthquake.nshmp.data.DoubleData.checkIsPositiveAndReal;
+import static gov.usgs.earthquake.nshmp.data.DoubleData.checkIsPositiveAndRealOrZero;
 import static gov.usgs.earthquake.nshmp.tree.RegularBranch.checkId;
 
 /**
@@ -18,7 +18,7 @@ class GroupBranch<T> implements Branch<T> {
   GroupBranch(String id, T value, double scale) {
     this.id = checkId(id);
     this.value = checkNotNull(value);
-    this.scale = checkIsPositiveAndReal(scale);
+    this.scale = checkIsPositiveAndRealOrZero(scale);
   }
 
   @Override
diff --git a/src/main/java/gov/usgs/earthquake/nshmp/tree/LogicGroup.java b/src/main/java/gov/usgs/earthquake/nshmp/tree/LogicGroup.java
index 5e24420d..7aef6c7f 100644
--- a/src/main/java/gov/usgs/earthquake/nshmp/tree/LogicGroup.java
+++ b/src/main/java/gov/usgs/earthquake/nshmp/tree/LogicGroup.java
@@ -15,7 +15,8 @@ import java.util.List;
  * implements {@code LogicTree}, its sampling methods are overriden to throw an
  * {@code UnsupportedOperationException}. A logic group branch <i>may</i>
  * include a scale factor that is used in lieu of a branch weight; in most
- * real-world cases, the scale value is one.
+ * real-world cases, the scale value is one. The scale factor may also be zero
+ * to represent {@code null} branches.
  *
  * @param <T> the type of value stored in a branch
  * @author U.S. Geological Survey
@@ -97,7 +98,7 @@ public final class LogicGroup<T> extends AbstractList<Branch<T>> implements Logi
      *
      * @param id of the branch
      * @param value of the branch
-     * @param scale factor to apply in lieu of a branch weight
+     * @param scale factor to apply in lieu of a branch weight, may be zero
      * @return this {@code Builder} object
      * @throws NullPointerException if {@code id} or {@code value} is null
      * @throws IllegalArgumentException if {@code id} is empty or whitespace
-- 
GitLab