Class MetadataConverter

java.lang.Object
io.axoniq.framework.axonserver.connector.shared.MetadataConverter

@Internal public final class MetadataConverter extends Object
Utility class to convert between Axon Server metadata values and a simple Map of String key-value pairs.

This class provides methods to convert a Map of String key-value pairs to a Map of Axon Server MetaDataValue objects and vice versa.

Since:
5.0.0
Author:
Steven van Beelen, Mitchell Herrijgers, Allard Buijze
  • Method Details

    • convertMetadataMapToGrpc

      public static Map<String,io.axoniq.axonserver.grpc.MetaDataValue> convertMetadataMapToGrpc(Map<String,@Nullable String> source)
      Converts a Map of String key-value pairs to a Map of Axon Server MetaDataValue objects.
      Parameters:
      source - The source map containing String key-value pairs.
      Returns:
      A map where each value is converted to an Axon Server MetaDataValue.
    • convertGrpcToMetadataMap

      public static Map<String,@Nullable String> convertGrpcToMetadataMap(Map<String,io.axoniq.axonserver.grpc.MetaDataValue> source)
      Converts a Map of Axon Server MetaDataValue objects to a Map of String key-value pairs.

      Text, double, number and boolean values are converted to their String representation. A bytes_value, which Axon Framework 4 used for anything that was not text, a number or a boolean, is converted by using its bytes as UTF-8 text, such as JSON or XML. When these bytes are not valid text, for example due to a binary serializer, the key is kept with a null value and a warning is logged once per key. A MetaDataValue without any value is converted to a null value as well, without a warning.

      Parameters:
      source - the source map containing Axon Server MetaDataValue objects
      Returns:
      a map where each value is converted to a String representation, or null if it cannot be converted