Class ImmutableConnection.Builder

java.lang.Object
net.bmahe.genetics4j.neat.ImmutableConnection.Builder
Direct Known Subclasses:
Connection.Builder
Enclosing class:
ImmutableConnection

public static class ImmutableConnection.Builder extends Object
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 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

  • Method Details

    • from

      public final Connection.Builder from(Connection instance)
      Fill a builder with attribute values from the provided Connection 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

      public final Connection.Builder fromNodeIndex(int fromNodeIndex)
      Initializes the value for the fromNodeIndex attribute.
      Parameters:
      fromNodeIndex - The value for fromNodeIndex
      Returns:
      this builder for use in a chained invocation
    • toNodeIndex

      public final Connection.Builder toNodeIndex(int toNodeIndex)
      Initializes the value for the toNodeIndex attribute.
      Parameters:
      toNodeIndex - The value for toNodeIndex
      Returns:
      this builder for use in a chained invocation
    • weight

      public final Connection.Builder weight(float weight)
      Initializes the value for the weight attribute.
      Parameters:
      weight - The value for weight
      Returns:
      this builder for use in a chained invocation
    • isEnabled

      public final Connection.Builder isEnabled(boolean isEnabled)
      Initializes the value for the isEnabled attribute.
      Parameters:
      isEnabled - The value for isEnabled
      Returns:
      this builder for use in a chained invocation
    • innovation

      public final Connection.Builder innovation(int innovation)
      Initializes the value for the innovation attribute.
      Parameters:
      innovation - The value for innovation
      Returns:
      this builder for use in a chained invocation
    • build

      public ImmutableConnection build()
      Builds a new ImmutableConnection.
      Returns:
      An immutable instance of Connection
      Throws:
      IllegalStateException - if any required attributes are missing
    • formatRequiredAttributesMessage

      private String formatRequiredAttributesMessage()