Package net.bmahe.genetics4j.gp
Class ImmutableOperation<T>
java.lang.Object
net.bmahe.genetics4j.gp.Operation<T>
net.bmahe.genetics4j.gp.ImmutableOperation<T>
@Generated(from="Operation",
generator="Immutables")
@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().
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateImmutableOperation(String name, Iterable<? extends Class> acceptedTypes, Class returnedType, BiFunction<T[], Object[], Object> compute) privateImmutableOperation(String name, List<Class> acceptedTypes, Class returnedType, BiFunction<T[], Object[], Object> compute, String prettyName) privateImmutableOperation(ImmutableOperation.Builder<T> builder) -
Method Summary
Modifier and TypeMethodDescriptionReturns the list of types that this operation accepts as arguments.static <T> ImmutableOperation.Builder<T> builder()Creates a builder forOperation.BiFunction<T[], Object[], Object> compute()Returns the computation function for this operation.static <T> Operation<T> Creates an immutable copy of aOperationvalue.private static <T> List<T> createSafeList(Iterable<? extends T> iterable, boolean checkNulls, boolean skipNulls) private static <T> List<T> createUnmodifiableList(boolean clone, List<? extends T> list) booleanThis instance is equal to all instances ofImmutableOperationthat have equal attribute values.private booleanequalsByValue(ImmutableOperation<?> another) getName()Returns the name of this operation.Returns a human-readable name for this operation.inthashCode()Computes a hash code from attributes:name,acceptedTypes,returnedType,prettyName.static <T> Operation<T> of(String name, Iterable<? extends Class> acceptedTypes, Class returnedType, BiFunction<T[], Object[], Object> compute) Construct a new immutableOperationinstance.static <T> Operation<T> of(String name, List<Class> acceptedTypes, Class returnedType, BiFunction<T[], Object[], Object> compute) Construct a new immutableOperationinstance.Returns the type that this operation returns.toString()Prints the immutable valueOperationwith attribute values.final ImmutableOperation<T> withAcceptedTypes(Class... elements) Copy the current immutable object with elements that replace the content ofacceptedTypes.final ImmutableOperation<T> withAcceptedTypes(Iterable<? extends Class> elements) Copy the current immutable object with elements that replace the content ofacceptedTypes.final ImmutableOperation<T> withCompute(BiFunction<T[], Object[], Object> value) Copy the current immutable object by setting a value for thecomputeattribute.final ImmutableOperation<T> Copy the current immutable object by setting a value for thenameattribute.final ImmutableOperation<T> withPrettyName(String value) Copy the current immutable object by setting a value for theprettyNameattribute.final ImmutableOperation<T> withReturnedType(Class value) Copy the current immutable object by setting a value for thereturnedTypeattribute.Methods inherited from class net.bmahe.genetics4j.gp.Operation
apply, getArity, isTerminal
-
Field Details
-
name
-
acceptedTypes
-
returnedType
-
compute
-
prettyName
-
-
Constructor Details
-
ImmutableOperation
-
ImmutableOperation
-
ImmutableOperation
-
-
Method Details
-
getName
Returns the name of this operation. -
acceptedTypes
Returns the list of types that this operation accepts as arguments.For strongly-typed genetic programming, this defines the type constraints for each argument position. The list size determines the operation's arity.
- Specified by:
acceptedTypesin classOperation<T>- Returns:
- the list of accepted argument types, empty for terminals
-
returnedType
Returns the type that this operation returns.- Specified by:
returnedTypein classOperation<T>- Returns:
- the return type of this operation
-
compute
Returns the computation function for this operation. -
getPrettyName
Returns a human-readable name for this operation.By default, this returns the same value as
getName(), but can be overridden to provide more descriptive names for display purposes.- Overrides:
getPrettyNamein classOperation<T>- Returns:
- the pretty name for display purposes
-
withName
Copy the current immutable object by setting a value for thenameattribute. An equals check used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for name- Returns:
- A modified copy or the
thisobject
-
withAcceptedTypes
Copy the current immutable object with elements that replace the content ofacceptedTypes.- Parameters:
elements- The elements to set- Returns:
- A modified copy of
thisobject
-
withAcceptedTypes
Copy the current immutable object with elements that replace the content ofacceptedTypes. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
elements- An iterable of acceptedTypes elements to set- Returns:
- A modified copy or
thisif not changed
-
withReturnedType
Copy the current immutable object by setting a value for thereturnedTypeattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for returnedType- Returns:
- A modified copy or the
thisobject
-
withCompute
Copy the current immutable object by setting a value for thecomputeattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for compute- Returns:
- A modified copy or the
thisobject
-
withPrettyName
Copy the current immutable object by setting a value for theprettyNameattribute. An equals check used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for prettyName- Returns:
- A modified copy or the
thisobject
-
equals
This instance is equal to all instances ofImmutableOperationthat have equal attribute values. -
equalsByValue
-
hashCode
public int hashCode()Computes a hash code from attributes:name,acceptedTypes,returnedType,prettyName. -
toString
Prints the immutable valueOperationwith attribute values. -
of
public static <T> Operation<T> of(String name, List<Class> acceptedTypes, Class returnedType, BiFunction<T[], Object[], Object> compute) Construct a new immutableOperationinstance.- Type Parameters:
T- generic parameter T- Parameters:
name- The value for thenameattributeacceptedTypes- The value for theacceptedTypesattributereturnedType- The value for thereturnedTypeattributecompute- The value for thecomputeattribute- Returns:
- An immutable Operation instance
-
of
public static <T> Operation<T> of(String name, Iterable<? extends Class> acceptedTypes, Class returnedType, BiFunction<T[], Object[], Object> compute) Construct a new immutableOperationinstance.- Type Parameters:
T- generic parameter T- Parameters:
name- The value for thenameattributeacceptedTypes- The value for theacceptedTypesattributereturnedType- The value for thereturnedTypeattributecompute- The value for thecomputeattribute- Returns:
- An immutable Operation instance
-
copyOf
Creates an immutable copy of aOperationvalue. 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
Creates a builder forOperation.ImmutableOperation.<T>builder() .name(String) // requiredname.addAcceptedTypes|addAllAcceptedTypes(Class) //acceptedTypeselements .returnedType(Class) // requiredreturnedType.compute(function.BiFunction<T[], Object[], Object>) // requiredcompute.prettyName(String) // optionalprettyName.build();- Type Parameters:
T- generic parameter T- Returns:
- A new Operation builder
-
createSafeList
-
createUnmodifiableList
-