Package net.bmahe.genetics4j.gp
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()
.
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprivate
ImmutableOperation
(String name, Iterable<? extends Class> acceptedTypes, Class returnedType, BiFunction<T[], Object[], Object> compute) private
ImmutableOperation
(String name, List<Class> acceptedTypes, Class returnedType, BiFunction<T[], Object[], Object> compute, String prettyName) private
ImmutableOperation
(ImmutableOperation.Builder<T> builder) -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> ImmutableOperation.Builder
<T> builder()
Creates a builder forImmutableOperation
.BiFunction
<T[], Object[], Object> compute()
static <T> ImmutableOperation
<T> Creates an immutable copy of aOperation
value.private static <T> List
<T> createSafeList
(Iterable<? extends T> iterable, boolean checkNulls, boolean skipNulls) private static <T> List
<T> createUnmodifiableList
(boolean clone, List<T> list) boolean
This instance is equal to all instances ofImmutableOperation
that have equal attribute values.private boolean
equalTo
(int synthetic, ImmutableOperation<?> another) getName()
int
hashCode()
Computes a hash code from attributes:name
,acceptedTypes
,returnedType
,prettyName
.static <T> ImmutableOperation
<T> of
(String name, Iterable<? extends Class> acceptedTypes, Class returnedType, BiFunction<T[], Object[], Object> compute) Construct a new immutableOperation
instance.static <T> ImmutableOperation
<T> of
(String name, List<Class> acceptedTypes, Class returnedType, BiFunction<T[], Object[], Object> compute) Construct a new immutableOperation
instance.toString()
Prints the immutable valueOperation
with 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 thecompute
attribute.final ImmutableOperation
<T> Copy the current immutable object by setting a value for thename
attribute.final ImmutableOperation
<T> withPrettyName
(String value) Copy the current immutable object by setting a value for theprettyName
attribute.final ImmutableOperation
<T> withReturnedType
(Class value) Copy the current immutable object by setting a value for thereturnedType
attribute.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
-
acceptedTypes
- Specified by:
acceptedTypes
in classOperation<T>
- Returns:
- The value of the
acceptedTypes
attribute
-
returnedType
- Specified by:
returnedType
in classOperation<T>
- Returns:
- The value of the
returnedType
attribute
-
compute
-
getPrettyName
- Overrides:
getPrettyName
in classOperation<T>
- Returns:
- The value of the
prettyName
attribute
-
withName
Copy the current immutable object by setting a value for thename
attribute. An equals check used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for name- Returns:
- A modified copy of the
this
object
-
withAcceptedTypes
Copy the current immutable object with elements that replace the content ofacceptedTypes
.- Parameters:
elements
- The elements to set- Returns:
- A modified copy of
this
object
-
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 of
this
object
-
withReturnedType
Copy the current immutable object by setting a value for thereturnedType
attribute. 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 of the
this
object
-
withCompute
Copy the current immutable object by setting a value for thecompute
attribute. 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 of the
this
object
-
withPrettyName
Copy the current immutable object by setting a value for theprettyName
attribute. An equals check used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for prettyName- Returns:
- A modified copy of the
this
object
-
equals
This instance is equal to all instances ofImmutableOperation
that have equal attribute values. -
equalTo
-
hashCode
public int hashCode()Computes a hash code from attributes:name
,acceptedTypes
,returnedType
,prettyName
. -
toString
Prints the immutable valueOperation
with attribute values. -
of
public static <T> ImmutableOperation<T> of(String name, List<Class> acceptedTypes, Class returnedType, BiFunction<T[], Object[], Object> compute) Construct a new immutableOperation
instance.- Type Parameters:
T
- generic parameter T- Parameters:
name
- The value for thename
attributeacceptedTypes
- The value for theacceptedTypes
attributereturnedType
- The value for thereturnedType
attributecompute
- The value for thecompute
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 immutableOperation
instance.- Type Parameters:
T
- generic parameter T- Parameters:
name
- The value for thename
attributeacceptedTypes
- The value for theacceptedTypes
attributereturnedType
- The value for thereturnedType
attributecompute
- The value for thecompute
attribute- Returns:
- An immutable Operation instance
-
copyOf
Creates an immutable copy of aOperation
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
Creates a builder forImmutableOperation
.ImmutableOperation.<T>builder() .name(String) // required
name
.addAcceptedTypes|addAllAcceptedTypes(Class) //acceptedTypes
elements .returnedType(Class) // requiredreturnedType
.compute(function.BiFunction<T[], Object[], Object>) // requiredcompute
.prettyName(String) // optionalprettyName
.build();- Type Parameters:
T
- generic parameter T- Returns:
- A new ImmutableOperation builder
-
createSafeList
-
createUnmodifiableList
-