Class ImmutableChromosomeFactoryProvider.Builder
java.lang.Object
net.bmahe.genetics4j.core.chromosomes.factory.ImmutableChromosomeFactoryProvider.Builder
- Enclosing class:
ImmutableChromosomeFactoryProvider
Builds instances of type
ImmutableChromosomeFactoryProvider
.
Initialize attributes and then invoke the build()
method to create an
immutable instance.
Builder
is not thread-safe and generally should not be stored in a field or collection,
but instead used immediately to create instances.
-
Field Summary
Modifier and TypeFieldDescriptionprivate List
<Function<ChromosomeFactoryProvider, ChromosomeFactory<? extends Chromosome>>> private List
<ChromosomeFactory<? extends Chromosome>> private static final long
private long
private static final long
private long
private RandomGenerator
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddAllChromosomeFactoriesGenerator
(Iterable<? extends Function<ChromosomeFactoryProvider, ChromosomeFactory<? extends Chromosome>>> elements) Adds elements tochromosomeFactoriesGenerator
list.addAllDefaultChromosomeFactories
(Iterable<? extends ChromosomeFactory<? extends Chromosome>> elements) Adds elements todefaultChromosomeFactories
list.addChromosomeFactoriesGenerator
(Function<ChromosomeFactoryProvider, ChromosomeFactory<? extends Chromosome>> element) Adds one element tochromosomeFactoriesGenerator
list.addChromosomeFactoriesGenerator
(Function<ChromosomeFactoryProvider, ChromosomeFactory<? extends Chromosome>>... elements) Adds elements tochromosomeFactoriesGenerator
list.addDefaultChromosomeFactories
(ChromosomeFactory<? extends Chromosome> element) Adds one element todefaultChromosomeFactories
list.addDefaultChromosomeFactories
(ChromosomeFactory<? extends Chromosome>... elements) Adds elements todefaultChromosomeFactories
list.build()
Builds a newImmutableChromosomeFactoryProvider
.chromosomeFactoriesGenerator
(Iterable<? extends Function<ChromosomeFactoryProvider, ChromosomeFactory<? extends Chromosome>>> elements) Sets or replaces all elements forchromosomeFactoriesGenerator
list.defaultChromosomeFactories
(Iterable<? extends ChromosomeFactory<? extends Chromosome>> elements) Sets or replaces all elements fordefaultChromosomeFactories
list.private boolean
private String
from
(ChromosomeFactoryProvider instance) Fill a builder with attribute values from the providedChromosomeFactoryProvider
instance.randomGenerator
(RandomGenerator randomGenerator) Initializes the value for therandomGenerator
attribute.
-
Field Details
-
INIT_BIT_RANDOM_GENERATOR
private static final long INIT_BIT_RANDOM_GENERATOR- See Also:
-
OPT_BIT_DEFAULT_CHROMOSOME_FACTORIES
private static final long OPT_BIT_DEFAULT_CHROMOSOME_FACTORIES- See Also:
-
initBits
private long initBits -
optBits
private long optBits -
randomGenerator
-
defaultChromosomeFactories
-
chromosomeFactoriesGenerator
private List<Function<ChromosomeFactoryProvider,ChromosomeFactory<? extends Chromosome>>> chromosomeFactoriesGenerator
-
-
Constructor Details
-
Builder
private Builder()
-
-
Method Details
-
from
Fill a builder with attribute values from the providedChromosomeFactoryProvider
instance. Regular attribute values will be replaced with those from the given instance. Absent optional values will not replace present values. Collection elements and entries will be added, not replaced.- Parameters:
instance
- The instance from which to copy values- Returns:
this
builder for use in a chained invocation
-
randomGenerator
public final ImmutableChromosomeFactoryProvider.Builder randomGenerator(RandomGenerator randomGenerator) Initializes the value for therandomGenerator
attribute.- Parameters:
randomGenerator
- The value for randomGenerator- Returns:
this
builder for use in a chained invocation
-
addDefaultChromosomeFactories
public final ImmutableChromosomeFactoryProvider.Builder addDefaultChromosomeFactories(ChromosomeFactory<? extends Chromosome> element) Adds one element todefaultChromosomeFactories
list.- Parameters:
element
- A defaultChromosomeFactories element- Returns:
this
builder for use in a chained invocation
-
addDefaultChromosomeFactories
@SafeVarargs public final ImmutableChromosomeFactoryProvider.Builder addDefaultChromosomeFactories(ChromosomeFactory<? extends Chromosome>... elements) Adds elements todefaultChromosomeFactories
list.- Parameters:
elements
- An array of defaultChromosomeFactories elements- Returns:
this
builder for use in a chained invocation
-
defaultChromosomeFactories
public final ImmutableChromosomeFactoryProvider.Builder defaultChromosomeFactories(Iterable<? extends ChromosomeFactory<? extends Chromosome>> elements) Sets or replaces all elements fordefaultChromosomeFactories
list.- Parameters:
elements
- An iterable of defaultChromosomeFactories elements- Returns:
this
builder for use in a chained invocation
-
addAllDefaultChromosomeFactories
public final ImmutableChromosomeFactoryProvider.Builder addAllDefaultChromosomeFactories(Iterable<? extends ChromosomeFactory<? extends Chromosome>> elements) Adds elements todefaultChromosomeFactories
list.- Parameters:
elements
- An iterable of defaultChromosomeFactories elements- Returns:
this
builder for use in a chained invocation
-
addChromosomeFactoriesGenerator
public final ImmutableChromosomeFactoryProvider.Builder addChromosomeFactoriesGenerator(Function<ChromosomeFactoryProvider, ChromosomeFactory<? extends Chromosome>> element) Adds one element tochromosomeFactoriesGenerator
list.- Parameters:
element
- A chromosomeFactoriesGenerator element- Returns:
this
builder for use in a chained invocation
-
addChromosomeFactoriesGenerator
@SafeVarargs public final ImmutableChromosomeFactoryProvider.Builder addChromosomeFactoriesGenerator(Function<ChromosomeFactoryProvider, ChromosomeFactory<? extends Chromosome>>... elements) Adds elements tochromosomeFactoriesGenerator
list.- Parameters:
elements
- An array of chromosomeFactoriesGenerator elements- Returns:
this
builder for use in a chained invocation
-
chromosomeFactoriesGenerator
public final ImmutableChromosomeFactoryProvider.Builder chromosomeFactoriesGenerator(Iterable<? extends Function<ChromosomeFactoryProvider, ChromosomeFactory<? extends Chromosome>>> elements) Sets or replaces all elements forchromosomeFactoriesGenerator
list.- Parameters:
elements
- An iterable of chromosomeFactoriesGenerator elements- Returns:
this
builder for use in a chained invocation
-
addAllChromosomeFactoriesGenerator
public final ImmutableChromosomeFactoryProvider.Builder addAllChromosomeFactoriesGenerator(Iterable<? extends Function<ChromosomeFactoryProvider, ChromosomeFactory<? extends Chromosome>>> elements) Adds elements tochromosomeFactoriesGenerator
list.- Parameters:
elements
- An iterable of chromosomeFactoriesGenerator elements- Returns:
this
builder for use in a chained invocation
-
build
Builds a newImmutableChromosomeFactoryProvider
.- Returns:
- An immutable instance of ChromosomeFactoryProvider
- Throws:
IllegalStateException
- if any required attributes are missing
-
defaultChromosomeFactoriesIsSet
private boolean defaultChromosomeFactoriesIsSet() -
formatRequiredAttributesMessage
-