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(from="EvolutionStep",
generator="Immutables")
@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
Nested ClassesModifier and TypeClassDescriptionstatic classImmutableEvolutionStep.Builder<T extends Comparable<T>,U> Builds instances of typeEvolutionStep. -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateImmutableEvolutionStep(Optional<? extends U> context, long generation, int individualIndex, Genotype individual, T fitness, boolean isDone) privateImmutableEvolutionStep(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>
EvolutionStep<T, U> copyOf(EvolutionStep<T, U> instance) Creates an immutable copy of aEvolutionStepvalue.booleanThis instance is equal to all instances ofImmutableEvolutionStepthat have equal attribute values.private booleanequalsByValue(ImmutableEvolutionStep<?, ?> another) fitness()longinthashCode()Computes a hash code from attributes:context,generation,individualIndex,individual,fitness,isDone.intbooleanisDone()static <T extends Comparable<T>,U>
EvolutionStep<T, U> of(Optional<? extends U> context, long generation, int individualIndex, Genotype individual, T fitness, boolean isDone) Construct a new immutableEvolutionStepinstance.toString()Prints the immutable valueEvolutionStepwith attribute values.final ImmutableEvolutionStep<T, U> withContext(Optional<? extends U> optional) Copy the current immutable object by setting an optional value for thecontextattribute.final ImmutableEvolutionStep<T, U> withContext(U value) Copy the current immutable object by setting a present value for the optionalcontextattribute.final ImmutableEvolutionStep<T, U> withFitness(T value) Copy the current immutable object by setting a value for thefitnessattribute.final ImmutableEvolutionStep<T, U> withGeneration(long value) Copy the current immutable object by setting a value for thegenerationattribute.final ImmutableEvolutionStep<T, U> withIndividual(Genotype value) Copy the current immutable object by setting a value for theindividualattribute.final ImmutableEvolutionStep<T, U> withIndividualIndex(int value) Copy the current immutable object by setting a value for theindividualIndexattribute.final ImmutableEvolutionStep<T, U> withIsDone(boolean value) Copy the current immutable object by setting a value for theisDoneattribute.
-
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:
contextin interfaceEvolutionStep<T extends Comparable<T>,U> - Returns:
- The value of the
contextattribute
-
generation
public long generation()- Specified by:
generationin interfaceEvolutionStep<T extends Comparable<T>,U> - Returns:
- The value of the
generationattribute
-
individualIndex
public int individualIndex()- Specified by:
individualIndexin interfaceEvolutionStep<T extends Comparable<T>,U> - Returns:
- The value of the
individualIndexattribute
-
individual
- Specified by:
individualin interfaceEvolutionStep<T extends Comparable<T>,U> - Returns:
- The value of the
individualattribute
-
fitness
- Specified by:
fitnessin interfaceEvolutionStep<T extends Comparable<T>,U> - Returns:
- The value of the
fitnessattribute
-
isDone
public boolean isDone()- Specified by:
isDonein interfaceEvolutionStep<T extends Comparable<T>,U> - Returns:
- The value of the
isDoneattribute
-
withContext
Copy the current immutable object by setting a present value for the optionalcontextattribute.- Parameters:
value- The value for context- Returns:
- A modified copy or
thisif not changed
-
withContext
Copy the current immutable object by setting an optional value for thecontextattribute. A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returningthis.- Parameters:
optional- An optional value for context- Returns:
- A modified copy or
thisif not changed
-
withGeneration
Copy the current immutable object by setting a value for thegenerationattribute. 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 or the
thisobject
-
withIndividualIndex
Copy the current immutable object by setting a value for theindividualIndexattribute. 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 or the
thisobject
-
withIndividual
Copy the current immutable object by setting a value for theindividualattribute. 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 or the
thisobject
-
withFitness
Copy the current immutable object by setting a value for thefitnessattribute. 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 or the
thisobject
-
withIsDone
Copy the current immutable object by setting a value for theisDoneattribute. 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 or the
thisobject
-
equals
This instance is equal to all instances ofImmutableEvolutionStepthat have equal attribute values. -
equalsByValue
-
hashCode
public int hashCode()Computes a hash code from attributes:context,generation,individualIndex,individual,fitness,isDone. -
toString
Prints the immutable valueEvolutionStepwith attribute values. -
of
public static <T extends Comparable<T>,U> EvolutionStep<T,U> of(Optional<? extends U> context, long generation, int individualIndex, Genotype individual, T fitness, boolean isDone) Construct a new immutableEvolutionStepinstance.- Type Parameters:
T- generic parameter TU- generic parameter U- Parameters:
context- The value for thecontextattributegeneration- The value for thegenerationattributeindividualIndex- The value for theindividualIndexattributeindividual- The value for theindividualattributefitness- The value for thefitnessattributeisDone- The value for theisDoneattribute- Returns:
- An immutable EvolutionStep instance
-
copyOf
Creates an immutable copy of aEvolutionStepvalue. 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
-