Class ImmutableOperation.Builder<T>

java.lang.Object
net.bmahe.genetics4j.gp.ImmutableOperation.Builder<T>
Enclosing class:
ImmutableOperation<T>

public static final class ImmutableOperation.Builder<T> extends Object
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 Details

  • Constructor Details

    • Builder

      private Builder()
  • Method Details

    • from

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

      public final ImmutableOperation.Builder<T> name(String name)
      Initializes the value for the name attribute.
      Parameters:
      name - The value for name
      Returns:
      this builder for use in a chained invocation
    • addAcceptedTypes

      public final ImmutableOperation.Builder<T> addAcceptedTypes(Class element)
      Adds one element to acceptedTypes list.
      Parameters:
      element - A acceptedTypes element
      Returns:
      this builder for use in a chained invocation
    • addAcceptedTypes

      public final ImmutableOperation.Builder<T> addAcceptedTypes(Class... elements)
      Adds elements to acceptedTypes list.
      Parameters:
      elements - An array of acceptedTypes elements
      Returns:
      this builder for use in a chained invocation
    • acceptedTypes

      public final ImmutableOperation.Builder<T> acceptedTypes(Iterable<? extends Class> elements)
      Sets or replaces all elements for acceptedTypes list.
      Parameters:
      elements - An iterable of acceptedTypes elements
      Returns:
      this builder for use in a chained invocation
    • addAllAcceptedTypes

      public final ImmutableOperation.Builder<T> addAllAcceptedTypes(Iterable<? extends Class> elements)
      Adds elements to acceptedTypes list.
      Parameters:
      elements - An iterable of acceptedTypes elements
      Returns:
      this builder for use in a chained invocation
    • returnedType

      public final ImmutableOperation.Builder<T> returnedType(Class returnedType)
      Initializes the value for the returnedType attribute.
      Parameters:
      returnedType - The value for returnedType
      Returns:
      this builder for use in a chained invocation
    • compute

      public final ImmutableOperation.Builder<T> compute(BiFunction<T[],Object[],Object> compute)
      Initializes the value for the compute attribute.
      Parameters:
      compute - The value for compute
      Returns:
      this builder for use in a chained invocation
    • prettyName

      public final ImmutableOperation.Builder<T> prettyName(String prettyName)
      Initializes the value for the prettyName 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

      public ImmutableOperation<T> build()
      Builds a new ImmutableOperation.
      Returns:
      An immutable instance of Operation
      Throws:
      IllegalStateException - if any required attributes are missing
    • formatRequiredAttributesMessage

      private String formatRequiredAttributesMessage()