class MessageMetadataParser {

    static Map<String,Object> parseTransactionMetadata( MapValue meta ) throws BoltIOException
    {
        AnyValue anyValue = meta.get( TX_META_DATA_KEY );
        if ( anyValue == Values.NO_VALUE )
        {
            return null;
        }
        else if ( anyValue instanceof MapValue )
        {
            MapValue mapValue = (MapValue) anyValue;
            TransactionMetadataWriter writer = new TransactionMetadataWriter();
            Map<String,Object> txMeta = new HashMap<>( mapValue.size() );
            mapValue.foreach( ( key, value ) -> txMeta.put( key, writer.valueAsObject( value ) ) );
            return txMeta;
        }
        else
        {
            throw new BoltIOException( Status.Request.Invalid, "Expecting transaction metadata value to be a Map value, but got: " + anyValue );
        }
    }

    private  MessageMetadataParser();

}