Class ImmutableFitnessSharing<T extends Comparable<T>>
java.lang.Object
net.bmahe.genetics4j.core.postevaluationprocess.FitnessSharing<T>
net.bmahe.genetics4j.core.postevaluationprocess.ImmutableFitnessSharing<T>
- All Implemented Interfaces:
Function<Population<T>,
Population<T>>
@Generated("org.immutables.processor.ProxyProcessor")
public final class ImmutableFitnessSharing<T extends Comparable<T>>
extends FitnessSharing<T>
Immutable implementation of
FitnessSharing
.
Use the builder to create immutable instances:
ImmutableFitnessSharing.builder()
.
Use the static factory method to create immutable instances:
ImmutableFitnessSharing.of()
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
ImmutableFitnessSharing.Builder<T extends Comparable<T>>
Builds instances of typeImmutableFitnessSharing
. -
Field Summary
Modifier and TypeFieldDescriptionprivate final BiFunction
<Genotype, Genotype, Double> private final BiFunction
<Individual<T>, Double, T> -
Constructor Summary
ModifierConstructorDescriptionprivate
ImmutableFitnessSharing
(BiFunction<Genotype, Genotype, Double> distance, Function<Double, Double> sharing, BiFunction<Individual<T>, Double, T> scaleFitness) private
ImmutableFitnessSharing
(ImmutableFitnessSharing<T> original, BiFunction<Genotype, Genotype, Double> distance, Function<Double, Double> sharing, BiFunction<Individual<T>, Double, T> scaleFitness) -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Comparable<T>>
ImmutableFitnessSharing.Builder<T> builder()
Creates a builder forImmutableFitnessSharing
.static <T extends Comparable<T>>
ImmutableFitnessSharing<T> copyOf
(FitnessSharing<T> instance) Creates an immutable copy of aFitnessSharing
value.distance()
boolean
This instance is equal to all instances ofImmutableFitnessSharing
that have equal attribute values.private boolean
equalTo
(int synthetic, ImmutableFitnessSharing<?> another) int
hashCode()
Computes a hash code from attributes:distance
,sharing
,scaleFitness
.static <T extends Comparable<T>>
ImmutableFitnessSharing<T> of
(BiFunction<Genotype, Genotype, Double> distance, Function<Double, Double> sharing, BiFunction<Individual<T>, Double, T> scaleFitness) Construct a new immutableFitnessSharing
instance.sharing()
toString()
Prints the immutable valueFitnessSharing
with attribute values.final ImmutableFitnessSharing
<T> withDistance
(BiFunction<Genotype, Genotype, Double> value) Copy the current immutable object by setting a value for thedistance
attribute.final ImmutableFitnessSharing
<T> withScaleFitness
(BiFunction<Individual<T>, Double, T> value) Copy the current immutable object by setting a value for thescaleFitness
attribute.final ImmutableFitnessSharing
<T> withSharing
(Function<Double, Double> value) Copy the current immutable object by setting a value for thesharing
attribute.Methods inherited from class net.bmahe.genetics4j.core.postevaluationprocess.FitnessSharing
apply, of, ofFloatFitness, ofStandard, ofStandard
-
Field Details
-
distance
-
sharing
-
scaleFitness
private final BiFunction<Individual<T extends Comparable<T>>,Double, scaleFitnessT extends Comparable<T>>
-
-
Constructor Details
-
ImmutableFitnessSharing
private ImmutableFitnessSharing(BiFunction<Genotype, Genotype, Double> distance, Function<Double, Double> sharing, BiFunction<Individual<T>, Double, T> scaleFitness) -
ImmutableFitnessSharing
private ImmutableFitnessSharing(ImmutableFitnessSharing<T> original, BiFunction<Genotype, Genotype, Double> distance, Function<Double, Double> sharing, BiFunction<Individual<T>, Double, T> scaleFitness)
-
-
Method Details
-
distance
- Specified by:
distance
in classFitnessSharing<T extends Comparable<T>>
- Returns:
- The value of the
distance
attribute
-
sharing
- Specified by:
sharing
in classFitnessSharing<T extends Comparable<T>>
- Returns:
- The value of the
sharing
attribute
-
scaleFitness
- Specified by:
scaleFitness
in classFitnessSharing<T extends Comparable<T>>
- Returns:
- The value of the
scaleFitness
attribute
-
withDistance
Copy the current immutable object by setting a value for thedistance
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for distance- Returns:
- A modified copy of the
this
object
-
withSharing
Copy the current immutable object by setting a value for thesharing
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for sharing- Returns:
- A modified copy of the
this
object
-
withScaleFitness
Copy the current immutable object by setting a value for thescaleFitness
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for scaleFitness- Returns:
- A modified copy of the
this
object
-
equals
This instance is equal to all instances ofImmutableFitnessSharing
that have equal attribute values. -
equalTo
-
hashCode
public int hashCode()Computes a hash code from attributes:distance
,sharing
,scaleFitness
. -
toString
Prints the immutable valueFitnessSharing
with attribute values. -
of
public static <T extends Comparable<T>> ImmutableFitnessSharing<T> of(BiFunction<Genotype, Genotype, Double> distance, Function<Double, Double> sharing, BiFunction<Individual<T>, Double, T> scaleFitness) Construct a new immutableFitnessSharing
instance.- Type Parameters:
T
- generic parameter T- Parameters:
distance
- The value for thedistance
attributesharing
- The value for thesharing
attributescaleFitness
- The value for thescaleFitness
attribute- Returns:
- An immutable FitnessSharing instance
-
copyOf
public static <T extends Comparable<T>> ImmutableFitnessSharing<T> copyOf(FitnessSharing<T> instance) Creates an immutable copy of aFitnessSharing
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 FitnessSharing instance
-
builder
Creates a builder forImmutableFitnessSharing
.ImmutableFitnessSharing.<T>builder() .distance(function.BiFunction<net.bmahe.genetics4j.core.Genotype, net.bmahe.genetics4j.core.Genotype, Double>) // required
distance
.sharing(function.Function<Double, Double>) // requiredsharing
.scaleFitness(function.BiFunction<net.bmahe.genetics4j.core.Individual<T>, Double, T>) // requiredscaleFitness
.build();- Type Parameters:
T
- generic parameter T- Returns:
- A new ImmutableFitnessSharing builder
-