Package net.bmahe.genetics4j.core
Class ImmutableIndividual<T extends Comparable<T>>
java.lang.Object
net.bmahe.genetics4j.core.ImmutableIndividual<T>
- All Implemented Interfaces:
Individual<T>
@Generated(from="Individual",
generator="Immutables")
@Generated("org.immutables.processor.ProxyProcessor")
public final class ImmutableIndividual<T extends Comparable<T>>
extends Object
implements Individual<T>
Immutable implementation of
Individual.
Use the builder to create immutable instances:
ImmutableIndividual.builder().
Use the static factory method to create immutable instances:
ImmutableIndividual.of().
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classImmutableIndividual.Builder<T extends Comparable<T>>Builds instances of typeIndividual. -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateImmutableIndividual(Genotype genotype, T fitness) privateImmutableIndividual(ImmutableIndividual<T> original, Genotype genotype, T fitness) -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Comparable<T>>
ImmutableIndividual.Builder<T> builder()Creates a builder forIndividual.static <T extends Comparable<T>>
Individual<T> copyOf(Individual<T> instance) Creates an immutable copy of aIndividualvalue.booleanThis instance is equal to all instances ofImmutableIndividualthat have equal attribute values.private booleanequalsByValue(ImmutableIndividual<?> another) fitness()Returns the fitness value of this individual.genotype()Returns the genotype of this individual.inthashCode()Computes a hash code from attributes:genotype,fitness.static <T extends Comparable<T>>
Individual<T> Construct a new immutableIndividualinstance.toString()Prints the immutable valueIndividualwith attribute values.final ImmutableIndividual<T> withFitness(T value) Copy the current immutable object by setting a value for thefitnessattribute.final ImmutableIndividual<T> withGenotype(Genotype value) Copy the current immutable object by setting a value for thegenotypeattribute.
-
Field Details
-
genotype
-
fitness
-
-
Constructor Details
-
ImmutableIndividual
-
ImmutableIndividual
-
-
Method Details
-
genotype
Returns the genotype of this individual.- Specified by:
genotypein interfaceIndividual<T extends Comparable<T>>- Returns:
- the genetic representation containing chromosomes that define this individual's traits
-
fitness
Returns the fitness value of this individual.- Specified by:
fitnessin interfaceIndividual<T extends Comparable<T>>- Returns:
- the evaluated performance or quality measure of this individual's genotype
-
withGenotype
Copy the current immutable object by setting a value for thegenotypeattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for genotype- 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
-
equals
This instance is equal to all instances ofImmutableIndividualthat have equal attribute values. -
equalsByValue
-
hashCode
public int hashCode()Computes a hash code from attributes:genotype,fitness. -
toString
Prints the immutable valueIndividualwith attribute values. -
of
Construct a new immutableIndividualinstance.- Type Parameters:
T- generic parameter T- Parameters:
genotype- The value for thegenotypeattributefitness- The value for thefitnessattribute- Returns:
- An immutable Individual instance
-
copyOf
Creates an immutable copy of aIndividualvalue. 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 Individual instance
-
builder
Creates a builder forIndividual.ImmutableIndividual.<T>builder() .genotype(net.bmahe.genetics4j.core.Genotype) // requiredgenotype.fitness(T) // requiredfitness.build();- Type Parameters:
T- generic parameter T- Returns:
- A new Individual builder
-