Class OrderedSetSerializer<T>
java.lang.Object
com.fasterxml.jackson.databind.JsonSerializer<Set<T>>
io.fliqa.client.interledger.serializer.OrderedSetSerializer<T>
- Type Parameters:
T- the type of elements contained in the set to be serialized
- All Implemented Interfaces:
com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitable
A custom serializer for
Set collections that serializes the elements
in a deterministic order based on their string representations.
The OrderedSetSerializer ensures that the serialization output
for a Set is consistent irrespective of the initial ordering
of the elements within the set. It accomplishes this by converting each
element in the set to its toString() representation, sorting these
string representations in natural order, and then writing them as a JSON array.
This serializer is useful in scenarios where consistent JSON output is required, such as when generating hashes, for debugging purposes, or for API clients requiring deterministic outputs for identical data sets.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.JsonSerializer
com.fasterxml.jackson.databind.JsonSerializer.None -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class com.fasterxml.jackson.databind.JsonSerializer
acceptJsonFormatVisitor, getDelegatee, handledType, isEmpty, isEmpty, isUnwrappingSerializer, properties, replaceDelegatee, serializeWithType, unwrappingSerializer, usesObjectId, withFilterId, withIgnoredProperties
-
Constructor Details
-
OrderedSetSerializer
public OrderedSetSerializer()
-
-
Method Details
-
serialize
public void serialize(Set<T> value, com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.databind.SerializerProvider serializers) throws IOException - Specified by:
serializein classcom.fasterxml.jackson.databind.JsonSerializer<Set<T>>- Throws:
IOException
-