private Message buildMapEntryMessage ( Message . Builder mapBuilder , Field field , Object mapKey , Object mapValue ) { FieldDescriptor keyFieldDescriptor = mapBuilder . getDescriptorForType ( ) . findFieldByName ( MAP_KEY_FIELD_NAME ) ; FieldDescriptor valueFieldDescriptor = mapBuilder . getDescriptorForType ( ) . findFieldByName ( MAP_VALUE_FIELD_NAME ) ; boolean isKeyStruct = field . getMapKeyField ( ) . isStruct ( ) ; boolean isValueStruct = field . getMapValueField ( ) . isStruct ( ) ; Object convertedKey ; if ( isKeyStruct ) { convertedKey = doConvert ( ( TBase < ? , ? > ) mapKey ) ; } else { convertedKey = sanitizeRawValue ( mapKey , field . getMapKeyField ( ) ) ; } Object convertedValue ; if ( isValueStruct ) { convertedValue = doConvert ( ( TBase < ? , ? > ) mapValue ) ; } else { convertedValue = sanitizeRawValue ( mapValue , field . getMapValueField ( ) ) ; } mapBuilder . setField ( keyFieldDescriptor , convertedKey ) ; mapBuilder . setField ( valueFieldDescriptor , convertedValue ) ; return mapBuilder . build ( ) ; }
Builds a Message that contains the key value pair of a Map entry