Class ImmutableEvolutionStep<T extends Comparable<T>,U>
java.lang.Object
net.bmahe.genetics4j.extras.evolutionlisteners.ImmutableEvolutionStep<T,U>
- All Implemented Interfaces:
EvolutionStep<T,
U>
@Generated("org.immutables.processor.ProxyProcessor")
public final class ImmutableEvolutionStep<T extends Comparable<T>,U>
extends Object
implements EvolutionStep<T,U>
Immutable implementation of
EvolutionStep
.
Use the builder to create immutable instances:
new EvolutionStep.Builder()
.
Use the static factory method to create immutable instances:
ImmutableEvolutionStep.of()
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
ImmutableEvolutionStep.Builder<T extends Comparable<T>,
U> Builds instances of typeImmutableEvolutionStep
. -
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprivate
ImmutableEvolutionStep
(Optional<? extends U> context, long generation, int individualIndex, Genotype individual, T fitness, boolean isDone) private
ImmutableEvolutionStep
(ImmutableEvolutionStep<T, U> original, U context, long generation, int individualIndex, Genotype individual, T fitness, boolean isDone) -
Method Summary
Modifier and TypeMethodDescriptioncontext()
static <T extends Comparable<T>,
U>
ImmutableEvolutionStep<T, U> copyOf
(EvolutionStep<T, U> instance) Creates an immutable copy of aEvolutionStep
value.boolean
This instance is equal to all instances ofImmutableEvolutionStep
that have equal attribute values.private boolean
equalTo
(int synthetic, ImmutableEvolutionStep<?, ?> another) fitness()
long
int
hashCode()
Computes a hash code from attributes:context
,generation
,individualIndex
,individual
,fitness
,isDone
.int
boolean
isDone()
static <T extends Comparable<T>,
U>
ImmutableEvolutionStep<T, U> of
(Optional<? extends U> context, long generation, int individualIndex, Genotype individual, T fitness, boolean isDone) Construct a new immutableEvolutionStep
instance.toString()
Prints the immutable valueEvolutionStep
with attribute values.final ImmutableEvolutionStep
<T, U> withContext
(Optional<? extends U> optional) Copy the current immutable object by setting an optional value for thecontext
attribute.final ImmutableEvolutionStep
<T, U> withContext
(U value) Copy the current immutable object by setting a present value for the optionalcontext
attribute.final ImmutableEvolutionStep
<T, U> withFitness
(T value) Copy the current immutable object by setting a value for thefitness
attribute.final ImmutableEvolutionStep
<T, U> withGeneration
(long value) Copy the current immutable object by setting a value for thegeneration
attribute.final ImmutableEvolutionStep
<T, U> withIndividual
(Genotype value) Copy the current immutable object by setting a value for theindividual
attribute.final ImmutableEvolutionStep
<T, U> withIndividualIndex
(int value) Copy the current immutable object by setting a value for theindividualIndex
attribute.final ImmutableEvolutionStep
<T, U> withIsDone
(boolean value) Copy the current immutable object by setting a value for theisDone
attribute.
-
Field Details
-
context
-
generation
private final long generation -
individualIndex
private final int individualIndex -
individual
-
fitness
-
isDone
private final boolean isDone
-
-
Constructor Details
-
ImmutableEvolutionStep
-
ImmutableEvolutionStep
-
-
Method Details
-
context
- Specified by:
context
in interfaceEvolutionStep<T extends Comparable<T>,
U> - Returns:
- The value of the
context
attribute
-
generation
public long generation()- Specified by:
generation
in interfaceEvolutionStep<T extends Comparable<T>,
U> - Returns:
- The value of the
generation
attribute
-
individualIndex
public int individualIndex()- Specified by:
individualIndex
in interfaceEvolutionStep<T extends Comparable<T>,
U> - Returns:
- The value of the
individualIndex
attribute
-
individual
- Specified by:
individual
in interfaceEvolutionStep<T extends Comparable<T>,
U> - Returns:
- The value of the
individual
attribute
-
fitness
- Specified by:
fitness
in interfaceEvolutionStep<T extends Comparable<T>,
U> - Returns:
- The value of the
fitness
attribute
-
isDone
public boolean isDone()- Specified by:
isDone
in interfaceEvolutionStep<T extends Comparable<T>,
U> - Returns:
- The value of the
isDone
attribute
-
withContext
Copy the current immutable object by setting a present value for the optionalcontext
attribute.- Parameters:
value
- The value for context- Returns:
- A modified copy of
this
object
-
withContext
Copy the current immutable object by setting an optional value for thecontext
attribute. A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returningthis
.- Parameters:
optional
- A value for context- Returns:
- A modified copy of
this
object
-
withGeneration
Copy the current immutable object by setting a value for thegeneration
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for generation- Returns:
- A modified copy of the
this
object
-
withIndividualIndex
Copy the current immutable object by setting a value for theindividualIndex
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for individualIndex- Returns:
- A modified copy of the
this
object
-
withIndividual
Copy the current immutable object by setting a value for theindividual
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for individual- Returns:
- A modified copy of the
this
object
-
withFitness
Copy the current immutable object by setting a value for thefitness
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for fitness- Returns:
- A modified copy of the
this
object
-
withIsDone
Copy the current immutable object by setting a value for theisDone
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for isDone- Returns:
- A modified copy of the
this
object
-
equals
This instance is equal to all instances ofImmutableEvolutionStep
that have equal attribute values. -
equalTo
-
hashCode
public int hashCode()Computes a hash code from attributes:context
,generation
,individualIndex
,individual
,fitness
,isDone
. -
toString
Prints the immutable valueEvolutionStep
with attribute values. -
of
public static <T extends Comparable<T>,U> ImmutableEvolutionStep<T,U> of(Optional<? extends U> context, long generation, int individualIndex, Genotype individual, T fitness, boolean isDone) Construct a new immutableEvolutionStep
instance.- Type Parameters:
T
- generic parameter TU
- generic parameter U- Parameters:
context
- The value for thecontext
attributegeneration
- The value for thegeneration
attributeindividualIndex
- The value for theindividualIndex
attributeindividual
- The value for theindividual
attributefitness
- The value for thefitness
attributeisDone
- The value for theisDone
attribute- Returns:
- An immutable EvolutionStep instance
-
copyOf
public static <T extends Comparable<T>,U> ImmutableEvolutionStep<T,U> copyOf(EvolutionStep<T, U> instance) Creates an immutable copy of aEvolutionStep
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 TU
- generic parameter U- Parameters:
instance
- The instance to copy- Returns:
- A copied immutable EvolutionStep instance
-