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.
-
-
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()
-
-
-
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.
-
-