Package com.singularsys.jep.functions
Class MinMax
java.lang.Object
com.singularsys.jep.functions.PostfixMathCommand
com.singularsys.jep.functions.ArrayFunctionBase
com.singularsys.jep.functions.MinMax
- All Implemented Interfaces:
ZeroLengthBehaviourI,PostfixMathCommandI,Serializable
Minimum and Maximum functions. Initialize with true for minimum and false
for maximum.
Since Jep 3.4 this function will flatten its arguments so
min([1,[2,3]])
will be 1.- Since:
- 3.1.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumType of MinMax function, used to make construct clearer.Nested classes/interfaces inherited from interface com.singularsys.jep.functions.ZeroLengthBehaviourI
ZeroLengthBehaviourI.DefaultZeroLengthBehaviourI, ZeroLengthBehaviourI.ZeroLengthErrorBehaviour, ZeroLengthBehaviourI.ZeroLengthHelper -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ComparativeUsed to compare greater than or less than between objects.Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand
curNumberOfParameters, description, name, NaN, numberOfParameters -
Constructor Summary
ConstructorsConstructorDescriptionMinMax(boolean isMin) Constructor.MinMax(Comparative comp) Constructor allowing for a different Comparative object.MinMax(MinMax.MinMaxType type) Constructor using the MinMaxType enum. -
Method Summary
Methods inherited from class com.singularsys.jep.functions.ArrayFunctionBase
addToArray, checkNumberOfParameters, getZeroLengthErrorBehaviour, getZeroLengthValue, run, setZeroLengthErrorBehaviour, setZeroLengthValue, throwAtLeastOneExcepMethods inherited from class com.singularsys.jep.functions.PostfixMathCommand
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, asType, getDescription, getDescriptionWithType, getName, getNumberOfParameters, setCurNumberOfParameters, setDescription, setName, toString, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.singularsys.jep.functions.ZeroLengthBehaviourI
getErrorMessage, getValueOrException, zeroLengthResultOrException
-
Field Details
-
comp
Used to compare greater than or less than between objects.
-
-
Constructor Details
-
MinMax
public MinMax(boolean isMin) Constructor.- Parameters:
isMin- set to true for Minimum, false for Maximum
-
MinMax
Constructor using the MinMaxType enum.- Parameters:
type- the type of MinMax function, either MIN or MAX- Since:
- 4.3
-
MinMax
Constructor allowing for a different Comparative object. TheComparative.compare(Object, Object)method will be used to compare elements.- Parameters:
comp- a Comparative object or subclass implemented less than or greater than.- Since:
- 3.4.0
-
-
Method Details
-
calc
Description copied from class:ArrayFunctionBaseAbstract method for performing the array calculation.- Specified by:
calcin classArrayFunctionBase- Parameters:
v- The list to operate on. Note this is in reverse order of the arguments of the function.- Returns:
- The result of the calculation.
- Throws:
EvaluationException- if the calculation cannot be performed
-
minmax
- Throws:
EvaluationException
-
getComp
Return the Comparative objected used to order the objects.- Returns:
- the Comparative object
- Since:
- 3.4.0
-
getDescription
Description copied from class:PostfixMathCommandReturn a description of the function from the properties file. The property name is the class name followed by ".description". The property is found using theJepMessagesclass, which can be configured to add additional properties files. IfPostfixMathCommand.setDescription(String)has been called, return the description set by that method instead.- Specified by:
getDescriptionin interfacePostfixMathCommandI- Overrides:
getDescriptionin classPostfixMathCommand- Returns:
- the description of the function
-