Class ImmutableSwapMutation
java.lang.Object
net.bmahe.genetics4j.core.spec.mutation.SwapMutation
net.bmahe.genetics4j.core.spec.mutation.ImmutableSwapMutation
- All Implemented Interfaces:
MutationPolicy
@Generated("org.immutables.processor.ProxyProcessor")
public final class ImmutableSwapMutation
extends SwapMutation
Immutable implementation of
SwapMutation
.
Use the builder to create immutable instances:
ImmutableSwapMutation.builder()
.
Use the static factory method to create immutable instances:
ImmutableSwapMutation.of()
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Builds instances of typeImmutableSwapMutation
. -
Field Summary
Modifier and TypeFieldDescriptionprivate final boolean
private final int
private final double
-
Constructor Summary
ModifierConstructorDescriptionprivate
ImmutableSwapMutation
(double populationMutationProbability, int numSwap, boolean isNumSwapFixed) -
Method Summary
Modifier and TypeMethodDescriptionbuilder()
Creates a builder forImmutableSwapMutation
.static ImmutableSwapMutation
copyOf
(SwapMutation instance) Creates an immutable copy of aSwapMutation
value.boolean
This instance is equal to all instances ofImmutableSwapMutation
that have equal attribute values.private boolean
equalTo
(int synthetic, ImmutableSwapMutation another) int
hashCode()
Computes a hash code from attributes:populationMutationProbability
,numSwap
,isNumSwapFixed
.boolean
int
numSwap()
static ImmutableSwapMutation
of
(double populationMutationProbability, int numSwap, boolean isNumSwapFixed) Construct a new immutableSwapMutation
instance.double
toString()
Prints the immutable valueSwapMutation
with attribute values.private static ImmutableSwapMutation
validate
(ImmutableSwapMutation instance) final ImmutableSwapMutation
withIsNumSwapFixed
(boolean value) Copy the current immutable object by setting a value for theisNumSwapFixed
attribute.final ImmutableSwapMutation
withNumSwap
(int value) Copy the current immutable object by setting a value for thenumSwap
attribute.final ImmutableSwapMutation
withPopulationMutationProbability
(double value) Copy the current immutable object by setting a value for thepopulationMutationProbability
attribute.Methods inherited from class net.bmahe.genetics4j.core.spec.mutation.SwapMutation
check
-
Field Details
-
populationMutationProbability
private final double populationMutationProbability -
numSwap
private final int numSwap -
isNumSwapFixed
private final boolean isNumSwapFixed
-
-
Constructor Details
-
ImmutableSwapMutation
private ImmutableSwapMutation(double populationMutationProbability, int numSwap, boolean isNumSwapFixed)
-
-
Method Details
-
populationMutationProbability
public double populationMutationProbability()- Specified by:
populationMutationProbability
in classSwapMutation
- Returns:
- The value of the
populationMutationProbability
attribute
-
numSwap
public int numSwap()- Specified by:
numSwap
in classSwapMutation
- Returns:
- The value of the
numSwap
attribute
-
isNumSwapFixed
public boolean isNumSwapFixed()- Specified by:
isNumSwapFixed
in classSwapMutation
- Returns:
- The value of the
isNumSwapFixed
attribute
-
withPopulationMutationProbability
Copy the current immutable object by setting a value for thepopulationMutationProbability
attribute. A value strict bits equality used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for populationMutationProbability- Returns:
- A modified copy of the
this
object
-
withNumSwap
Copy the current immutable object by setting a value for thenumSwap
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for numSwap- Returns:
- A modified copy of the
this
object
-
withIsNumSwapFixed
Copy the current immutable object by setting a value for theisNumSwapFixed
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for isNumSwapFixed- Returns:
- A modified copy of the
this
object
-
equals
This instance is equal to all instances ofImmutableSwapMutation
that have equal attribute values. -
equalTo
-
hashCode
public int hashCode()Computes a hash code from attributes:populationMutationProbability
,numSwap
,isNumSwapFixed
. -
toString
Prints the immutable valueSwapMutation
with attribute values. -
of
public static ImmutableSwapMutation of(double populationMutationProbability, int numSwap, boolean isNumSwapFixed) Construct a new immutableSwapMutation
instance.- Parameters:
populationMutationProbability
- The value for thepopulationMutationProbability
attributenumSwap
- The value for thenumSwap
attributeisNumSwapFixed
- The value for theisNumSwapFixed
attribute- Returns:
- An immutable SwapMutation instance
-
validate
-
copyOf
Creates an immutable copy of aSwapMutation
value. 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 SwapMutation instance
-
builder
Creates a builder forImmutableSwapMutation
.ImmutableSwapMutation.builder() .populationMutationProbability(double) // required
populationMutationProbability
.numSwap(int) // requirednumSwap
.isNumSwapFixed(boolean) // requiredisNumSwapFixed
.build();- Returns:
- A new ImmutableSwapMutation builder
-