Provides equivalence comparisons between two
IonValue
s, following
the contract of
IonValue.equals(Object)
.
Basic usage of this class is as follows:
IonValue v1 = ...;
IonValue v2 = ...;
software.amazon.ion.util.Equivalence.ionEquals( v1, v2 );
More likely, a static import would make using this class easier.
import static software.amazon.ion.util.Equivalence.ionEquals;
...
boolean equivalent = ionEquals( v1, v2 );
Ion Equivalence
In order to make Ion a useful model to describe data, we must first define
the notion of equivalence for all values representable in Ion. Equivalence
with respect to Ion values means that if two Ion values, X and Y, are
equivalent, they represent the same data and can be substituted for the other
without loss of information.
This relationship is:
-
symmetric: X is equivalent to Y if and only if Y is equivalent to X.
-
transitive: if X is equivalent to Y and Y is equivalent to Z, then X is
equivalent to Z.
-
reflexive: X is equivalent to X.
Ordered Sequence Equivalence
When an ordered sequence (i.e. tuple) of elements is specified in this
document, equivalence over such an ordered sequence is defined as follows.
A tuple, A = (a1, a2, ..., an), is equivalent to another tuple, B = (b1, b2,
..., bm) if and only if the cardinality (number of elements) of A equals the
cardinality of B (i.e. n == m) and ai is equivalent to bi for i = 1 ... n.
Un-Ordered Sequence Equivalence
When an un-ordered sequence (i.e. bag or multi-set) is specified in this
document, equivalence over such a sequence is defined as follows.
A bag, A = {a1, a2, ..., an} is equivalent to B = {b1, b2, ..., bm} if and
only if the cardinality of A is equal to the cardinality of B and for each
element, x, in A there exists a distinct element, y, in B for which x is
equivalent to y.
Values
Any arbitrary, atomic value in the Ion Language can be denoted as the tuple,
(A, V), where A is an ordered list of annotations, and V is an Ion Primitive
Data or Ion Complex Data value. The list of annotations, A is an tuple of Ion
Symbols (a specific type of Ion Primitive).