Package dev.cel.runtime
Class RuntimeEquality
- java.lang.Object
-
- dev.cel.runtime.RuntimeEquality
-
- Direct Known Subclasses:
ProtoMessageRuntimeEquality
@Immutable @Internal public class RuntimeEquality extends java.lang.ObjectRuntimeEquality contains methods for performing CEL related equality checks.
-
-
Field Summary
Fields Modifier and Type Field Description protected dev.cel.common.CelOptionscelOptionsprotected RuntimeHelpersruntimeHelpers
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static RuntimeEqualitycreate(RuntimeHelpers runtimeHelper, dev.cel.common.CelOptions celOptions)java.util.Optional<java.lang.Object>findInMap(java.util.Map<?,?> map, java.lang.Object index)inthashCode(java.lang.Object object)Returns the hash code consistent with theobjectEquals(Object, Object)method.<A,B>
BindexMap(java.util.Map<A,B> map, A index)Bound-checked indexing of maps.<A> booleaninList(java.util.List<A> list, A value)Determine whether thelistcontains the givenvalue.<A,B>
booleaninMap(java.util.Map<A,B> map, A key)Determine whether themapcontains the givenkey.booleanobjectEquals(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.
-
-
-
Field Detail
-
runtimeHelpers
protected final RuntimeHelpers runtimeHelpers
-
celOptions
protected final dev.cel.common.CelOptions celOptions
-
-
Method Detail
-
create
public static RuntimeEquality create(RuntimeHelpers runtimeHelper, dev.cel.common.CelOptions celOptions)
-
inList
public <A> boolean inList(java.util.List<A> list, A value)Determine whether thelistcontains the givenvalue.
-
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 themapcontains the givenkey.
-
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 theobjectEquals(Object, Object)method. For example,hashCode(1) == hashCode(1.0)sinceobjectEquals(1, 1.0)is true.
-
-