Package dev.cel.runtime
Class CelAttributePattern
- java.lang.Object
-
- dev.cel.runtime.CelAttributePattern
-
@Immutable public abstract class CelAttributePattern extends java.lang.ObjectA Pattern for matching againstCelAttributes.CelAttributePatterns are structured the same as attributes, but permit some qualifiers be replaced with wildcards.
-
-
Constructor Summary
Constructors Constructor Description CelAttributePattern()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static CelAttributePatterncreate(com.google.common.collect.ImmutableList<CelAttribute.Qualifier> qualifiers)Constructs a CelAttributePattern from a list of qualifiers.static CelAttributePatterncreate(java.lang.String rootIdentifier)Constructs a pattern from a single root identifier (single string qualifier).static CelAttributePatternfromQualifiedIdentifier(java.lang.String qualifiedIdentifier)Attempts to parse a dot qualified identifier into a CEL attribute.booleanisMatch(CelAttribute attribute)Return whether this pattern matches the given attribute.booleanisPartialMatch(CelAttribute attribute)Return whether this pattern matches the given attribute or any of its descendants.abstract com.google.common.collect.ImmutableList<CelAttribute.Qualifier>qualifiers()The list of qualifiers representing the select paths this pattern matches.CelAttributePatternqualify(CelAttribute.Qualifier qualifier)Create a new attribute pattern that specifies a subfield of this pattern.CelAttributesimplify(CelAttribute candidate)Return an appropriate attribute for a pattern match.java.lang.StringtoString()
-
-
-
Method Detail
-
create
public static CelAttributePattern create(com.google.common.collect.ImmutableList<CelAttribute.Qualifier> qualifiers)
Constructs a CelAttributePattern from a list of qualifiers.
-
create
public static CelAttributePattern create(java.lang.String rootIdentifier)
Constructs a pattern from a single root identifier (single string qualifier).
-
fromQualifiedIdentifier
public static CelAttributePattern fromQualifiedIdentifier(java.lang.String qualifiedIdentifier)
Attempts to parse a dot qualified identifier into a CEL attribute.- Throws:
java.lang.IllegalArgumentException- if qualifiedIdentifier isn't a legal qualified identifier. Note: this is intended for use with reference names in a checked CEL expression -- it does not check for some edge cases (e.g. reserved words).
-
qualifiers
public abstract com.google.common.collect.ImmutableList<CelAttribute.Qualifier> qualifiers()
The list of qualifiers representing the select paths this pattern matches.
-
qualify
public CelAttributePattern qualify(CelAttribute.Qualifier qualifier)
Create a new attribute pattern that specifies a subfield of this pattern.
-
toString
public final java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
isMatch
public boolean isMatch(CelAttribute attribute)
Return whether this pattern matches the given attribute.A pattern matches an attribute if the pattern contains the attribute (e.g. fully matches the attribute or one of its parents).
-
isPartialMatch
public boolean isPartialMatch(CelAttribute attribute)
Return whether this pattern matches the given attribute or any of its descendants.A partial match indicates that the attribute may contain some missing data, so the complete object is may be in an undefined state. For example:
- pattern (this) object.field.list_field
- attribute (arg) object.field
-
simplify
public CelAttribute simplify(CelAttribute candidate)
Return an appropriate attribute for a pattern match.For a partial match, return the attribute.
For a full match, return the (possibly parent attribute)
-
-