Package gov.usgs.earthquake.nshmp.tree
Class LogicTree.Builder<T>
- java.lang.Object
-
- gov.usgs.earthquake.nshmp.tree.LogicTree.Builder<T>
-
- Direct Known Subclasses:
LogicGroup.Builder,LogicTree.EnumBuilder,LogicTree.EnumValueBuilder,LogicTree.StringValueBuilder
public static class LogicTree.Builder<T> extends Object
A single-useLogicTreebuilder.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedBuilder(String name)Sole package constructor; useLogicTree.builder(String)instead.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LogicTree.Builder<T>addBranch(String id, T value, double weight)Add a branch to the tree.LogicTree<T>build()Return a newly createdLogicTree.
-
-
-
Constructor Detail
-
Builder
protected Builder(String name)
Sole package constructor; useLogicTree.builder(String)instead.- Parameters:
name- of the tree
-
-
Method Detail
-
addBranch
public LogicTree.Builder<T> addBranch(String id, T value, double weight)
Add a branch to the tree.- Parameters:
id- of the branchvalue- of the branchweight- of the branch- Returns:
- this
Builderobject - Throws:
NullPointerException- ifidorvalueis nullIllegalArgumentException- ifidis empty or whitespaceIllegalArgumentException- if a branch withidhas already been addedIllegalArgumentException- ifweightis outside the range (0..1]
-
build
public LogicTree<T> build()
Return a newly createdLogicTree.- Throws:
IllegalStateException- if this method has already been calledIllegalStateException- if the logic tree is empty (i.e. no branches have been added)IllegalStateException- if branch weights do not sum to1.0 ± 0.00001
-
-