Package io.jenetics.prog.op
Class Const<T>
- java.lang.Object
-
- io.jenetics.prog.op.Val<T>
-
- io.jenetics.prog.op.Const<T>
-
- All Implemented Interfaces:
Op<T>
,Serializable
,Function<T[],T>
,Supplier<Op<T>>
public final class Const<T> extends Val<T> implements Serializable
Represents an operation which always returns the same, constant, value. To improve readability, constants may have a name. If a name is given, this name is used when printing the program tree. TheConst
operation is a terminal operation.final static Op<Double> PI = Const.of("π", Math.PI); final static Op<Double> ONE = Const.of(1.0);
- Since:
- 3.9
- Version:
- 5.0
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> Const<T>
of(String name, T value)
Return a new constant with the given name and value.static <T> Const<T>
of(T value)
Return a new constant with the given value.String
toString()
T
value()
Return the constant value.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.jenetics.prog.op.Op
get, isTerminal
-
-
-
-
Method Detail
-
of
public static <T> Const<T> of(String name, T value)
Return a new constant with the given name and value.- Type Parameters:
T
- the constant type- Parameters:
name
- the constant namevalue
- the constant value- Returns:
- a new constant
- Throws:
NullPointerException
- if the given constantname
isnull
-
-