Package net.bmahe.genetics4j.gp
Class ImmutableOperation.Builder<T>
java.lang.Object
net.bmahe.genetics4j.gp.ImmutableOperation.Builder<T>
- Enclosing class:
ImmutableOperation<T>
Builds instances of type
ImmutableOperation
.
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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal ImmutableOperation.Builder
<T> acceptedTypes
(Iterable<? extends Class> elements) Sets or replaces all elements foracceptedTypes
list.final ImmutableOperation.Builder
<T> addAcceptedTypes
(Class element) Adds one element toacceptedTypes
list.final ImmutableOperation.Builder
<T> addAcceptedTypes
(Class... elements) Adds elements toacceptedTypes
list.final ImmutableOperation.Builder
<T> addAllAcceptedTypes
(Iterable<? extends Class> elements) Adds elements toacceptedTypes
list.build()
Builds a newImmutableOperation
.final ImmutableOperation.Builder
<T> compute
(BiFunction<T[], Object[], Object> compute) Initializes the value for thecompute
attribute.private String
final ImmutableOperation.Builder
<T> Fill a builder with attribute values from the providedOperation
instance.final ImmutableOperation.Builder
<T> Initializes the value for thename
attribute.final ImmutableOperation.Builder
<T> prettyName
(String prettyName) Initializes the value for theprettyName
attribute.final ImmutableOperation.Builder
<T> returnedType
(Class returnedType) Initializes the value for thereturnedType
attribute.
-
Field Details
-
INIT_BIT_NAME
private static final long INIT_BIT_NAME- See Also:
-
INIT_BIT_RETURNED_TYPE
private static final long INIT_BIT_RETURNED_TYPE- See Also:
-
INIT_BIT_COMPUTE
private static final long INIT_BIT_COMPUTE- See Also:
-
initBits
private long initBits -
name
-
acceptedTypes
-
returnedType
-
compute
-
prettyName
-
-
Constructor Details
-
Builder
private Builder()
-
-
Method Details
-
from
Fill a builder with attribute values from the providedOperation
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
-
name
Initializes the value for thename
attribute.- Parameters:
name
- The value for name- Returns:
this
builder for use in a chained invocation
-
addAcceptedTypes
Adds one element toacceptedTypes
list.- Parameters:
element
- A acceptedTypes element- Returns:
this
builder for use in a chained invocation
-
addAcceptedTypes
Adds elements toacceptedTypes
list.- Parameters:
elements
- An array of acceptedTypes elements- Returns:
this
builder for use in a chained invocation
-
acceptedTypes
Sets or replaces all elements foracceptedTypes
list.- Parameters:
elements
- An iterable of acceptedTypes elements- Returns:
this
builder for use in a chained invocation
-
addAllAcceptedTypes
Adds elements toacceptedTypes
list.- Parameters:
elements
- An iterable of acceptedTypes elements- Returns:
this
builder for use in a chained invocation
-
returnedType
Initializes the value for thereturnedType
attribute.- Parameters:
returnedType
- The value for returnedType- Returns:
this
builder for use in a chained invocation
-
compute
Initializes the value for thecompute
attribute.- Parameters:
compute
- The value for compute- Returns:
this
builder for use in a chained invocation
-
prettyName
Initializes the value for theprettyName
attribute.If not set, this attribute will have a default value as returned by the initializer of
prettyName
.- Parameters:
prettyName
- The value for prettyName- Returns:
this
builder for use in a chained invocation
-
build
Builds a newImmutableOperation
.- Returns:
- An immutable instance of Operation
- Throws:
IllegalStateException
- if any required attributes are missing
-
formatRequiredAttributesMessage
-