Package dev.cel.parser
Class CelMacro
- java.lang.Object
-
- dev.cel.parser.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 theCelMacroExpanderto apply.
-
-
Field Summary
Fields Modifier and Type Field Description static CelMacroALLBoolean comprehension which asserts that a predicate holds true for all elements in the input range.static CelMacroEXISTSBoolean comprehension which asserts that a predicate holds true for at least one element in the input range.static CelMacroEXISTS_ONEBoolean comprehension which asserts that a predicate holds true for exactly one element in the input range.static CelMacroFILTERComprehension which produces a list containing elements in the input range which match the filter.static CelMacroHASField presence test macrostatic CelMacroMAPComprehension which applies a transform to each element in the input range and produces a list of equivalent size as output.static CelMacroMAP_FILTERComprehension which conditionally applies a transform to elements in the list which satisfy the filter predicate.static com.google.common.collect.ImmutableList<CelMacro>STANDARD_MACROSSet of all standard macros supported by the CEL spec.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description intcompareTo(CelMacro other)booleanequals(java.lang.Object other)abstract intgetArgumentCount()Returns the number of arguments this macro expects.abstract CelMacroExpandergetExpander()Returns the expander for this macro.abstract java.lang.StringgetFunction()Returns the function name for this macro.abstract java.lang.StringgetKey()Returns the unique string used to identify this macro.inthashCode()booleanisReceiverStyle()True if this macro is receiver-style, false if it is global.booleanisVariadic()Returns true if this macro accepts any number of arguments, false otherwise.static CelMacronewGlobalMacro(java.lang.String function, int argCount, CelMacroExpander expander)Creates a new global macro that accepts a fixed number of arguments.static CelMacronewGlobalVarArgMacro(java.lang.String function, CelMacroExpander expander)Creates a new global macro that accepts a variable number of arguments.static CelMacronewReceiverMacro(java.lang.String function, int argCount, CelMacroExpander expander)Creates a new receiver-style macro that accepts a fixed number of arguments.static CelMacronewReceiverVarArgMacro(java.lang.String function, CelMacroExpander expander)Creates a new receiver-style macro that accepts a variable number of arguments.java.lang.StringtoString()
-
-
-
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:
compareToin interfacejava.lang.Comparable<CelMacro>
-
toString
public final java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
hashCode
public final int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public final boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.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.
-
-