Class ImmutableNeatSelection<T extends Comparable<T>>
java.lang.Object
net.bmahe.genetics4j.neat.spec.selection.NeatSelection<T>
net.bmahe.genetics4j.neat.spec.selection.ImmutableNeatSelection<T>
- All Implemented Interfaces:
SelectionPolicy
@Generated("org.immutables.processor.ProxyProcessor")
public final class ImmutableNeatSelection<T extends Comparable<T>>
extends NeatSelection<T>
Immutable implementation of
NeatSelection
.
Use the builder to create immutable instances:
new NeatSelection.Builder()
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
ImmutableNeatSelection.Builder<T extends Comparable<T>>
Builds instances of typeImmutableNeatSelection
.private final class
-
Field Summary
Modifier and TypeFieldDescriptionprivate ImmutableNeatSelection<T>.InitShim
private final int
private final float
private final BiPredicate
<Individual<T>, Individual<T>> private final SelectionPolicy
private static final byte
private static final byte
private static final byte
-
Constructor Summary
ModifierConstructorDescriptionprivate
ImmutableNeatSelection
(float perSpeciesKeepRatio, int minSpeciesSize, BiPredicate<Individual<T>, Individual<T>> speciesPredicate, SelectionPolicy speciesSelection) private
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Comparable<T>>
ImmutableNeatSelection<T> copyOf
(NeatSelection<T> instance) Creates an immutable copy of aNeatSelection
value.boolean
This instance is equal to all instances ofImmutableNeatSelection
that have equal attribute values.private boolean
equalTo
(int synthetic, ImmutableNeatSelection<?> another) int
hashCode()
Computes a hash code from attributes:perSpeciesKeepRatio
,minSpeciesSize
,speciesPredicate
,speciesSelection
.int
float
toString()
Prints the immutable valueNeatSelection
with attribute values.private static <T extends Comparable<T>>
ImmutableNeatSelection<T> validate
(ImmutableNeatSelection<T> instance) final ImmutableNeatSelection
<T> withMinSpeciesSize
(int value) Copy the current immutable object by setting a value for theminSpeciesSize
attribute.final ImmutableNeatSelection
<T> withPerSpeciesKeepRatio
(float value) Copy the current immutable object by setting a value for theperSpeciesKeepRatio
attribute.final ImmutableNeatSelection
<T> withSpeciesPredicate
(BiPredicate<Individual<T>, Individual<T>> value) Copy the current immutable object by setting a value for thespeciesPredicate
attribute.final ImmutableNeatSelection
<T> Copy the current immutable object by setting a value for thespeciesSelection
attribute.
-
Field Details
-
perSpeciesKeepRatio
private final float perSpeciesKeepRatio -
minSpeciesSize
private final int minSpeciesSize -
speciesPredicate
private final BiPredicate<Individual<T extends Comparable<T>>,Individual<T extends Comparable<T>>> speciesPredicate -
speciesSelection
-
STAGE_INITIALIZING
private static final byte STAGE_INITIALIZING- See Also:
-
STAGE_UNINITIALIZED
private static final byte STAGE_UNINITIALIZED- See Also:
-
STAGE_INITIALIZED
private static final byte STAGE_INITIALIZED- See Also:
-
initShim
-
-
Constructor Details
-
ImmutableNeatSelection
-
ImmutableNeatSelection
private ImmutableNeatSelection(float perSpeciesKeepRatio, int minSpeciesSize, BiPredicate<Individual<T>, Individual<T>> speciesPredicate, SelectionPolicy speciesSelection)
-
-
Method Details
-
perSpeciesKeepRatio
public float perSpeciesKeepRatio()- Overrides:
perSpeciesKeepRatio
in classNeatSelection<T extends Comparable<T>>
- Returns:
- The value of the
perSpeciesKeepRatio
attribute
-
minSpeciesSize
public int minSpeciesSize()- Overrides:
minSpeciesSize
in classNeatSelection<T extends Comparable<T>>
- Returns:
- The value of the
minSpeciesSize
attribute
-
speciesPredicate
- Specified by:
speciesPredicate
in classNeatSelection<T extends Comparable<T>>
- Returns:
- The value of the
speciesPredicate
attribute
-
speciesSelection
- Specified by:
speciesSelection
in classNeatSelection<T extends Comparable<T>>
- Returns:
- The value of the
speciesSelection
attribute
-
withPerSpeciesKeepRatio
Copy the current immutable object by setting a value for theperSpeciesKeepRatio
attribute. A value strict bits equality used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for perSpeciesKeepRatio- Returns:
- A modified copy of the
this
object
-
withMinSpeciesSize
Copy the current immutable object by setting a value for theminSpeciesSize
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for minSpeciesSize- Returns:
- A modified copy of the
this
object
-
withSpeciesPredicate
public final ImmutableNeatSelection<T> withSpeciesPredicate(BiPredicate<Individual<T>, Individual<T>> value) Copy the current immutable object by setting a value for thespeciesPredicate
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for speciesPredicate- Returns:
- A modified copy of the
this
object
-
withSpeciesSelection
Copy the current immutable object by setting a value for thespeciesSelection
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for speciesSelection- Returns:
- A modified copy of the
this
object
-
equals
This instance is equal to all instances ofImmutableNeatSelection
that have equal attribute values. -
equalTo
-
hashCode
public int hashCode()Computes a hash code from attributes:perSpeciesKeepRatio
,minSpeciesSize
,speciesPredicate
,speciesSelection
. -
toString
Prints the immutable valueNeatSelection
with attribute values. -
validate
private static <T extends Comparable<T>> ImmutableNeatSelection<T> validate(ImmutableNeatSelection<T> instance) -
copyOf
Creates an immutable copy of aNeatSelection
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 NeatSelection instance
-