+
+ // override this method to return the protobuff related extension fields and their values
+ @Override public Map<GeneratedMessage.GeneratedExtension<?, ?>, String> encode() {
+ Map<GeneratedMessage.GeneratedExtension<?, ?>, String> map = new HashMap<>();
+ map.put(KeyValueMessages.key, getKey());
+ map.put(KeyValueMessages.value, getValue());
+ return map;
+ }
+
+ // override this method to assign the values from protobuff
+ @Override public Payload decode(
+ AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload payloadProtoBuff) {
+ String key = payloadProtoBuff.getExtension(KeyValueMessages.key);
+ String value = payloadProtoBuff.getExtension(KeyValueMessages.value);
+ this.setKey(key);
+ this.setValue(value);
+ return this;
+ }
+
+ @Override
+ public int size() {
+ return this.value.length() + this.key.length();
+ }
+