93121834fef254cc7b8ad8dc64e3c1b00417eb09
[controller.git] / opendaylight / md-sal / sal-akka-raft-example / src / main / java / org / opendaylight / controller / cluster / example / messages / KeyValue.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.cluster.example.messages;
9
10 import org.opendaylight.controller.cluster.raft.messages.Payload;
11
12 public final class KeyValue extends Payload {
13     private static final long serialVersionUID = 1L;
14
15     private String key;
16     private String value;
17
18     public KeyValue() {
19     }
20
21     public KeyValue(String key, String value) {
22         this.key = key;
23         this.value = value;
24     }
25
26     public String getKey() {
27         return key;
28     }
29
30     public String getValue() {
31         return value;
32     }
33
34     @Override
35     public String toString() {
36         return "KeyValue{" + "key='" + key + '\'' + ", value='" + value + '\'' + '}';
37     }
38
39     @Override
40     public int size() {
41         return value.length() + key.length();
42     }
43
44     @Override
45     protected Object writeReplace() {
46         return new KVv1(value, key);
47     }
48 }