Class EvaluationValue

  • All Implemented Interfaces:
    java.lang.Comparable<EvaluationValue>

    public class EvaluationValue
    extends java.lang.Object
    implements java.lang.Comparable<EvaluationValue>
    The representation of the final or intermediate evaluation result value. The representation consists of a data type and data value. Depending on the type, the value will be stored in a corresponding object type.
    • Field Detail

      • NULL_VALUE

        public static final EvaluationValue NULL_VALUE
        A pre-built, immutable, null value.
      • FALSE

        public static final EvaluationValue FALSE
        A pre-built, immutable, false boolean value.
      • TRUE

        public static final EvaluationValue TRUE
        A pre-built, immutable, true boolean value.
    • Constructor Detail

      • EvaluationValue

        @Deprecated(since="3.3.0",
                    forRemoval=true)
        public EvaluationValue​(java.lang.Object value,
                               ExpressionConfiguration configuration)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Creates a new evaluation value by using the configured converter and configuration.
        Parameters:
        value - One of the supported data types.
        configuration - The expression configuration to use.
        Throws:
        java.lang.IllegalArgumentException - if the data type can't be mapped.
        See Also:
        ExpressionConfiguration#getEvaluationValueConverter()
    • Method Detail

      • of

        public static EvaluationValue of​(java.lang.Object value,
                                         ExpressionConfiguration configuration)
        Creates a new evaluation value by using the configured converter and configuration.
        Parameters:
        value - One of the supported data types.
        configuration - The expression configuration to use; not null
        Throws:
        java.lang.IllegalArgumentException - if the data type can't be mapped.
        See Also:
        ExpressionConfiguration#getEvaluationValueConverter()
      • nullValue

        @Deprecated(since="3.3.0",
                    forRemoval=true)
        public static EvaluationValue nullValue()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Use NULL_VALUE instead
        Returns an immutable null value.
        Returns:
        A null value.
      • numberValue

        public static EvaluationValue numberValue​(java.math.BigDecimal value)
        Creates a new number value.
        Parameters:
        value - The BigDecimal value to use.
        Returns:
        the new number value.
      • stringValue

        public static EvaluationValue stringValue​(java.lang.String value)
        Creates a new string value.
        Parameters:
        value - The String value to use.
        Returns:
        the new string value.
      • booleanValue

        public static EvaluationValue booleanValue​(java.lang.Boolean value)
        Creates a new boolean value.
        Parameters:
        value - The Boolean value to use.
        Returns:
        the new boolean value.
      • dateTimeValue

        public static EvaluationValue dateTimeValue​(java.time.Instant value)
        Creates a new date-time value.
        Parameters:
        value - The Instant value to use.
        Returns:
        the new date-time value.
      • durationValue

        public static EvaluationValue durationValue​(java.time.Duration value)
        Creates a new duration value.
        Parameters:
        value - The Duration value to use.
        Returns:
        the new duration value.
      • expressionNodeValue

        public static EvaluationValue expressionNodeValue​(ASTNode value)
        Creates a new expression node value.
        Parameters:
        value - The ASTNode value to use.
        Returns:
        the new expression node value.
      • arrayValue

        public static EvaluationValue arrayValue​(java.util.List<?> value)
        Creates a new array value.
        Parameters:
        value - The List value to use.
        Returns:
        the new array value.
      • structureValue

        public static EvaluationValue structureValue​(java.util.Map<?,​?> value)
        Creates a new structure value.
        Parameters:
        value - The Map value to use.
        Returns:
        the new structure value.
      • binaryValue

        public static EvaluationValue binaryValue​(java.lang.Object value)
        Creates a new binary (raw) value.
        Parameters:
        value - The Object to use.
        Returns:
        the new binary value.
        Since:
        3.3.0
      • isNullValue

        public boolean isNullValue()
      • numberOfString

        public static EvaluationValue numberOfString​(java.lang.String value,
                                                     java.math.MathContext mathContext)
        Creates a EvaluationValue.DataType.NUMBER value from a String.
        Parameters:
        value - The String value.
        mathContext - The math context to use for creation of the BigDecimal storage.
      • getNumberValue

        public java.math.BigDecimal getNumberValue()
        Gets a BigDecimal representation of the value. If possible and needed, a conversion will be made.
        • Boolean true will return a BigDecimal.ONE, else BigDecimal.ZERO.
        Returns:
        The BigDecimal representation of the value, or BigDecimal.ZERO if conversion is not possible.
      • getStringValue

        public java.lang.String getStringValue()
        Gets a String representation of the value. If possible and needed, a conversion will be made.
        • Number values will be returned as BigDecimal.toPlainString().
        • The Object.toString() will be used in all other cases.
        Returns:
        The String representation of the value.
      • getBooleanValue

        public java.lang.Boolean getBooleanValue()
        Gets a Boolean representation of the value. If possible and needed, a conversion will be made.
        • Any non-zero number value will return true.
        • Any string with the value "true" (case ignored) will return true.
        Returns:
        The Boolean representation of the value.
      • getDateTimeValue

        public java.time.Instant getDateTimeValue()
        Gets a Instant representation of the value. If possible and needed, a conversion will be made.
        • Any number value will return the instant from the epoc value.
        • Any string with the string representation of a LocalDateTime (ex: "2018-11-30T18:35:24.00") (case ignored) will return the current LocalDateTime.
        • The date Instant.EPOCH will return if a conversion error occurs or in all other cases.
        Returns:
        The Instant representation of the value.
      • getDurationValue

        public java.time.Duration getDurationValue()
        Gets a Duration representation of the value. If possible and needed, a conversion will be made.
        • Any non-zero number value will return the duration from the millisecond.
        • Any string with the string representation of an Duration (ex: "PnDTnHnMn.nS") (case ignored) will return the current instant.
        • The Duration.ZERO will return if a conversion error occurs or in all other cases.
        Returns:
        The Duration representation of the value.
      • getArrayValue

        public java.util.List<EvaluationValue> getArrayValue()
        Gets a List representation of the value.
        Returns:
        The List representation of the value or an empty list, if no conversion is possible.
      • getStructureValue

        public java.util.Map<java.lang.String,​EvaluationValue> getStructureValue()
        Gets a Map representation of the value.
        Returns:
        The Map representation of the value or an empty list, if no conversion is possible.