Class RuntimeEquality


  • @Internal
    @Immutable
    public final class RuntimeEquality
    extends java.lang.Object
    CEL Library Internals. Do Not Use.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Optional<java.lang.Object> findInMap​(java.util.Map<?,​?> map, java.lang.Object index, CelOptions celOptions)  
      <A,​B>
      B
      indexMap​(java.util.Map<A,​B> map, A index, CelOptions celOptions)
      Bound-checked indexing of maps.
      <A> boolean inList​(java.util.List<A> list, A value, CelOptions celOptions)
      Determine whether the list contains the given value.
      <A,​B>
      boolean
      inMap​(java.util.Map<A,​B> map, A key, CelOptions celOptions)
      Determine whether the map contains the given key.
      boolean objectEquals​(java.lang.Object x, java.lang.Object y, CelOptions celOptions)
      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
    • Constructor Detail

      • RuntimeEquality

        public RuntimeEquality​(DynamicProto dynamicProto)
    • Method Detail

      • inList

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

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

        public <A,​B> boolean inMap​(java.util.Map<A,​B> map,
                                         A key,
                                         CelOptions celOptions)
        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,
                                                              CelOptions celOptions)
      • objectEquals

        public boolean objectEquals​(java.lang.Object x,
                                    java.lang.Object y,
                                    CelOptions celOptions)
        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. Heterogeneous runtime equality is under consideration in b/71516544.

        Note, uint values are problematic in that they cannot be properly type-tested for equality in comparisons with 64-int signed integer values, see b/159183198. This problem only affects Java and is typically inconsequential due to the requirement for type-checking expressions before they are evaluated.