Package net.bmahe.genetics4j.gp.program
Class ImmutableProgram
java.lang.Object
net.bmahe.genetics4j.gp.program.Program
net.bmahe.genetics4j.gp.program.ImmutableProgram
@Generated("org.immutables.processor.ProxyProcessor")
public final class ImmutableProgram
extends Program
Immutable implementation of
Program
.
Use the builder to create immutable instances:
ImmutableProgram.builder()
.
Use the static factory method to create immutable instances:
ImmutableProgram.of()
.
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprivate final Set
<OperationFactory> private final InputSpec
private final int
private final Set
<OperationFactory> -
Constructor Summary
ModifierConstructorDescriptionprivate
ImmutableProgram
(Iterable<? extends OperationFactory> functions, Iterable<? extends OperationFactory> terminal, InputSpec inputSpec, int maxDepth) private
ImmutableProgram
(ImmutableProgram original, Set<OperationFactory> functions, Set<OperationFactory> terminal, InputSpec inputSpec, int maxDepth) -
Method Summary
Modifier and TypeMethodDescriptionstatic ImmutableProgram.Builder
builder()
Creates a builder forImmutableProgram
.static ImmutableProgram
Creates an immutable copy of aProgram
value.private static <T> List
<T> createSafeList
(Iterable<? extends T> iterable, boolean checkNulls, boolean skipNulls) private static <T> Set
<T> createUnmodifiableSet
(List<T> list) Unmodifiable set constructed from list to avoid rehashing.boolean
This instance is equal to all instances ofImmutableProgram
that have equal attribute values.private boolean
equalTo
(int synthetic, ImmutableProgram another) int
hashCode()
Computes a hash code from attributes:functions
,terminal
,inputSpec
,maxDepth
.int
maxDepth()
static ImmutableProgram
of
(Iterable<? extends OperationFactory> functions, Iterable<? extends OperationFactory> terminal, InputSpec inputSpec, int maxDepth) Construct a new immutableProgram
instance.static ImmutableProgram
of
(Set<OperationFactory> functions, Set<OperationFactory> terminal, InputSpec inputSpec, int maxDepth) Construct a new immutableProgram
instance.terminal()
toString()
Prints the immutable valueProgram
with attribute values.private static ImmutableProgram
validate
(ImmutableProgram instance) final ImmutableProgram
withFunctions
(Iterable<? extends OperationFactory> elements) Copy the current immutable object with elements that replace the content offunctions
.final ImmutableProgram
withFunctions
(OperationFactory... elements) Copy the current immutable object with elements that replace the content offunctions
.final ImmutableProgram
withInputSpec
(InputSpec value) Copy the current immutable object by setting a value for theinputSpec
attribute.final ImmutableProgram
withMaxDepth
(int value) Copy the current immutable object by setting a value for themaxDepth
attribute.final ImmutableProgram
withTerminal
(Iterable<? extends OperationFactory> elements) Copy the current immutable object with elements that replace the content ofterminal
.final ImmutableProgram
withTerminal
(OperationFactory... elements) Copy the current immutable object with elements that replace the content ofterminal
.
-
Field Details
-
functions
-
terminal
-
inputSpec
-
maxDepth
private final int maxDepth
-
-
Constructor Details
-
ImmutableProgram
private ImmutableProgram(Iterable<? extends OperationFactory> functions, Iterable<? extends OperationFactory> terminal, InputSpec inputSpec, int maxDepth) -
ImmutableProgram
private ImmutableProgram(ImmutableProgram original, Set<OperationFactory> functions, Set<OperationFactory> terminal, InputSpec inputSpec, int maxDepth)
-
-
Method Details
-
functions
-
terminal
-
inputSpec
-
maxDepth
public int maxDepth() -
withFunctions
Copy the current immutable object with elements that replace the content offunctions
.- Parameters:
elements
- The elements to set- Returns:
- A modified copy of
this
object
-
withFunctions
Copy the current immutable object with elements that replace the content offunctions
. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
elements
- An iterable of functions elements to set- Returns:
- A modified copy of
this
object
-
withTerminal
Copy the current immutable object with elements that replace the content ofterminal
.- Parameters:
elements
- The elements to set- Returns:
- A modified copy of
this
object
-
withTerminal
Copy the current immutable object with elements that replace the content ofterminal
. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
elements
- An iterable of terminal elements to set- Returns:
- A modified copy of
this
object
-
withInputSpec
Copy the current immutable object by setting a value for theinputSpec
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for inputSpec- Returns:
- A modified copy of the
this
object
-
withMaxDepth
Copy the current immutable object by setting a value for themaxDepth
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for maxDepth- Returns:
- A modified copy of the
this
object
-
equals
This instance is equal to all instances ofImmutableProgram
that have equal attribute values. -
equalTo
-
hashCode
public int hashCode()Computes a hash code from attributes:functions
,terminal
,inputSpec
,maxDepth
. -
toString
Prints the immutable valueProgram
with attribute values. -
of
public static ImmutableProgram of(Set<OperationFactory> functions, Set<OperationFactory> terminal, InputSpec inputSpec, int maxDepth) Construct a new immutableProgram
instance.- Parameters:
functions
- The value for thefunctions
attributeterminal
- The value for theterminal
attributeinputSpec
- The value for theinputSpec
attributemaxDepth
- The value for themaxDepth
attribute- Returns:
- An immutable Program instance
-
of
public static ImmutableProgram of(Iterable<? extends OperationFactory> functions, Iterable<? extends OperationFactory> terminal, InputSpec inputSpec, int maxDepth) Construct a new immutableProgram
instance.- Parameters:
functions
- The value for thefunctions
attributeterminal
- The value for theterminal
attributeinputSpec
- The value for theinputSpec
attributemaxDepth
- The value for themaxDepth
attribute- Returns:
- An immutable Program instance
-
validate
-
copyOf
Creates an immutable copy of aProgram
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 Program instance
-
builder
Creates a builder forImmutableProgram
.ImmutableProgram.builder() .addFunctions|addAllFunctions(net.bmahe.genetics4j.gp.OperationFactory) //
functions
elements .addTerminal|addAllTerminal(net.bmahe.genetics4j.gp.OperationFactory) //terminal
elements .inputSpec(net.bmahe.genetics4j.gp.InputSpec) // requiredinputSpec
.maxDepth(int) // requiredmaxDepth
.build();- Returns:
- A new ImmutableProgram builder
-
createSafeList
-
createUnmodifiableSet
Unmodifiable set constructed from list to avoid rehashing.
-