Class CelAttributePattern


  • @Immutable
    public abstract class CelAttributePattern
    extends java.lang.Object
    A Pattern for matching against CelAttributes.

    CelAttributePatterns are structured the same as attributes, but permit some qualifiers be replaced with wildcards.

    • Constructor Detail

      • CelAttributePattern

        public CelAttributePattern()
    • Method Detail

      • 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.
      • toString

        public final java.lang.String toString()
        Overrides:
        toString in class java.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
        is not a full match, but is a partial match.
      • 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)