Class ImmutableSwapMutation
java.lang.Object
net.bmahe.genetics4j.core.spec.mutation.SwapMutation
net.bmahe.genetics4j.core.spec.mutation.ImmutableSwapMutation
- All Implemented Interfaces:
MutationPolicy
@Generated(from="SwapMutation",
generator="Immutables")
@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
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanprivate final intprivate final double -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateImmutableSwapMutation(double populationMutationProbability, int numSwap, boolean isNumSwapFixed) -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Creates a builder forSwapMutation.static SwapMutationcopyOf(SwapMutation instance) Creates an immutable copy of aSwapMutationvalue.booleanThis instance is equal to all instances ofImmutableSwapMutationthat have equal attribute values.private booleanequalsByValue(ImmutableSwapMutation another) inthashCode()Computes a hash code from attributes:populationMutationProbability,numSwap,isNumSwapFixed.booleanintnumSwap()static SwapMutationof(double populationMutationProbability, int numSwap, boolean isNumSwapFixed) Construct a new immutableSwapMutationinstance.doubletoString()Prints the immutable valueSwapMutationwith attribute values.private static ImmutableSwapMutationvalidate(ImmutableSwapMutation instance) final ImmutableSwapMutationwithIsNumSwapFixed(boolean value) Copy the current immutable object by setting a value for theisNumSwapFixedattribute.final ImmutableSwapMutationwithNumSwap(int value) Copy the current immutable object by setting a value for thenumSwapattribute.final ImmutableSwapMutationwithPopulationMutationProbability(double value) Copy the current immutable object by setting a value for thepopulationMutationProbabilityattribute.Methods inherited from class net.bmahe.genetics4j.core.spec.mutation.SwapMutation
check, ofFixedNumSwap
-
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:
populationMutationProbabilityin classSwapMutation- Returns:
- The value of the
populationMutationProbabilityattribute
-
numSwap
public int numSwap()- Specified by:
numSwapin classSwapMutation- Returns:
- The value of the
numSwapattribute
-
isNumSwapFixed
public boolean isNumSwapFixed()- Specified by:
isNumSwapFixedin classSwapMutation- Returns:
- The value of the
isNumSwapFixedattribute
-
withPopulationMutationProbability
Copy the current immutable object by setting a value for thepopulationMutationProbabilityattribute. 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 or the
thisobject
-
withNumSwap
Copy the current immutable object by setting a value for thenumSwapattribute. 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 or the
thisobject
-
withIsNumSwapFixed
Copy the current immutable object by setting a value for theisNumSwapFixedattribute. 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 or the
thisobject
-
equals
This instance is equal to all instances ofImmutableSwapMutationthat have equal attribute values. -
equalsByValue
-
hashCode
public int hashCode()Computes a hash code from attributes:populationMutationProbability,numSwap,isNumSwapFixed. -
toString
Prints the immutable valueSwapMutationwith attribute values. -
of
public static SwapMutation of(double populationMutationProbability, int numSwap, boolean isNumSwapFixed) Construct a new immutableSwapMutationinstance.- Parameters:
populationMutationProbability- The value for thepopulationMutationProbabilityattributenumSwap- The value for thenumSwapattributeisNumSwapFixed- The value for theisNumSwapFixedattribute- Returns:
- An immutable SwapMutation instance
-
validate
-
copyOf
Creates an immutable copy of aSwapMutationvalue. 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 forSwapMutation.ImmutableSwapMutation.builder() .populationMutationProbability(double) // requiredpopulationMutationProbability.numSwap(int) // requirednumSwap.isNumSwapFixed(boolean) // requiredisNumSwapFixed.build();- Returns:
- A new SwapMutation builder
-