Package dev.cel.common.ast
Class CelExprFactory
- java.lang.Object
-
- dev.cel.common.ast.CelExprFactory
-
- Direct Known Subclasses:
CelMacroExprFactory
@Internal public class CelExprFactory extends java.lang.Object
Factory for generating expression nodes.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
CelExprFactory()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CelExpr
fold(java.lang.String iterVar, CelExpr iterRange, java.lang.String accuVar, CelExpr accuInit, CelExpr condition, CelExpr step, CelExpr result)
Fold creates a fold for one variable comprehension instruction.CelExpr
fold(java.lang.String iterVar, java.lang.String iterVar2, CelExpr iterRange, java.lang.String accuVar, CelExpr accuInit, CelExpr condition, CelExpr step, CelExpr result)
Fold creates a fold for two variable comprehension instruction.protected void
maybeDeleteId(long id)
Attempts to decrement the next expr ID if possible.CelExpr
newBoolLiteral(boolean value)
Creates a new constantCelExpr
for a bool value.CelExpr
newBytesLiteral(byte[] value)
Creates a new constantCelExpr
for a bytes value.CelExpr
newBytesLiteral(CelByteString value)
Creates a new constantCelExpr
for a bytes value.CelExpr
newBytesLiteral(java.lang.String value)
Creates a new constantCelExpr
for a bytes value.CelExpr
newConstant(CelConstant constant)
Create a new constant expression.CelExpr
newDoubleLiteral(double value)
Creates a new constantCelExpr
for a double value.CelExpr
newGlobalCall(java.lang.String function, CelExpr... arguments)
Creates a global (free) function callCelExpr
for the given function and arguments.CelExpr
newGlobalCall(java.lang.String function, java.lang.Iterable<CelExpr> arguments)
Creates a global (free) function callCelExpr
for the given function and arguments.CelExpr
newIdentifier(java.lang.String name)
Creates an identifierCelExpr
for the given name.static CelExprFactory
newInstance()
CelExpr
newIntLiteral(long value)
Creates a new constantCelExpr
for an int value.CelExpr
newList(CelExpr... elements)
Creates a new listCelExpr
comprised of the elements.CelExpr
newList(java.lang.Iterable<CelExpr> elements)
Creates a new listCelExpr
comprised of the elements.CelExpr
newMap(CelExpr.CelMap.Entry... entries)
Creates a new mapCelExpr
comprised of the entries.CelExpr
newMap(java.lang.Iterable<CelExpr.CelMap.Entry> entries)
Creates a new mapCelExpr
comprised of the entries.CelExpr.CelMap.Entry
newMapEntry(CelExpr key, CelExpr value)
Creates a new mapCelExpr.CelStruct.Entry
comprised of the given key and value.CelExpr
newMessage(java.lang.String typeName, CelExpr.CelStruct.Entry... fields)
Creates a new messageCelExpr
of the given type comprised of the given fields.CelExpr
newMessage(java.lang.String typeName, java.lang.Iterable<CelExpr.CelStruct.Entry> fields)
Creates a new messageCelExpr
of the given type comprised of the given fields.CelExpr.CelStruct.Entry
newMessageField(java.lang.String field, CelExpr value)
Creates a new messageCelExpr.CelStruct.Entry
comprised of the given field and value.CelExpr
newReceiverCall(java.lang.String function, CelExpr target, CelExpr... arguments)
Creates a receiver-style function callCelExpr
for the given function, target, and arguments.CelExpr
newReceiverCall(java.lang.String function, CelExpr target, java.lang.Iterable<CelExpr> arguments)
Creates a receiver-style function callCelExpr
for the given function, target, and arguments.CelExpr
newSelect(CelExpr operand, java.lang.String field, boolean testOnly)
Creates a field traversal or field presence testCelExpr
for the given operand and field.CelExpr
newStringLiteral(java.lang.String value)
Creates a new constantCelExpr
for a string value.CelExpr
newUintLiteral(long value)
Creates a new constantCelExpr
for a uint value.protected long
nextExprId()
Returns the next unique expression ID.
-
-
-
Method Detail
-
newInstance
public static CelExprFactory newInstance()
-
newConstant
public final CelExpr newConstant(CelConstant constant)
Create a new constant expression.
-
newBoolLiteral
public final CelExpr newBoolLiteral(boolean value)
Creates a new constantCelExpr
for a bool value.
-
newBytesLiteral
public final CelExpr newBytesLiteral(java.lang.String value)
Creates a new constantCelExpr
for a bytes value.
-
newBytesLiteral
public final CelExpr newBytesLiteral(byte[] value)
Creates a new constantCelExpr
for a bytes value.
-
newBytesLiteral
public final CelExpr newBytesLiteral(CelByteString value)
Creates a new constantCelExpr
for a bytes value.
-
newDoubleLiteral
public final CelExpr newDoubleLiteral(double value)
Creates a new constantCelExpr
for a double value.
-
newIntLiteral
public final CelExpr newIntLiteral(long value)
Creates a new constantCelExpr
for an int value.
-
newStringLiteral
public final CelExpr newStringLiteral(java.lang.String value)
Creates a new constantCelExpr
for a string value.
-
newUintLiteral
public final CelExpr newUintLiteral(long value)
Creates a new constantCelExpr
for a uint value.
-
newList
public final CelExpr newList(CelExpr... elements)
Creates a new listCelExpr
comprised of the elements.
-
newList
public final CelExpr newList(java.lang.Iterable<CelExpr> elements)
Creates a new listCelExpr
comprised of the elements.
-
newMap
public final CelExpr newMap(CelExpr.CelMap.Entry... entries)
Creates a new mapCelExpr
comprised of the entries.
-
newMap
public final CelExpr newMap(java.lang.Iterable<CelExpr.CelMap.Entry> entries)
Creates a new mapCelExpr
comprised of the entries.
-
newMapEntry
public final CelExpr.CelMap.Entry newMapEntry(CelExpr key, CelExpr value)
Creates a new mapCelExpr.CelStruct.Entry
comprised of the given key and value.
-
newMessage
public final CelExpr newMessage(java.lang.String typeName, CelExpr.CelStruct.Entry... fields)
Creates a new messageCelExpr
of the given type comprised of the given fields.
-
newMessage
public final CelExpr newMessage(java.lang.String typeName, java.lang.Iterable<CelExpr.CelStruct.Entry> fields)
Creates a new messageCelExpr
of the given type comprised of the given fields.
-
newMessageField
public final CelExpr.CelStruct.Entry newMessageField(java.lang.String field, CelExpr value)
Creates a new messageCelExpr.CelStruct.Entry
comprised of the given field and value.
-
fold
public final CelExpr fold(java.lang.String iterVar, CelExpr iterRange, java.lang.String accuVar, CelExpr accuInit, CelExpr condition, CelExpr step, CelExpr result)
Fold creates a fold for one variable comprehension instruction.
-
fold
public final CelExpr fold(java.lang.String iterVar, java.lang.String iterVar2, CelExpr iterRange, java.lang.String accuVar, CelExpr accuInit, CelExpr condition, CelExpr step, CelExpr result)
Fold creates a fold for two variable comprehension instruction.
-
newIdentifier
public final CelExpr newIdentifier(java.lang.String name)
Creates an identifierCelExpr
for the given name.
-
newGlobalCall
public final CelExpr newGlobalCall(java.lang.String function, CelExpr... arguments)
Creates a global (free) function callCelExpr
for the given function and arguments.
-
newGlobalCall
public final CelExpr newGlobalCall(java.lang.String function, java.lang.Iterable<CelExpr> arguments)
Creates a global (free) function callCelExpr
for the given function and arguments.
-
newReceiverCall
public final CelExpr newReceiverCall(java.lang.String function, CelExpr target, CelExpr... arguments)
Creates a receiver-style function callCelExpr
for the given function, target, and arguments.
-
newReceiverCall
public final CelExpr newReceiverCall(java.lang.String function, CelExpr target, java.lang.Iterable<CelExpr> arguments)
Creates a receiver-style function callCelExpr
for the given function, target, and arguments.
-
newSelect
public final CelExpr newSelect(CelExpr operand, java.lang.String field, boolean testOnly)
Creates a field traversal or field presence testCelExpr
for the given operand and field.
-
nextExprId
protected long nextExprId()
Returns the next unique expression ID.
-
maybeDeleteId
protected void maybeDeleteId(long id)
Attempts to decrement the next expr ID if possible.
-
-