atomic-storage: remove type dependency at segment level I/O
[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 @Deprecated(since = "9.0.0", forRemoval = true)
20 public final class CloseTransactionChain extends VersionedExternalizableMessage
21         implements Identifiable<LocalHistoryIdentifier> {
22     @java.io.Serial
23     private static final long serialVersionUID = 1L;
24
25     private LocalHistoryIdentifier transactionChainId;
26
27     public CloseTransactionChain() {
28     }
29
30     public CloseTransactionChain(final LocalHistoryIdentifier transactionChainId, final short version) {
31         super(version);
32         this.transactionChainId = requireNonNull(transactionChainId);
33     }
34
35     @Override
36     public LocalHistoryIdentifier getIdentifier() {
37         return transactionChainId;
38     }
39
40     @Override
41     public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
42         super.readExternal(in);
43         transactionChainId = LocalHistoryIdentifier.readFrom(in);
44     }
45
46     @Override
47     public void writeExternal(final ObjectOutput out) throws IOException {
48         super.writeExternal(out);
49         transactionChainId.writeTo(out);
50     }
51
52     public static CloseTransactionChain fromSerializable(final Object serializable) {
53         checkArgument(serializable instanceof CloseTransactionChain);
54         return (CloseTransactionChain)serializable;
55     }
56
57     public static boolean isSerializedType(final Object message) {
58         return message instanceof CloseTransactionChain;
59     }
60 }