Class ImmutableIntChromosomeSpec
java.lang.Object
net.bmahe.genetics4j.core.spec.chromosome.IntChromosomeSpec
net.bmahe.genetics4j.core.spec.chromosome.ImmutableIntChromosomeSpec
- All Implemented Interfaces:
ChromosomeSpec
@Generated(from="IntChromosomeSpec",
generator="Immutables")
@Generated("org.immutables.processor.ProxyProcessor")
public final class ImmutableIntChromosomeSpec
extends IntChromosomeSpec
Immutable implementation of
IntChromosomeSpec.
Use the builder to create immutable instances:
new IntChromosomeSpec.Builder().
Use the static factory method to create immutable instances:
ImmutableIntChromosomeSpec.of().
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateImmutableIntChromosomeSpec(int size, int minValue, int maxValue) -
Method Summary
Modifier and TypeMethodDescriptionstatic IntChromosomeSpeccopyOf(IntChromosomeSpec instance) Creates an immutable copy of aIntChromosomeSpecvalue.booleanThis instance is equal to all instances ofImmutableIntChromosomeSpecthat have equal attribute values.private booleanequalsByValue(ImmutableIntChromosomeSpec another) inthashCode()Computes a hash code from attributes:size,minValue,maxValue.intmaxValue()Returns the maximum value (inclusive) for integer alleles in the chromosome.intminValue()Returns the minimum value (inclusive) for integer alleles in the chromosome.static IntChromosomeSpecof(int size, int minValue, int maxValue) Construct a new immutableIntChromosomeSpecinstance.intsize()Returns the number of integer values in chromosomes created from this specification.toString()Prints the immutable valueIntChromosomeSpecwith attribute values.private static ImmutableIntChromosomeSpecvalidate(ImmutableIntChromosomeSpec instance) withMaxValue(int value) Copy the current immutable object by setting a value for themaxValueattribute.withMinValue(int value) Copy the current immutable object by setting a value for theminValueattribute.withSize(int value) Copy the current immutable object by setting a value for thesizeattribute.Methods inherited from class net.bmahe.genetics4j.core.spec.chromosome.IntChromosomeSpec
check
-
Field Details
-
size
private final int size -
minValue
private final int minValue -
maxValue
private final int maxValue
-
-
Constructor Details
-
ImmutableIntChromosomeSpec
private ImmutableIntChromosomeSpec(int size, int minValue, int maxValue)
-
-
Method Details
-
size
public int size()Returns the number of integer values in chromosomes created from this specification.- Specified by:
sizein classIntChromosomeSpec- Returns:
- the chromosome size, always positive
-
minValue
public int minValue()Returns the minimum value (inclusive) for integer alleles in the chromosome.- Specified by:
minValuein classIntChromosomeSpec- Returns:
- the minimum allowed integer value
-
maxValue
public int maxValue()Returns the maximum value (inclusive) for integer alleles in the chromosome.- Specified by:
maxValuein classIntChromosomeSpec- Returns:
- the maximum allowed integer value
-
withSize
Copy the current immutable object by setting a value for thesizeattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for size- Returns:
- A modified copy or the
thisobject
-
withMinValue
Copy the current immutable object by setting a value for theminValueattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for minValue- Returns:
- A modified copy or the
thisobject
-
withMaxValue
Copy the current immutable object by setting a value for themaxValueattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for maxValue- Returns:
- A modified copy or the
thisobject
-
equals
This instance is equal to all instances ofImmutableIntChromosomeSpecthat have equal attribute values. -
equalsByValue
-
hashCode
public int hashCode()Computes a hash code from attributes:size,minValue,maxValue. -
toString
Prints the immutable valueIntChromosomeSpecwith attribute values. -
of
Construct a new immutableIntChromosomeSpecinstance.- Parameters:
size- The value for thesizeattributeminValue- The value for theminValueattributemaxValue- The value for themaxValueattribute- Returns:
- An immutable IntChromosomeSpec instance
-
validate
-
copyOf
Creates an immutable copy of aIntChromosomeSpecvalue. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.- Parameters:
instance- The instance to copy- Returns:
- A copied immutable IntChromosomeSpec instance
-