Class GrpcMetaDataConverter
java.lang.Object
org.axonframework.axonserver.connector.util.GrpcMetaDataConverter
Utility class for converting gRPC MetaData entries into a Java Map and vice versa.
To optimize communication and minimize the loss of data structure, the MetaDataValue entries used in gRPC distinguish
between numerical values (double or long), Strings, booleans and arbitrary objects. The latter group is converted to
and from a byte[] using the configured Serializer.
- Since:
- 4.0
- Author:
- Marc Gathier
-
Constructor Summary
ConstructorsConstructorDescriptionGrpcMetaDataConverter(org.axonframework.serialization.Serializer serializer) Initialize the converter, using the givenserializerto serialize Objects. -
Method Summary
Modifier and TypeMethodDescriptionorg.axonframework.messaging.MetaDataConvert the givenMapofMetaDataValues to a Map containing the Java representations of each of those values.convertFromMetaDataValue(io.axoniq.axonserver.grpc.MetaDataValue value) Convert the givenMetaDataValueto its Java representation.io.axoniq.axonserver.grpc.MetaDataValueconvertToMetaDataValue(Object value) Convert the givenvalueinto aMetaDataValue, attempting to maintain the source type as much as possible in the returnedMetaDataValue.booleaninthashCode()
-
Constructor Details
-
GrpcMetaDataConverter
public GrpcMetaDataConverter(org.axonframework.serialization.Serializer serializer) Initialize the converter, using the givenserializerto serialize Objects.- Parameters:
serializer- theSerializerto serialize objects with
-
-
Method Details
-
convertToMetaDataValue
Convert the givenvalueinto aMetaDataValue, attempting to maintain the source type as much as possible in the returnedMetaDataValue.- A CharSequence (such as String) is stored as a 'string'
- A Float or Double values is represented as a 'double'
- A Number that is not a Double or Float is represented as a 'sint64'
- A Boolean is represented as a 'bool'
- Any other object is serialized and stored as bytes
- Parameters:
value- theObjectto convert into aMetaDataValue- Returns:
- a
MetaDataValuerepresenting the givenvalue
-
convert
public org.axonframework.messaging.MetaData convert(Map<String, io.axoniq.axonserver.grpc.MetaDataValue> metaDataMap) Convert the givenMapofMetaDataValues to a Map containing the Java representations of each of those values.See
convertToMetaDataValue(Object)for details about the mapping.- Parameters:
metaDataMap- aMapcontainingMetaDataValuerepresentations of eachMetaDatakey- Returns:
- a
MetaDatamap containing the same keys, referencing to the Java representation of each corresponding value in the givenmetaDataMap
-
convertFromMetaDataValue
Convert the givenMetaDataValueto its Java representation.See
convertToMetaDataValue(Object)for details about the mapping.- Parameters:
value- theMetaDataValueto convert to its Java representation- Returns:
- an
Objectrepresenting the same value
-
equals
-
hashCode
public int hashCode()
-