Add new cds-access-api proxies
[controller.git] / opendaylight / md-sal / cds-access-api / src / main / java / org / opendaylight / controller / cluster / access / commands / TransactionSuccess.java
1 /*
2  * Copyright (c) 2016 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.access.commands;
9
10 import java.io.DataInput;
11 import java.io.IOException;
12 import org.opendaylight.controller.cluster.access.ABIVersion;
13 import org.opendaylight.controller.cluster.access.concepts.RequestSuccess;
14 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
15
16 /**
17  * Abstract base class for {@link RequestSuccess}es involving specific transaction. This class is visible outside of
18  * this package solely for the ability to perform a unified instanceof check.
19  *
20  * @param <T> Message type
21  */
22 public abstract class TransactionSuccess<T extends TransactionSuccess<T>>
23         extends RequestSuccess<TransactionIdentifier, T> {
24     interface SerialForm<T extends TransactionSuccess<T>> extends RequestSuccess.SerialForm<TransactionIdentifier, T> {
25         @Override
26         default TransactionIdentifier readTarget(final DataInput in) throws IOException {
27             return TransactionIdentifier.readFrom(in);
28         }
29     }
30
31     @java.io.Serial
32     private static final long serialVersionUID = 1L;
33
34     TransactionSuccess(final TransactionIdentifier identifier, final long sequence) {
35         super(identifier, sequence);
36     }
37
38     TransactionSuccess(final T success, final ABIVersion version) {
39         super(success, version);
40     }
41
42     @Override
43     protected abstract SerialForm<T> externalizableProxy(ABIVersion version);
44 }