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`

public class MinMax extends ArrayFunctionBase
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:
  - Serialized Form

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `MinMax.MinMaxType`
  Type 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

  Fields
  Modifier and Type
  Field
  Description
  `protected final Comparative`
  `comp`
  Used 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

  Constructors
  Constructor
  Description
  `MinMax(boolean isMin)`
  Constructor.
  `MinMax(Comparative comp)`
  Constructor allowing for a different Comparative object.
  `MinMax(MinMax.MinMaxType type)`
  Constructor using the MinMaxType enum.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected Object`
  `calc(List<Object> v)`
  Abstract method for performing the array calculation.
  `Comparative`
  `getComp()`
  Return the Comparative objected used to order the objects.
  `String`
  `getDescription()`
  Return a description of the function from the properties file.
  `Object`
  `minmax(List<Object> vals)`

  ### Methods inherited from class com.singularsys.jep.functions.ArrayFunctionBase

  `addToArray, checkNumberOfParameters, getZeroLengthErrorBehaviour, getZeroLengthValue, run, setZeroLengthErrorBehaviour, setZeroLengthValue, throwAtLeastOneExcep`

  ### Methods inherited from class com.singularsys.jep.functions.PostfixMathCommand

  `asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, asType, getDescription, getDescriptionWithType, getName, getNumberOfParameters, setCurNumberOfParameters, setDescription, setName, toString, toString`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface com.singularsys.jep.functions.ZeroLengthBehaviourI

  `getErrorMessage, getValueOrException, zeroLengthResultOrException`

- ## Field Details

  - ### comp

    protected final Comparative 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

    public MinMax(MinMax.MinMaxType type)
    Constructor using the MinMaxType enum.
    Parameters:
      `type` - the type of MinMax function, either MIN or MAX
    Since:
      4.3

  - ### MinMax

    public MinMax(Comparative comp)
    Constructor allowing for a different Comparative object. The `Comparative.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

    protected Object calc(List<Object> v) throws EvaluationException
    Description copied from class: `ArrayFunctionBase`
    Abstract method for performing the array calculation.
    Specified by:
      `calc` in class `ArrayFunctionBase`
    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

    public Object minmax(List<Object> vals) throws EvaluationException
    Throws:
      `EvaluationException`

  - ### getComp

    public Comparative getComp()
    Return the Comparative objected used to order the objects.
    Returns:
      the Comparative object
    Since:
      3.4.0

  - ### getDescription

    public String getDescription()
    Description copied from class: `PostfixMathCommand`
    Return a description of the function from the properties file. The property name is the class name followed by ".description". The property is found using the `JepMessages` class, which can be configured to add additional properties files. If `PostfixMathCommand.setDescription(String)` has been called, return the description set by that method instead.
    Specified by:
      `getDescription` in interface `PostfixMathCommandI`
    Overrides:
      `getDescription` in class `PostfixMathCommand`
    Returns:
      the description of the function