Package net.bmahe.genetics4j.neat
Class ImmutableConnection.Builder
java.lang.Object
net.bmahe.genetics4j.neat.ImmutableConnection.Builder
- Direct Known Subclasses:
Connection.Builder
- Enclosing class:
ImmutableConnection
Builds instances of type
ImmutableConnection
.
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 int
private static final long
private static final long
private static final long
private static final long
private static final long
private long
private int
private boolean
private int
private float
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds a newImmutableConnection
.private String
final Connection.Builder
from
(Connection instance) Fill a builder with attribute values from the providedConnection
instance.final Connection.Builder
fromNodeIndex
(int fromNodeIndex) Initializes the value for thefromNodeIndex
attribute.final Connection.Builder
innovation
(int innovation) Initializes the value for theinnovation
attribute.final Connection.Builder
isEnabled
(boolean isEnabled) Initializes the value for theisEnabled
attribute.final Connection.Builder
toNodeIndex
(int toNodeIndex) Initializes the value for thetoNodeIndex
attribute.final Connection.Builder
weight
(float weight) Initializes the value for theweight
attribute.
-
Field Details
-
INIT_BIT_FROM_NODE_INDEX
private static final long INIT_BIT_FROM_NODE_INDEX- See Also:
-
INIT_BIT_TO_NODE_INDEX
private static final long INIT_BIT_TO_NODE_INDEX- See Also:
-
INIT_BIT_WEIGHT
private static final long INIT_BIT_WEIGHT- See Also:
-
INIT_BIT_IS_ENABLED
private static final long INIT_BIT_IS_ENABLED- See Also:
-
INIT_BIT_INNOVATION
private static final long INIT_BIT_INNOVATION- See Also:
-
initBits
private long initBits -
fromNodeIndex
private int fromNodeIndex -
toNodeIndex
private int toNodeIndex -
weight
private float weight -
isEnabled
private boolean isEnabled -
innovation
private int innovation
-
-
Constructor Details
-
Builder
public Builder()Creates a builder forImmutableConnection
instances.new Connection.Builder() .fromNodeIndex(int) // required
fromNodeIndex
.toNodeIndex(int) // requiredtoNodeIndex
.weight(float) // requiredweight
.isEnabled(boolean) // requiredisEnabled
.innovation(int) // requiredinnovation
.build();
-
-
Method Details
-
from
Fill a builder with attribute values from the providedConnection
instance. Regular attribute values will be replaced with those from the given instance. Absent optional values will not replace present values.- Parameters:
instance
- The instance from which to copy values- Returns:
this
builder for use in a chained invocation
-
fromNodeIndex
Initializes the value for thefromNodeIndex
attribute.- Parameters:
fromNodeIndex
- The value for fromNodeIndex- Returns:
this
builder for use in a chained invocation
-
toNodeIndex
Initializes the value for thetoNodeIndex
attribute.- Parameters:
toNodeIndex
- The value for toNodeIndex- Returns:
this
builder for use in a chained invocation
-
weight
Initializes the value for theweight
attribute.- Parameters:
weight
- The value for weight- Returns:
this
builder for use in a chained invocation
-
isEnabled
Initializes the value for theisEnabled
attribute.- Parameters:
isEnabled
- The value for isEnabled- Returns:
this
builder for use in a chained invocation
-
innovation
Initializes the value for theinnovation
attribute.- Parameters:
innovation
- The value for innovation- Returns:
this
builder for use in a chained invocation
-
build
Builds a newImmutableConnection
.- Returns:
- An immutable instance of Connection
- Throws:
IllegalStateException
- if any required attributes are missing
-
formatRequiredAttributesMessage
-