Class RuntimeEquality

  • Direct Known Subclasses:
    ProtoMessageRuntimeEquality

    @Immutable
    @Internal
    public class RuntimeEquality
    extends java.lang.Object
    RuntimeEquality contains methods for performing CEL related equality checks.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static RuntimeEquality create​(RuntimeHelpers runtimeHelper, dev.cel.common.CelOptions celOptions)  
      java.util.Optional<java.lang.Object> findInMap​(java.util.Map<?,​?> map, java.lang.Object index)  
      int hashCode​(java.lang.Object object)
      Returns the hash code consistent with the objectEquals(Object, Object) method.
      <A,​B>
      B
      indexMap​(java.util.Map<A,​B> map, A index)
      Bound-checked indexing of maps.
      <A> boolean inList​(java.util.List<A> list, A value)
      Determine whether the list contains the given value.
      <A,​B>
      boolean
      inMap​(java.util.Map<A,​B> map, A key)
      Determine whether the map contains the given key.
      boolean objectEquals​(java.lang.Object x, java.lang.Object y)
      CEL implements homogeneous equality where two values are only comparable if they have the same type, otherwise an error is thrown.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • celOptions

        protected final dev.cel.common.CelOptions celOptions
    • Method Detail

      • inList

        public <A> boolean inList​(java.util.List<A> list,
                                  A value)
        Determine whether the list contains the given value.
      • indexMap

        public <A,​B> B indexMap​(java.util.Map<A,​B> map,
                                      A index)
        Bound-checked indexing of maps.
      • inMap

        public <A,​B> boolean inMap​(java.util.Map<A,​B> map,
                                         A key)
        Determine whether the map contains the given key.
      • findInMap

        public java.util.Optional<java.lang.Object> findInMap​(java.util.Map<?,​?> map,
                                                              java.lang.Object index)
      • objectEquals

        public boolean objectEquals​(java.lang.Object x,
                                    java.lang.Object y)
        CEL implements homogeneous equality where two values are only comparable if they have the same type, otherwise an error is thrown.

        If the values are of different type, the comparison fails with an error. For aggregate types, equality

        If lists are of different length, return false, otherwise take the CEL logical AND of homogeneous equality of the elements by list position:

        • If any element comparison returns false, the list comparison returns false.
        • Otherwise, if all element comparisons return true, the list comparison returns true.
        • Otherwise, there are one or more errors, one of which is re-thrown.

        If maps have different key sets, return false, otherwise take the CEL logical AND of homogeneous equality of the values by map key:

        • If any value comparison returns false, the map comparison returns false.
        • Otherwise, if all value comparisons return true, the map comparison returns true.
        • Otherwise, there are one or more errors, one of which is re-thrown.

        Heterogeneous equality differs from homogeneous equality in that two objects may be comparable even if they are not of the same type, where type differences are usually trivially false.

      • hashCode

        public int hashCode​(java.lang.Object object)
        Returns the hash code consistent with the objectEquals(Object, Object) method. For example, hashCode(1) == hashCode(1.0) since objectEquals(1, 1.0) is true.