Merge "Add MD-SAL artifacts"
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / ReplicatedLogImplEntry.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
9 package org.opendaylight.controller.cluster.raft;
10
11 import java.io.Serializable;
12 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
13
14 public class ReplicatedLogImplEntry implements ReplicatedLogEntry,
15     Serializable {
16     private static final long serialVersionUID = 1L;
17
18     private final long index;
19     private final long term;
20     private final Payload payload;
21
22     public ReplicatedLogImplEntry(long index, long term, Payload payload) {
23
24         this.index = index;
25         this.term = term;
26         this.payload = payload;
27     }
28
29     @Override public Payload getData() {
30         return payload;
31     }
32
33     @Override public long getTerm() {
34         return term;
35     }
36
37     @Override public long getIndex() {
38         return index;
39     }
40
41     @Override
42     public int size() {
43         return getData().size();
44     }
45
46     @Override public String toString() {
47         return "Entry{" +
48             "index=" + index +
49             ", term=" + term +
50             '}';
51     }
52 }