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("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
Modifier and TypeClassDescriptionstatic final class
ImmutableIndividual.Builder<T extends Comparable<T>>
Builds instances of typeImmutableIndividual
. -
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprivate
ImmutableIndividual
(Genotype genotype, T fitness) private
ImmutableIndividual
(ImmutableIndividual<T> original, Genotype genotype, T fitness) -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Comparable<T>>
ImmutableIndividual.Builder<T> builder()
Creates a builder forImmutableIndividual
.static <T extends Comparable<T>>
ImmutableIndividual<T> copyOf
(Individual<T> instance) Creates an immutable copy of aIndividual
value.boolean
This instance is equal to all instances ofImmutableIndividual
that have equal attribute values.private boolean
equalTo
(int synthetic, ImmutableIndividual<?> another) fitness()
genotype()
int
hashCode()
Computes a hash code from attributes:genotype
,fitness
.static <T extends Comparable<T>>
ImmutableIndividual<T> Construct a new immutableIndividual
instance.toString()
Prints the immutable valueIndividual
with attribute values.final ImmutableIndividual
<T> withFitness
(T value) Copy the current immutable object by setting a value for thefitness
attribute.final ImmutableIndividual
<T> withGenotype
(Genotype value) Copy the current immutable object by setting a value for thegenotype
attribute.
-
Field Details
-
genotype
-
fitness
-
-
Constructor Details
-
ImmutableIndividual
-
ImmutableIndividual
-
-
Method Details
-
genotype
- Specified by:
genotype
in interfaceIndividual<T extends Comparable<T>>
- Returns:
- The value of the
genotype
attribute
-
fitness
- Specified by:
fitness
in interfaceIndividual<T extends Comparable<T>>
- Returns:
- The value of the
fitness
attribute
-
withGenotype
Copy the current immutable object by setting a value for thegenotype
attribute. 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 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
-
equals
This instance is equal to all instances ofImmutableIndividual
that have equal attribute values. -
equalTo
-
hashCode
public int hashCode()Computes a hash code from attributes:genotype
,fitness
. -
toString
Prints the immutable valueIndividual
with attribute values. -
of
Construct a new immutableIndividual
instance.- Type Parameters:
T
- generic parameter T- Parameters:
genotype
- The value for thegenotype
attributefitness
- The value for thefitness
attribute- Returns:
- An immutable Individual instance
-
copyOf
Creates an immutable copy of aIndividual
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 Individual instance
-
builder
Creates a builder forImmutableIndividual
.ImmutableIndividual.<T>builder() .genotype(net.bmahe.genetics4j.core.Genotype) // required
genotype
.fitness(T) // requiredfitness
.build();- Type Parameters:
T
- generic parameter T- Returns:
- A new ImmutableIndividual builder
-