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(from="EvolutionResult",
generator="Immutables")
@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
Nested ClassesModifier and TypeClassDescriptionstatic final classImmutableEvolutionResult.Builder<T extends Comparable<T>>Builds instances of typeEvolutionResult. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final GenotypeFitness<T> private final AbstractEAConfiguration<T> private final long -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateImmutableEvolutionResult(AbstractEAConfiguration<T> eaConfiguration, long generation, Iterable<? extends Genotype> population, Iterable<? extends T> fitness) privateImmutableEvolutionResult(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 forEvolutionResult.static <T extends Comparable<T>>
EvolutionResult<T> copyOf(EvolutionResult<T> instance) Creates an immutable copy of aEvolutionResultvalue.private static <T> List<T> createSafeList(Iterable<? extends T> iterable, boolean checkNulls, boolean skipNulls) private static <T> List<T> createUnmodifiableList(boolean clone, List<? extends T> list) booleanThis instance is equal to all instances ofImmutableEvolutionResultthat have equal attribute values.private booleanequalsByValue(ImmutableEvolutionResult<?> another) fitness()longinthashCode()Computes a hash code from attributes:eaConfiguration,generation,population,fitness,bestIndividual.static <T extends Comparable<T>>
EvolutionResult<T> of(AbstractEAConfiguration<T> eaConfiguration, long generation, Iterable<? extends Genotype> population, Iterable<? extends T> fitness) Construct a new immutableEvolutionResultinstance.static <T extends Comparable<T>>
EvolutionResult<T> of(AbstractEAConfiguration<T> eaConfiguration, long generation, List<Genotype> population, List<T> fitness) Construct a new immutableEvolutionResultinstance.toString()Prints the immutable valueEvolutionResultwith attribute values.final ImmutableEvolutionResult<T> Copy the current immutable object by setting a value for theeaConfigurationattribute.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 thegenerationattribute.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:
eaConfigurationin classEvolutionResult<T extends Comparable<T>>- Returns:
- The value of the
eaConfigurationattribute
-
generation
public long generation()- Specified by:
generationin classEvolutionResult<T extends Comparable<T>>- Returns:
- The value of the
generationattribute
-
population
- Specified by:
populationin classEvolutionResult<T extends Comparable<T>>- Returns:
- The value of the
populationattribute
-
fitness
- Specified by:
fitnessin classEvolutionResult<T extends Comparable<T>>- Returns:
- The value of the
fitnessattribute
-
bestIndividual
- Overrides:
bestIndividualin classEvolutionResult<T extends Comparable<T>>- Returns:
- The computed-at-construction value of the
bestIndividualattribute
-
withEaConfiguration
Copy the current immutable object by setting a value for theeaConfigurationattribute. 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 or the
thisobject
-
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
-
withPopulation
Copy the current immutable object with elements that replace the content ofpopulation.- Parameters:
elements- The elements to set- Returns:
- A modified copy of
thisobject
-
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 or
thisif not changed
-
withFitness
Copy the current immutable object with elements that replace the content offitness.- Parameters:
elements- The elements to set- Returns:
- A modified copy of
thisobject
-
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 or
thisif not changed
-
equals
This instance is equal to all instances ofImmutableEvolutionResultthat have equal attribute values. -
equalsByValue
-
hashCode
public int hashCode()Computes a hash code from attributes:eaConfiguration,generation,population,fitness,bestIndividual. -
toString
Prints the immutable valueEvolutionResultwith attribute values. -
of
public static <T extends Comparable<T>> EvolutionResult<T> of(AbstractEAConfiguration<T> eaConfiguration, long generation, List<Genotype> population, List<T> fitness) Construct a new immutableEvolutionResultinstance.- Type Parameters:
T- generic parameter T- Parameters:
eaConfiguration- The value for theeaConfigurationattributegeneration- The value for thegenerationattributepopulation- The value for thepopulationattributefitness- The value for thefitnessattribute- Returns:
- An immutable EvolutionResult instance
-
of
public static <T extends Comparable<T>> EvolutionResult<T> of(AbstractEAConfiguration<T> eaConfiguration, long generation, Iterable<? extends Genotype> population, Iterable<? extends T> fitness) Construct a new immutableEvolutionResultinstance.- Type Parameters:
T- generic parameter T- Parameters:
eaConfiguration- The value for theeaConfigurationattributegeneration- The value for thegenerationattributepopulation- The value for thepopulationattributefitness- The value for thefitnessattribute- Returns:
- An immutable EvolutionResult instance
-
copyOf
Creates an immutable copy of aEvolutionResultvalue. 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 forEvolutionResult.ImmutableEvolutionResult.<T>builder() .eaConfiguration(net.bmahe.genetics4j.core.spec.AbstractEAConfiguration<T>) // requiredeaConfiguration.generation(long) // requiredgeneration.addPopulation|addAllPopulation(net.bmahe.genetics4j.core.Genotype) //populationelements .addFitness|addAllFitness(T) //fitnesselements .build();- Type Parameters:
T- generic parameter T- Returns:
- A new EvolutionResult builder
-
createSafeList
-
createUnmodifiableList
-