Class InterpreterUtil


  • @Internal
    public final class InterpreterUtil
    extends java.lang.Object
    Util class for CEL interpreter.

    CEL Library Internals. Do Not Use.

    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static ExprValue combineUnknownExprValue​(java.lang.Object... objs)
      Combine multiple ExprValue objects which has UnknownSet into one ExprValue
      static java.lang.Object completeDataOnly​(java.lang.Object obj, java.lang.String exceptionMessage)
      Deprecated.
      static ExprValue createUnknownExprValue​(java.lang.Long... ids)
      Create a ExprValue for one or more ids representing an unknown set.
      static ExprValue createUnknownExprValue​(java.util.List<java.lang.Long> ids)
      Create an ExprValue object has UnknownSet, from a list of unknown expr ids
      static boolean isUnknown​(java.lang.Object obj)
      Check if raw object is ExprValue object and has UnknownSet
      static java.lang.Object shortcircuitUnknownOrThrowable​(java.lang.Object left, java.lang.Object right)
      Short circuit unknown or error arguments to logical operators.
      static java.lang.Object strict​(java.lang.Object valueOrThrowable)
      Enforces strictness.
      static java.lang.Object valueOrUnknown​(@Nullable java.lang.Object valueOrThrowable, java.lang.Long id)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • strict

        public static java.lang.Object strict​(java.lang.Object valueOrThrowable)
                                       throws InterpreterException
        Enforces strictness. The outcome of a failed computation is represented by the value being a Throwable. Applying strict() to such a value-or-throwable will re-throw the proper exception.
        Throws:
        InterpreterException
      • isUnknown

        public static boolean isUnknown​(java.lang.Object obj)
        Check if raw object is ExprValue object and has UnknownSet
        Parameters:
        obj - Object to check.
        Returns:
        boolean value if object is unknown.
      • completeDataOnly

        @CanIgnoreReturnValue
        @Deprecated
        public static java.lang.Object completeDataOnly​(java.lang.Object obj,
                                                        java.lang.String exceptionMessage)
                                                 throws InterpreterException
        Deprecated.
        Throws an InterpreterException with exceptionMessage if the obj is an instance of IncompleteData. IncompleteData does not support some operators.

        Returns the obj argument otherwise.

        Deprecated. TODO: Can be removed once clients have stopped using IncompleteData.

        Throws:
        InterpreterException
      • combineUnknownExprValue

        public static ExprValue combineUnknownExprValue​(java.lang.Object... objs)
        Combine multiple ExprValue objects which has UnknownSet into one ExprValue
        Parameters:
        objs - ExprValue objects which has UnknownSet
        Returns:
        A new ExprValue object which has all unknown expr ids from input objects, without duplication.
      • createUnknownExprValue

        public static ExprValue createUnknownExprValue​(java.lang.Long... ids)
        Create a ExprValue for one or more ids representing an unknown set.
      • createUnknownExprValue

        public static ExprValue createUnknownExprValue​(java.util.List<java.lang.Long> ids)
        Create an ExprValue object has UnknownSet, from a list of unknown expr ids
        Parameters:
        ids - List of unknown expr ids
        Returns:
        A new ExprValue object which has all unknown expr ids from input list
      • shortcircuitUnknownOrThrowable

        public static java.lang.Object shortcircuitUnknownOrThrowable​(java.lang.Object left,
                                                                      java.lang.Object right)
                                                               throws InterpreterException
        Short circuit unknown or error arguments to logical operators.

        Given two arguments, one of which must be throwable (error) or unknown, returns the result from the && or || operators for these arguments, assuming that the result cannot be determined from any boolean arguments alone. This allows us to consolidate the error/unknown handling for both of these operators.

        Throws:
        InterpreterException
      • valueOrUnknown

        public static java.lang.Object valueOrUnknown​(@Nullable java.lang.Object valueOrThrowable,
                                                      java.lang.Long id)