Class ImmutableOperation<T>

java.lang.Object
net.bmahe.genetics4j.gp.Operation<T>
net.bmahe.genetics4j.gp.ImmutableOperation<T>

@Generated("org.immutables.processor.ProxyProcessor") public final class ImmutableOperation<T> extends Operation<T>
Immutable implementation of Operation.

Use the builder to create immutable instances: ImmutableOperation.builder(). Use the static factory method to create immutable instances: ImmutableOperation.of().

  • Field Details

    • name

      private final String name
    • acceptedTypes

      private final List<Class> acceptedTypes
    • returnedType

      private final Class returnedType
    • compute

      private final BiFunction<T[],Object[],Object> compute
    • prettyName

      private final String prettyName
  • Constructor Details

  • Method Details

    • getName

      public String getName()
      Specified by:
      getName in class Operation<T>
      Returns:
      The value of the name attribute
    • acceptedTypes

      public List<Class> acceptedTypes()
      Specified by:
      acceptedTypes in class Operation<T>
      Returns:
      The value of the acceptedTypes attribute
    • returnedType

      public Class returnedType()
      Specified by:
      returnedType in class Operation<T>
      Returns:
      The value of the returnedType attribute
    • compute

      public BiFunction<T[],Object[],Object> compute()
      Specified by:
      compute in class Operation<T>
      Returns:
      The value of the compute attribute
    • getPrettyName

      public String getPrettyName()
      Overrides:
      getPrettyName in class Operation<T>
      Returns:
      The value of the prettyName attribute
    • withName

      public final ImmutableOperation<T> withName(String value)
      Copy the current immutable object by setting a value for the name attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for name
      Returns:
      A modified copy of the this object
    • withAcceptedTypes

      public final ImmutableOperation<T> withAcceptedTypes(Class... elements)
      Copy the current immutable object with elements that replace the content of acceptedTypes.
      Parameters:
      elements - The elements to set
      Returns:
      A modified copy of this object
    • withAcceptedTypes

      public final ImmutableOperation<T> withAcceptedTypes(Iterable<? extends Class> elements)
      Copy the current immutable object with elements that replace the content of acceptedTypes. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      elements - An iterable of acceptedTypes elements to set
      Returns:
      A modified copy of this object
    • withReturnedType

      public final ImmutableOperation<T> withReturnedType(Class value)
      Copy the current immutable object by setting a value for the returnedType attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for returnedType
      Returns:
      A modified copy of the this object
    • withCompute

      public final ImmutableOperation<T> withCompute(BiFunction<T[],Object[],Object> value)
      Copy the current immutable object by setting a value for the compute attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for compute
      Returns:
      A modified copy of the this object
    • withPrettyName

      public final ImmutableOperation<T> withPrettyName(String value)
      Copy the current immutable object by setting a value for the prettyName attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for prettyName
      Returns:
      A modified copy of the this object
    • equals

      public boolean equals(Object another)
      This instance is equal to all instances of ImmutableOperation that have equal attribute values.
      Overrides:
      equals in class Object
      Returns:
      true if this is equal to another instance
    • equalTo

      private boolean equalTo(int synthetic, ImmutableOperation<?> another)
    • hashCode

      public int hashCode()
      Computes a hash code from attributes: name, acceptedTypes, returnedType, prettyName.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

      public String toString()
      Prints the immutable value Operation with attribute values.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the value
    • of

      public static <T> ImmutableOperation<T> of(String name, List<Class> acceptedTypes, Class returnedType, BiFunction<T[],Object[],Object> compute)
      Construct a new immutable Operation instance.
      Type Parameters:
      T - generic parameter T
      Parameters:
      name - The value for the name attribute
      acceptedTypes - The value for the acceptedTypes attribute
      returnedType - The value for the returnedType attribute
      compute - The value for the compute attribute
      Returns:
      An immutable Operation instance
    • of

      public static <T> ImmutableOperation<T> of(String name, Iterable<? extends Class> acceptedTypes, Class returnedType, BiFunction<T[],Object[],Object> compute)
      Construct a new immutable Operation instance.
      Type Parameters:
      T - generic parameter T
      Parameters:
      name - The value for the name attribute
      acceptedTypes - The value for the acceptedTypes attribute
      returnedType - The value for the returnedType attribute
      compute - The value for the compute attribute
      Returns:
      An immutable Operation instance
    • copyOf

      public static <T> ImmutableOperation<T> copyOf(Operation<T> instance)
      Creates an immutable copy of a Operation value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.
      Type Parameters:
      T - generic parameter T
      Parameters:
      instance - The instance to copy
      Returns:
      A copied immutable Operation instance
    • builder

      public static <T> ImmutableOperation.Builder<T> builder()
      Creates a builder for ImmutableOperation.
       ImmutableOperation.&lt;T&gt;builder()
          .name(String) // required name
          .addAcceptedTypes|addAllAcceptedTypes(Class) // acceptedTypes elements
          .returnedType(Class) // required returnedType
          .compute(function.BiFunction&lt;T[], Object[], Object&gt;) // required compute
          .prettyName(String) // optional prettyName
          .build();
       
      Type Parameters:
      T - generic parameter T
      Returns:
      A new ImmutableOperation builder
    • createSafeList

      private static <T> List<T> createSafeList(Iterable<? extends T> iterable, boolean checkNulls, boolean skipNulls)
    • createUnmodifiableList

      private static <T> List<T> createUnmodifiableList(boolean clone, List<T> list)