Package net.bmahe.genetics4j.gp.program
Class ImmutableProgram.Builder
java.lang.Object
net.bmahe.genetics4j.gp.program.ImmutableProgram.Builder
- Enclosing class:
ImmutableProgram
Builds instances of type
ImmutableProgram
.
Initialize attributes and then invoke the build()
method to create an
immutable instance.
Builder
is not thread-safe and generally should not be stored in a field or collection,
but instead used immediately to create instances.
-
Field Summary
Modifier and TypeFieldDescriptionprivate List
<OperationFactory> private static final long
private static final long
private long
private InputSpec
private int
private List
<OperationFactory> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal ImmutableProgram.Builder
addAllFunctions
(Iterable<? extends OperationFactory> elements) Adds elements tofunctions
set.final ImmutableProgram.Builder
addAllTerminal
(Iterable<? extends OperationFactory> elements) Adds elements toterminal
set.final ImmutableProgram.Builder
addFunctions
(OperationFactory element) Adds one element tofunctions
set.final ImmutableProgram.Builder
addFunctions
(OperationFactory... elements) Adds elements tofunctions
set.final ImmutableProgram.Builder
addTerminal
(OperationFactory element) Adds one element toterminal
set.final ImmutableProgram.Builder
addTerminal
(OperationFactory... elements) Adds elements toterminal
set.build()
Builds a newImmutableProgram
.private String
final ImmutableProgram.Builder
Fill a builder with attribute values from the providedProgram
instance.final ImmutableProgram.Builder
functions
(Iterable<? extends OperationFactory> elements) Sets or replaces all elements forfunctions
set.final ImmutableProgram.Builder
Initializes the value for theinputSpec
attribute.final ImmutableProgram.Builder
maxDepth
(int maxDepth) Initializes the value for themaxDepth
attribute.final ImmutableProgram.Builder
terminal
(Iterable<? extends OperationFactory> elements) Sets or replaces all elements forterminal
set.
-
Field Details
-
INIT_BIT_INPUT_SPEC
private static final long INIT_BIT_INPUT_SPEC- See Also:
-
INIT_BIT_MAX_DEPTH
private static final long INIT_BIT_MAX_DEPTH- See Also:
-
initBits
private long initBits -
functions
-
terminal
-
inputSpec
-
maxDepth
private int maxDepth
-
-
Constructor Details
-
Builder
private Builder()
-
-
Method Details
-
from
Fill a builder with attribute values from the providedProgram
instance. Regular attribute values will be replaced with those from the given instance. Absent optional values will not replace present values. Collection elements and entries will be added, not replaced.- Parameters:
instance
- The instance from which to copy values- Returns:
this
builder for use in a chained invocation
-
addFunctions
Adds one element tofunctions
set.- Parameters:
element
- A functions element- Returns:
this
builder for use in a chained invocation
-
addFunctions
Adds elements tofunctions
set.- Parameters:
elements
- An array of functions elements- Returns:
this
builder for use in a chained invocation
-
functions
Sets or replaces all elements forfunctions
set.- Parameters:
elements
- An iterable of functions elements- Returns:
this
builder for use in a chained invocation
-
addAllFunctions
public final ImmutableProgram.Builder addAllFunctions(Iterable<? extends OperationFactory> elements) Adds elements tofunctions
set.- Parameters:
elements
- An iterable of functions elements- Returns:
this
builder for use in a chained invocation
-
addTerminal
Adds one element toterminal
set.- Parameters:
element
- A terminal element- Returns:
this
builder for use in a chained invocation
-
addTerminal
Adds elements toterminal
set.- Parameters:
elements
- An array of terminal elements- Returns:
this
builder for use in a chained invocation
-
terminal
Sets or replaces all elements forterminal
set.- Parameters:
elements
- An iterable of terminal elements- Returns:
this
builder for use in a chained invocation
-
addAllTerminal
Adds elements toterminal
set.- Parameters:
elements
- An iterable of terminal elements- Returns:
this
builder for use in a chained invocation
-
inputSpec
Initializes the value for theinputSpec
attribute.- Parameters:
inputSpec
- The value for inputSpec- Returns:
this
builder for use in a chained invocation
-
maxDepth
Initializes the value for themaxDepth
attribute.- Parameters:
maxDepth
- The value for maxDepth- Returns:
this
builder for use in a chained invocation
-
build
Builds a newImmutableProgram
.- Returns:
- An immutable instance of Program
- Throws:
IllegalStateException
- if any required attributes are missing
-
formatRequiredAttributesMessage
-