Class CelMacro

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

    @Immutable
    public abstract class CelMacro
    extends java.lang.Object
    implements java.lang.Comparable<CelMacro>
    Describes a function signature to match and the CelMacroExpander to apply.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static CelMacro ALL
      Boolean comprehension which asserts that a predicate holds true for all elements in the input range.
      static CelMacro EXISTS
      Boolean comprehension which asserts that a predicate holds true for at least one element in the input range.
      static CelMacro EXISTS_ONE
      Boolean comprehension which asserts that a predicate holds true for exactly one element in the input range.
      static CelMacro FILTER
      Comprehension which produces a list containing elements in the input range which match the filter.
      static CelMacro HAS
      Field presence test macro
      static CelMacro MAP
      Comprehension which applies a transform to each element in the input range and produces a list of equivalent size as output.
      static CelMacro MAP_FILTER
      Comprehension which conditionally applies a transform to elements in the list which satisfy the filter predicate.
      static com.google.common.collect.ImmutableList<CelMacro> STANDARD_MACROS
      Set of all standard macros supported by the CEL spec.
    • Field Detail

      • HAS

        public static final CelMacro HAS
        Field presence test macro
      • ALL

        public static final CelMacro ALL
        Boolean comprehension which asserts that a predicate holds true for all elements in the input range.
      • EXISTS

        public static final CelMacro EXISTS
        Boolean comprehension which asserts that a predicate holds true for at least one element in the input range.
      • EXISTS_ONE

        public static final CelMacro EXISTS_ONE
        Boolean comprehension which asserts that a predicate holds true for exactly one element in the input range.
      • MAP

        public static final CelMacro MAP
        Comprehension which applies a transform to each element in the input range and produces a list of equivalent size as output.
      • MAP_FILTER

        public static final CelMacro MAP_FILTER
        Comprehension which conditionally applies a transform to elements in the list which satisfy the filter predicate.
      • FILTER

        public static final CelMacro FILTER
        Comprehension which produces a list containing elements in the input range which match the filter.
      • STANDARD_MACROS

        public static final com.google.common.collect.ImmutableList<CelMacro> STANDARD_MACROS
        Set of all standard macros supported by the CEL spec.
    • Method Detail

      • getFunction

        public abstract java.lang.String getFunction()
        Returns the function name for this macro.
      • getArgumentCount

        public abstract int getArgumentCount()
        Returns the number of arguments this macro expects. For variadic macros, this is 0.
      • isReceiverStyle

        public final boolean isReceiverStyle()
        True if this macro is receiver-style, false if it is global.
      • getKey

        public abstract java.lang.String getKey()
        Returns the unique string used to identify this macro.
      • isVariadic

        public final boolean isVariadic()
        Returns true if this macro accepts any number of arguments, false otherwise.
      • getExpander

        public abstract CelMacroExpander getExpander()
        Returns the expander for this macro.
      • compareTo

        public final int compareTo​(CelMacro other)
        Specified by:
        compareTo in interface java.lang.Comparable<CelMacro>
      • toString

        public final java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • hashCode

        public final int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public final boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • newGlobalMacro

        public static CelMacro newGlobalMacro​(java.lang.String function,
                                              int argCount,
                                              CelMacroExpander expander)
        Creates a new global macro that accepts a fixed number of arguments.
      • newGlobalVarArgMacro

        public static CelMacro newGlobalVarArgMacro​(java.lang.String function,
                                                    CelMacroExpander expander)
        Creates a new global macro that accepts a variable number of arguments.
      • newReceiverMacro

        public static CelMacro newReceiverMacro​(java.lang.String function,
                                                int argCount,
                                                CelMacroExpander expander)
        Creates a new receiver-style macro that accepts a fixed number of arguments.
      • newReceiverVarArgMacro

        public static CelMacro newReceiverVarArgMacro​(java.lang.String function,
                                                      CelMacroExpander expander)
        Creates a new receiver-style macro that accepts a variable number of arguments.