IonValues, following
the contract of IonValue#equals(Object).
Basic usage of this class is as follows:
IonValue v1 = ...;
IonValue v2 = ...;
com.amazon.ion.util.Equivalence.ionEquals( v1, v2 );
More likely, a static import would make using this class easier.
import static com.amazon.ion.util.Equivalence.ionEquals;
...
boolean equivalent = ionEquals( v1, v2 );
Additional options are available by configuring an Equivalence
instance using Equivalence.. For example:
com.amazon.ion.util.Equivalence equivalence =
new com.amazon.ion.util.Equivalence.Builder()
.withEpsilon(1e-6)
.build();
IonValue v1 = ...;
IonValue v2 = ...;
equivalence.ionValueEquals( v1, v2 );
| Modifier and Type | Class and Description |
|---|---|
| public static class | Equivalence.
Constructs |
| pack-priv static class | Equivalence.
Contains the configuration to use when comparing Ion values. |
| pack-priv static class | Equivalence.
Class that denotes a name/value pair in Structs. |
| Modifier and Type | Field and Description |
|---|---|
| private final Equivalence. | |
| private static final Equivalence. | NON_STRICT_CONFIGURATION
Configuration that requires structural equivalence without considering annotations. |
| private static final boolean | PUBLIC_COMPARISON_API
TODO amazon-ion/ion-java/issues/26 Marker for code that needs to be altered in order to support a public comparison API to determine ordering of values, not just equality. |
| private static final Equivalence. | STRICT_CONFIGURATION
Configuration that requires strict data equivalence. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| private static int | |
| private static int | compareLobContents(final IonLob lob1, final IonLob lob2)
Compare LOB content by stream--assuming non-null. |
| private static int | compareSequences(final IonSequence s1, final IonSequence s2, final Equivalence.
|
| private static int | compareStructs(final IonStruct s1, final IonStruct s2, final Equivalence.
|
| private static int | |
| private static final Map | convertToMultiSet(final IonStruct struct, final Equivalence.
Converts an IonStruct to a multi-set for use in IonStruct equality checks. |
| private static int | ionCompareToImpl(final IonValue v1, final IonValue v2, final Equivalence.
|
| public static boolean | |
| public static boolean | Returns: true if two Ion Values represent the same data without regard to annotations.The first Ion value to compare. v1, final IonValue The second Ion value to compare. v2)Checks for structural data equivalence over two Ion Values. |
| private static boolean | ionEqualsImpl(final IonValue v1, final IonValue v2, final Equivalence.
|
| public boolean | Returns: true if two Ion Values represent the same data.The first Ion value to compare. v1, final IonValue The second Ion value to compare. v2)Checks for data equivalence over two Ion values using this Equivalence's configuration |
| configuration | back to summary |
|---|---|
| private final Equivalence. | |
| NON_STRICT_CONFIGURATION | back to summary |
|---|---|
| private static final Equivalence. Configuration that requires structural equivalence without considering annotations. | |
| PUBLIC_COMPARISON_API | back to summary |
|---|---|
| private static final boolean PUBLIC_COMPARISON_API TODO amazon-ion/ion-java/issues/26 Marker for code that needs to be altered in order to support a public comparison API to determine ordering of values, not just equality. | |
| STRICT_CONFIGURATION | back to summary |
|---|---|
| private static final Equivalence. Configuration that requires strict data equivalence.
| |
| Equivalence | back to summary |
|---|---|
| private Equivalence(Equivalence. | |
| compareAnnotations | back to summary |
|---|---|
| private static int compareAnnotations(SymbolToken[] ann1, SymbolToken[] ann2) | |
| compareLobContents | back to summary |
|---|---|
| private static int compareLobContents(final IonLob lob1, final IonLob lob2) Compare LOB content by stream--assuming non-null. | |
| compareSequences | back to summary |
|---|---|
| private static int compareSequences(final IonSequence s1, final IonSequence s2, final Equivalence. | |
| compareStructs | back to summary |
|---|---|
| private static int compareStructs(final IonStruct s1, final IonStruct s2, final Equivalence. | |
| compareSymbolTokens | back to summary |
|---|---|
| private static int compareSymbolTokens(SymbolToken tok1, SymbolToken tok2) | |
| convertToMultiSet | back to summary |
|---|---|
| private static final Map Converts an IonStruct to a multi-set for use in IonStruct equality
checks. This method returns the multi-set as a A multi-set supports order-independent equality, and may have duplicate elements.
Take special note that | |
| ionCompareToImpl | back to summary |
|---|---|
| private static int ionCompareToImpl(final IonValue v1, final IonValue v2, final Equivalence. | |
| ionEquals | back to summary |
|---|---|
| public static boolean ionEquals(final IonValue v1, final IonValue v2) Checks for strict data equivalence over two Ion Values. | |
| ionEqualsByContent | back to summary |
|---|---|
| public static boolean ionEqualsByContent(final IonValue v1, final IonValue v2) Checks for structural data equivalence over two Ion Values. That is, equivalence without considering any annotations. | |
| ionEqualsImpl | back to summary |
|---|---|
| private static boolean ionEqualsImpl(final IonValue v1, final IonValue v2, final Equivalence. | |
| ionValueEquals | back to summary |
|---|---|
| public boolean ionValueEquals(final IonValue v1, final IonValue v2) Checks for data equivalence over two Ion values using this Equivalence's configuration | |
Equivalence instances. To compare IonValues using an
Equivalence instance's configuration, call ionValueEquals(IonValue, IonValue)
on that instance rather than calling IonValue#equals(Object).
| Modifier and Type | Field and Description |
|---|---|
| private Double | |
| private boolean | |
| private int |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Equivalence | |
| public Equivalence. | Returns: this builder.the value. epsilon)The maximum absolute difference between two Ion float values for which the two values will be considered equivalent. |
| public Equivalence. | Returns: this builder.the value. maxComparisonDepth)The maximum depth to which two values will be compared. |
| public Equivalence. | Returns: this builder.the value. isStrict)When true, checks for strict data equivalence over two Ion Values. |
| epsilon | back to summary |
|---|---|
| private Double epsilon | |
| isStrict | back to summary |
|---|---|
| private boolean isStrict | |
| maxComparisonDepth | back to summary |
|---|---|
| private int maxComparisonDepth | |
| Builder | back to summary |
|---|---|
| public Builder() | |
| build | back to summary |
|---|---|
public Equivalence build()
| |
| withEpsilon | back to summary |
|---|---|
| public Equivalence. The maximum absolute difference between two Ion float values for
which the two values will be considered equivalent. Default: Ion
float values will only be considered equivalent when
| |
| withMaxComparisonDepth | back to summary |
|---|---|
| public Equivalence. The maximum depth to which two values will be compared. If the two
values to be compared are still potentially equivalent beyond this
depth,
| |
| withStrict | back to summary |
|---|---|
| public Equivalence. When true, checks for strict data equivalence over two Ion Values.
When false, checks for structural data equivalence over two Ion
Values. See
| |
| Modifier and Type | Field and Description |
|---|---|
| private final Double | |
| private final boolean | |
| private final int |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| epsilon | back to summary |
|---|---|
| private final Double epsilon | |
| isStrict | back to summary |
|---|---|
| private final boolean isStrict | |
| maxComparisonDepth | back to summary |
|---|---|
| private final int maxComparisonDepth | |
| Configuration | back to summary |
|---|---|
| pack-priv Configuration(Equivalence. | |
Structs are unordered collections of name/value pairs. The names are symbol tokens, and the values are unrestricted. Each name/value pair is called a field.
The responsibilities of this class is to expose a
Map<Field, Field> as a multi-set. A Field instance holds the name
and value of a Struct field, and counts the number of times that
name/value pair occurs within the multi-set.
For example, an IonStruct:
{
a : 123,
a : 123
}
will be converted into a multi-set Map<Field, Field> with
a single Field -> Field with occurrences of 2.
Refer to
Equivalence#convertToMultiSet(IonStruct, Configuration, int) and
Field#equals(Object) for more info.
Note
This class should only be instantiated for the sole purpose of
using it as either a key or value in a Map.
| Modifier and Type | Field and Description |
|---|---|
| private final Equivalence. | |
| private final int | |
| private final String | |
| private int | occurrences
Number of times that this specific field (with the same name and value) occurs within the struct. |
| private final IonValue |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | equals(final Object
the reference object with which to compare. other)Overrides java. This method is implicitly called by |
| public int |
| configuration | back to summary |
|---|---|
| private final Equivalence. | |
| depth | back to summary |
|---|---|
| private final int depth | |
| name | back to summary |
|---|---|
| private final String name | |
| occurrences | back to summary |
|---|---|
| private int occurrences Number of times that this specific field (with the same name and value) occurs within the struct. | |
| value | back to summary |
|---|---|
| private final IonValue value | |
| Field | back to summary |
|---|---|
| pack-priv Field(final IonValue value, final Equivalence. | |
| equals | back to summary |
|---|---|
| public boolean equals(final Object other) Overrides java. This method is implicitly called by
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |