Package net.bmahe.genetics4j.gp.program
Class ImmutableProgram
java.lang.Object
net.bmahe.genetics4j.gp.program.Program
net.bmahe.genetics4j.gp.program.ImmutableProgram
@Generated(from="Program",
generator="Immutables")
@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
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Set<OperationFactory> private final InputSpecprivate final intprivate final Set<OperationFactory> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateImmutableProgram(Iterable<? extends OperationFactory> functions, Iterable<? extends OperationFactory> terminal, InputSpec inputSpec, int maxDepth) privateImmutableProgram(ImmutableProgram original, Set<OperationFactory> functions, Set<OperationFactory> terminal, InputSpec inputSpec, int maxDepth) -
Method Summary
Modifier and TypeMethodDescriptionstatic ImmutableProgram.Builderbuilder()Creates a builder forProgram.static ProgramCreates an immutable copy of aProgramvalue.private static <T> List<T> createSafeList(Iterable<? extends T> iterable, boolean checkNulls, boolean skipNulls) private static <T> Set<T> createUnmodifiableSet(List<? extends T> list) Unmodifiable set constructed from list to avoid rehashing.booleanThis instance is equal to all instances ofImmutableProgramthat have equal attribute values.private booleanequalsByValue(ImmutableProgram another) inthashCode()Computes a hash code from attributes:functions,terminal,inputSpec,maxDepth.intmaxDepth()static Programof(Iterable<? extends OperationFactory> functions, Iterable<? extends OperationFactory> terminal, InputSpec inputSpec, int maxDepth) Construct a new immutablePrograminstance.static Programof(Set<OperationFactory> functions, Set<OperationFactory> terminal, InputSpec inputSpec, int maxDepth) Construct a new immutablePrograminstance.terminal()toString()Prints the immutable valueProgramwith attribute values.private static ImmutableProgramvalidate(ImmutableProgram instance) final ImmutableProgramwithFunctions(Iterable<? extends OperationFactory> elements) Copy the current immutable object with elements that replace the content offunctions.final ImmutableProgramwithFunctions(OperationFactory... elements) Copy the current immutable object with elements that replace the content offunctions.final ImmutableProgramwithInputSpec(InputSpec value) Copy the current immutable object by setting a value for theinputSpecattribute.final ImmutableProgramwithMaxDepth(int value) Copy the current immutable object by setting a value for themaxDepthattribute.final ImmutableProgramwithTerminal(Iterable<? extends OperationFactory> elements) Copy the current immutable object with elements that replace the content ofterminal.final ImmutableProgramwithTerminal(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
thisobject
-
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 or
thisif not changed
-
withTerminal
Copy the current immutable object with elements that replace the content ofterminal.- Parameters:
elements- The elements to set- Returns:
- A modified copy of
thisobject
-
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 or
thisif not changed
-
withInputSpec
Copy the current immutable object by setting a value for theinputSpecattribute. 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 or the
thisobject
-
withMaxDepth
Copy the current immutable object by setting a value for themaxDepthattribute. 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 or the
thisobject
-
equals
This instance is equal to all instances ofImmutableProgramthat have equal attribute values. -
equalsByValue
-
hashCode
public int hashCode()Computes a hash code from attributes:functions,terminal,inputSpec,maxDepth. -
toString
Prints the immutable valueProgramwith attribute values. -
of
public static Program of(Set<OperationFactory> functions, Set<OperationFactory> terminal, InputSpec inputSpec, int maxDepth) Construct a new immutablePrograminstance.- Parameters:
functions- The value for thefunctionsattributeterminal- The value for theterminalattributeinputSpec- The value for theinputSpecattributemaxDepth- The value for themaxDepthattribute- Returns:
- An immutable Program instance
-
of
public static Program of(Iterable<? extends OperationFactory> functions, Iterable<? extends OperationFactory> terminal, InputSpec inputSpec, int maxDepth) Construct a new immutablePrograminstance.- Parameters:
functions- The value for thefunctionsattributeterminal- The value for theterminalattributeinputSpec- The value for theinputSpecattributemaxDepth- The value for themaxDepthattribute- Returns:
- An immutable Program instance
-
validate
-
copyOf
Creates an immutable copy of aProgramvalue. 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 forProgram.ImmutableProgram.builder() .addFunctions|addAllFunctions(net.bmahe.genetics4j.gp.OperationFactory) //functionselements .addTerminal|addAllTerminal(net.bmahe.genetics4j.gp.OperationFactory) //terminalelements .inputSpec(net.bmahe.genetics4j.gp.InputSpec) // requiredinputSpec.maxDepth(int) // requiredmaxDepth.build();- Returns:
- A new Program builder
-
createSafeList
-
createUnmodifiableSet
Unmodifiable set constructed from list to avoid rehashing.
-