@Override public byte[] toBytes(Map<String, String> tagContext) { if (tagContext == null) { throw new NullPointerException("tagContext == null"); // programming error } if (tagContext.isEmpty()) return EMPTY_BYTES; byte[] result = new byte[sizeInBytes(tagContext)]; Buffer bytes = new Buffer(result); bytes.writeByte(VERSION); for (Map.Entry<String, String> entry : tagContext.entrySet()) { bytes.writeByte(TAG_FIELD_ID); bytes.writeLengthPrefixed(entry.getKey()); bytes.writeLengthPrefixed(entry.getValue()); } return result; }
@Override public byte[] toBytes(Map<String, String> tagContext) { if (tagContext == null) { throw new NullPointerException("tagContext == null"); // programming error } if (tagContext.isEmpty()) return EMPTY_BYTES; byte[] result = new byte[sizeInBytes(tagContext)]; Buffer bytes = new Buffer(result); bytes.writeByte(VERSION); for (Map.Entry<String, String> entry : tagContext.entrySet()) { bytes.writeByte(TAG_FIELD_ID); bytes.writeLengthPrefixed(entry.getKey()); bytes.writeLengthPrefixed(entry.getValue()); } return result; }