Interface CelExpr
- All Known Subinterfaces:
CelExpr.Binary,CelExpr.Macro,CelExpr.Unary
- All Known Implementing Classes:
CelExpr.Add,CelExpr.And,CelExpr.BoolValue,CelExpr.BytesValue,CelExpr.Divide,CelExpr.DoubleValue,CelExpr.EqualTo,CelExpr.FunctionCall,CelExpr.GreaterThan,CelExpr.GreaterThanOrEqualTo,CelExpr.Ident,CelExpr.IfElse,CelExpr.In,CelExpr.Index,CelExpr.LessThan,CelExpr.LessThanOrEqualTo,CelExpr.ListOf,CelExpr.LongValue,CelExpr.Macro.All,CelExpr.Macro.Exists,CelExpr.Macro.ExistsOne,CelExpr.Macro.Filter,CelExpr.Macro.FilterMap,CelExpr.Macro.Has,CelExpr.Macro.Map,CelExpr.MapOf,CelExpr.MemberCall,CelExpr.Modulo,CelExpr.Multiply,CelExpr.Negative,CelExpr.Not,CelExpr.NotEqualTo,CelExpr.NullValue,CelExpr.OptionalIndex,CelExpr.OptionalSelect,CelExpr.Or,CelExpr.Select,CelExpr.StringValue,CelExpr.Struct,CelExpr.Subtract,CelExpr.UintValue
public sealed interface CelExpr
permits CelExpr.NullValue, CelExpr.BoolValue, CelExpr.LongValue, CelExpr.UintValue, CelExpr.DoubleValue, CelExpr.StringValue, CelExpr.BytesValue, CelExpr.Ident, CelExpr.Select, CelExpr.Index, CelExpr.OptionalSelect, CelExpr.OptionalIndex, CelExpr.Binary, CelExpr.Unary, CelExpr.IfElse, CelExpr.FunctionCall, CelExpr.MemberCall, CelExpr.ListOf, CelExpr.MapOf, CelExpr.Struct, CelExpr.Macro
Abstract representation of a parsed Common Expression Language (CEL) expression.
- Since:
- 10.7
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordAddition:x + y.static final recordLogical AND comparison:x && y.static interfaceAn expression composed by a binary operator.static final recordBoolean literal.static final recordByte sequence literal.static final recordDivision:x / y.static final recordDouble-precision floating point literal.static final recordAn element in a list, map, or message, which can optionally be marked as optional.static final recordEquality comparison:x == y.static final recordGlobal function callsf(args).static final recordGreater than relational comparison:x > y.static final recordGreater than or equal to relational comparison:x >= y.static final recordVariable or symbol lookup, such asrequest.static final recordTernary conditional, such ascondition ? trueExpr : falseExpr.static final recordContainment comparison:x in y.static final recordSubscript/indexing, such asoperand[index].static final recordAn entry/field representing a key-value or field-value mapping in map or struct literals.static final recordLess than relational comparison:x < y.static final recordLess than or equal to relational comparison:x <= y.static final recordList creation, such as[1, ?optional_var].static final recordSigned 64-bit integer literal.static interfaceAbstract representation of a CEL macro expression.static final recordMap creation, such as{"key": value, ? "opt_key": value}.static final recordMember callstarget.f(args).static final recordModulo/remainder:x % y.static final recordMultiplication:x * y.static final recordUnary sign negation:-x.static final recordLogical negation:!x.static final recordInequality comparison:x != y.static final recordNull literal.static final recordOptional subscript/indexing, such asoperand[?index].static final recordOptional field selection, such asoperand.?field.static final recordLogical OR comparison:x || y.static final recordField selection, such asoperand.field.static final recordUTF-8 string literal.static final recordStruct/message creation, such asType{field: value, ?opt_field: value}.static final recordSubtraction:x - y.static final recordUnsigned 64-bit integer literal.static interfaceAn expression composed by a unary operator. -
Method Summary
Modifier and TypeMethodDescriptiondefault CelExpr.Adda.add(b)is equivalent toCelExpr.of("a + b").default CelExpr.Anda.and(b)is equivalent toCelExpr.of("a && b").default CelExpr.GreaterThanOrEqualToa.atLeast(b)is equivalent toCelExpr.of("a >= b").default CelExpr.LessThanOrEqualToa.atMost(b)is equivalent toCelExpr.of("a <= b").static CelExpr.BytesValuebytes(byte... value) CelExpr.bytes((byte) 1, (byte) 2)is equivalent toCelExpr.of("b'\\x01\\x02'").default CelExpr.MemberCallcall(CelExpr.Ident member, List<CelExpr> args) target.call(member, args)is equivalent toCelExpr.of("target.member(args)").default CelExpr.Dividea.divide(b)is equivalent toCelExpr.of("a / b").default CelExpr.EqualToa.equalTo(b)is equivalent toCelExpr.of("a == b").default CelExpr.GreaterThangreaterThan(CelExpr that) a.greaterThan(b)is equivalent toCelExpr.of("a > b").default CelExpr.IfElseactive.ifElse(1, 0)is equivalent toCelExpr.of("active ? 1 : 0").default CelExpr.Ina.in(b)is equivalent toCelExpr.of("a in b").default CelExpr.Indexexpr.index(value(0))is equivalent toCelExpr.of("expr[0]").default CelExpr.LessThana.lessThan(b)is equivalent toCelExpr.of("a < b").default CelExpr.Moduloa.modulo(b)is equivalent toCelExpr.of("a % b").default CelExpr.Multiplya.multiply(b)is equivalent toCelExpr.of("a * b").static CelExpr.NegativeCelExpr.negative(value(5))is equivalent toCelExpr.of("-(5)").static CelExpr.NotCelExpr.not(value(true))is equivalent toCelExpr.of("!true").default CelExpr.NotEqualTonotEqualTo(CelExpr that) a.notEqualTo(b)is equivalent toCelExpr.of("a != b").static CelExprParses and returns aCelExprrepresenting thecelstring.default CelExpr.OptionalIndexoptionalIndex(CelExpr index) expr.optionalIndex(value(0))is equivalent toCelExpr.of("expr[?0]").default CelExpr.OptionalSelectoptionalSelect(CelExpr.Ident field) expr.optionalSelect(field)is equivalent toCelExpr.of("expr.?field").default CelExpr.Ora.or(b)is equivalent toCelExpr.of("a || b").default CelExpr.Selectselect(CelExpr.Ident field) expr.select(field)is equivalent toCelExpr.of("expr.field").intReturns the 0-based source character index where this expression starts.static CelExpr.StringValueCelExpr.value("foo")is equivalent toCelExpr.of("'foo'").default CelExpr.Subtracta.subtract(b)is equivalent toCelExpr.of("a - b").static CelExpr.UintValueunsigned(long value) CelExpr.unsigned(123)is equivalent toCelExpr.of("123u").static CelExpr.BoolValuevalue(boolean value) CelExpr.value(true)is equivalent toCelExpr.of("true").static CelExpr.DoubleValuevalue(double value) CelExpr.value(12.3)is equivalent toCelExpr.of("12.3").static CelExpr.LongValuevalue(long value) CelExpr.value(123)is equivalent toCelExpr.of("123").withSourceIndex(int index) Returns a copy of this expression with the given source index.
-
Method Details
-
sourceIndex
int sourceIndex()Returns the 0-based source character index where this expression starts. -
withSourceIndex
Returns a copy of this expression with the given source index. -
of
-
value
CelExpr.value(true)is equivalent toCelExpr.of("true"). -
value
CelExpr.value(123)is equivalent toCelExpr.of("123"). -
value
CelExpr.value(12.3)is equivalent toCelExpr.of("12.3"). -
string
CelExpr.value("foo")is equivalent toCelExpr.of("'foo'"). -
bytes
CelExpr.bytes((byte) 1, (byte) 2)is equivalent toCelExpr.of("b'\\x01\\x02'"). -
unsigned
CelExpr.unsigned(123)is equivalent toCelExpr.of("123u"). -
negative
CelExpr.negative(value(5))is equivalent toCelExpr.of("-(5)"). -
not
CelExpr.not(value(true))is equivalent toCelExpr.of("!true"). -
select
expr.select(field)is equivalent toCelExpr.of("expr.field"). -
optionalSelect
expr.optionalSelect(field)is equivalent toCelExpr.of("expr.?field"). -
index
expr.index(value(0))is equivalent toCelExpr.of("expr[0]"). -
optionalIndex
expr.optionalIndex(value(0))is equivalent toCelExpr.of("expr[?0]"). -
add
a.add(b)is equivalent toCelExpr.of("a + b"). -
subtract
a.subtract(b)is equivalent toCelExpr.of("a - b"). -
multiply
a.multiply(b)is equivalent toCelExpr.of("a * b"). -
divide
a.divide(b)is equivalent toCelExpr.of("a / b"). -
modulo
a.modulo(b)is equivalent toCelExpr.of("a % b"). -
equalTo
a.equalTo(b)is equivalent toCelExpr.of("a == b"). -
notEqualTo
a.notEqualTo(b)is equivalent toCelExpr.of("a != b"). -
lessThan
a.lessThan(b)is equivalent toCelExpr.of("a < b"). -
atMost
a.atMost(b)is equivalent toCelExpr.of("a <= b"). -
greaterThan
a.greaterThan(b)is equivalent toCelExpr.of("a > b"). -
atLeast
a.atLeast(b)is equivalent toCelExpr.of("a >= b"). -
in
a.in(b)is equivalent toCelExpr.of("a in b"). -
and
a.and(b)is equivalent toCelExpr.of("a && b"). -
or
a.or(b)is equivalent toCelExpr.of("a || b"). -
ifElse
active.ifElse(1, 0)is equivalent toCelExpr.of("active ? 1 : 0"). -
call
target.call(member, args)is equivalent toCelExpr.of("target.member(args)").
-