2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.cluster.example.messages;
11 import com.google.protobuf.GeneratedMessage;
12 import java.io.Serializable;
14 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
15 import org.opendaylight.controller.protobuff.messages.cluster.raft.AppendEntriesMessages;
17 public class KeyValue extends Payload implements Serializable {
18 private static final long serialVersionUID = 1L;
25 public KeyValue(String key, String value){
30 public String getKey() {
34 public String getValue() {
38 public void setKey(String key) {
42 public void setValue(String value) {
46 @Override public String toString() {
48 "key='" + key + '\'' +
49 ", value='" + value + '\'' +
53 // override this method to return the protobuff related extension fields and their values
54 @Override public Map<GeneratedMessage.GeneratedExtension<?, ?>, String> encode() {
58 // override this method to assign the values from protobuff
59 @Override public Payload decode(AppendEntriesMessages.AppendEntries.ReplicatedLogEntry.Payload payloadProtoBuff) {
65 return this.value.length() + this.key.length();