Fix modernization issues
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / CloseTransactionChain.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.datastore.messages;
9
10 import static com.google.common.base.Preconditions.checkArgument;
11 import static java.util.Objects.requireNonNull;
12
13 import java.io.IOException;
14 import java.io.ObjectInput;
15 import java.io.ObjectOutput;
16 import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier;
17 import org.opendaylight.yangtools.concepts.Identifiable;
18
19 public class CloseTransactionChain extends VersionedExternalizableMessage
20         implements Identifiable<LocalHistoryIdentifier> {
21     private static final long serialVersionUID = 1L;
22
23     private LocalHistoryIdentifier transactionChainId;
24
25     public CloseTransactionChain() {
26     }
27
28     public CloseTransactionChain(final LocalHistoryIdentifier transactionChainId, final short version) {
29         super(version);
30         this.transactionChainId = requireNonNull(transactionChainId);
31     }
32
33     @Override
34     public LocalHistoryIdentifier getIdentifier() {
35         return transactionChainId;
36     }
37
38     @Override
39     public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
40         super.readExternal(in);
41         transactionChainId = LocalHistoryIdentifier.readFrom(in);
42     }
43
44     @Override
45     public void writeExternal(final ObjectOutput out) throws IOException {
46         super.writeExternal(out);
47         transactionChainId.writeTo(out);
48     }
49
50     public static CloseTransactionChain fromSerializable(final Object serializable) {
51         checkArgument(serializable instanceof CloseTransactionChain);
52         return (CloseTransactionChain)serializable;
53     }
54
55     public static boolean isSerializedType(final Object message) {
56         return message instanceof CloseTransactionChain;
57     }
58 }