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-useLogicTree
builder.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Builder(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
Builder
object - Throws:
NullPointerException
- ifid
orvalue
is nullIllegalArgumentException
- ifid
is empty or whitespaceIllegalArgumentException
- if a branch withid
has already been addedIllegalArgumentException
- ifweight
is 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
-
-