Package net.bmahe.genetics4j.core.spec
Class ImmutableEvolutionResult<T extends Comparable<T>>
java.lang.Object
net.bmahe.genetics4j.core.spec.EvolutionResult<T>
net.bmahe.genetics4j.core.spec.ImmutableEvolutionResult<T>
@Generated("org.immutables.processor.ProxyProcessor")
public final class ImmutableEvolutionResult<T extends Comparable<T>>
extends EvolutionResult<T>
Immutable implementation of
EvolutionResult
.
Use the builder to create immutable instances:
ImmutableEvolutionResult.builder()
.
Use the static factory method to create immutable instances:
ImmutableEvolutionResult.of()
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
ImmutableEvolutionResult.Builder<T extends Comparable<T>>
Builds instances of typeImmutableEvolutionResult
. -
Field Summary
Modifier and TypeFieldDescriptionprivate final GenotypeFitness
<T> private final AbstractEAConfiguration
<T> private final long
-
Constructor Summary
ModifierConstructorDescriptionprivate
ImmutableEvolutionResult
(AbstractEAConfiguration<T> eaConfiguration, long generation, Iterable<? extends Genotype> population, Iterable<? extends T> fitness) private
ImmutableEvolutionResult
(ImmutableEvolutionResult<T> original, AbstractEAConfiguration<T> eaConfiguration, long generation, List<Genotype> population, List<T> fitness) -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Comparable<T>>
ImmutableEvolutionResult.Builder<T> builder()
Creates a builder forImmutableEvolutionResult
.static <T extends Comparable<T>>
ImmutableEvolutionResult<T> copyOf
(EvolutionResult<T> instance) Creates an immutable copy of aEvolutionResult
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 ofImmutableEvolutionResult
that have equal attribute values.private boolean
equalTo
(int synthetic, ImmutableEvolutionResult<?> another) fitness()
long
int
hashCode()
Computes a hash code from attributes:eaConfiguration
,generation
,population
,fitness
,bestIndividual
.static <T extends Comparable<T>>
ImmutableEvolutionResult<T> of
(AbstractEAConfiguration<T> eaConfiguration, long generation, Iterable<? extends Genotype> population, Iterable<? extends T> fitness) Construct a new immutableEvolutionResult
instance.static <T extends Comparable<T>>
ImmutableEvolutionResult<T> of
(AbstractEAConfiguration<T> eaConfiguration, long generation, List<Genotype> population, List<T> fitness) Construct a new immutableEvolutionResult
instance.toString()
Prints the immutable valueEvolutionResult
with attribute values.final ImmutableEvolutionResult
<T> Copy the current immutable object by setting a value for theeaConfiguration
attribute.final ImmutableEvolutionResult
<T> withFitness
(Iterable<? extends T> elements) Copy the current immutable object with elements that replace the content offitness
.final ImmutableEvolutionResult
<T> withFitness
(T... elements) Copy the current immutable object with elements that replace the content offitness
.final ImmutableEvolutionResult
<T> withGeneration
(long value) Copy the current immutable object by setting a value for thegeneration
attribute.final ImmutableEvolutionResult
<T> withPopulation
(Iterable<? extends Genotype> elements) Copy the current immutable object with elements that replace the content ofpopulation
.final ImmutableEvolutionResult
<T> withPopulation
(Genotype... elements) Copy the current immutable object with elements that replace the content ofpopulation
.Methods inherited from class net.bmahe.genetics4j.core.spec.EvolutionResult
bestFitness, bestGenotype
-
Field Details
-
eaConfiguration
-
generation
private final long generation -
population
-
fitness
-
bestIndividual
-
-
Constructor Details
-
ImmutableEvolutionResult
-
ImmutableEvolutionResult
private ImmutableEvolutionResult(ImmutableEvolutionResult<T> original, AbstractEAConfiguration<T> eaConfiguration, long generation, List<Genotype> population, List<T> fitness)
-
-
Method Details
-
eaConfiguration
- Specified by:
eaConfiguration
in classEvolutionResult<T extends Comparable<T>>
- Returns:
- The value of the
eaConfiguration
attribute
-
generation
public long generation()- Specified by:
generation
in classEvolutionResult<T extends Comparable<T>>
- Returns:
- The value of the
generation
attribute
-
population
- Specified by:
population
in classEvolutionResult<T extends Comparable<T>>
- Returns:
- The value of the
population
attribute
-
fitness
- Specified by:
fitness
in classEvolutionResult<T extends Comparable<T>>
- Returns:
- The value of the
fitness
attribute
-
bestIndividual
- Overrides:
bestIndividual
in classEvolutionResult<T extends Comparable<T>>
- Returns:
- The computed-at-construction value of the
bestIndividual
attribute
-
withEaConfiguration
Copy the current immutable object by setting a value for theeaConfiguration
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for eaConfiguration- Returns:
- A modified copy of the
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
-
withPopulation
Copy the current immutable object with elements that replace the content ofpopulation
.- Parameters:
elements
- The elements to set- Returns:
- A modified copy of
this
object
-
withPopulation
Copy the current immutable object with elements that replace the content ofpopulation
. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
elements
- An iterable of population elements to set- Returns:
- A modified copy of
this
object
-
withFitness
Copy the current immutable object with elements that replace the content offitness
.- Parameters:
elements
- The elements to set- Returns:
- A modified copy of
this
object
-
withFitness
Copy the current immutable object with elements that replace the content offitness
. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
elements
- An iterable of fitness elements to set- Returns:
- A modified copy of
this
object
-
equals
This instance is equal to all instances ofImmutableEvolutionResult
that have equal attribute values. -
equalTo
-
hashCode
public int hashCode()Computes a hash code from attributes:eaConfiguration
,generation
,population
,fitness
,bestIndividual
. -
toString
Prints the immutable valueEvolutionResult
with attribute values. -
of
public static <T extends Comparable<T>> ImmutableEvolutionResult<T> of(AbstractEAConfiguration<T> eaConfiguration, long generation, List<Genotype> population, List<T> fitness) Construct a new immutableEvolutionResult
instance.- Type Parameters:
T
- generic parameter T- Parameters:
eaConfiguration
- The value for theeaConfiguration
attributegeneration
- The value for thegeneration
attributepopulation
- The value for thepopulation
attributefitness
- The value for thefitness
attribute- Returns:
- An immutable EvolutionResult instance
-
of
public static <T extends Comparable<T>> ImmutableEvolutionResult<T> of(AbstractEAConfiguration<T> eaConfiguration, long generation, Iterable<? extends Genotype> population, Iterable<? extends T> fitness) Construct a new immutableEvolutionResult
instance.- Type Parameters:
T
- generic parameter T- Parameters:
eaConfiguration
- The value for theeaConfiguration
attributegeneration
- The value for thegeneration
attributepopulation
- The value for thepopulation
attributefitness
- The value for thefitness
attribute- Returns:
- An immutable EvolutionResult instance
-
copyOf
public static <T extends Comparable<T>> ImmutableEvolutionResult<T> copyOf(EvolutionResult<T> instance) Creates an immutable copy of aEvolutionResult
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 EvolutionResult instance
-
builder
Creates a builder forImmutableEvolutionResult
.ImmutableEvolutionResult.<T>builder() .eaConfiguration(net.bmahe.genetics4j.core.spec.AbstractEAConfiguration<T>) // required
eaConfiguration
.generation(long) // requiredgeneration
.addPopulation|addAllPopulation(net.bmahe.genetics4j.core.Genotype) //population
elements .addFitness|addAllFitness(T) //fitness
elements .build();- Type Parameters:
T
- generic parameter T- Returns:
- A new ImmutableEvolutionResult builder
-
createSafeList
-
createUnmodifiableList
-