More cds-access-api cleanup
[controller.git] / opendaylight / md-sal / cds-access-api / src / main / java / org / opendaylight / controller / cluster / access / commands / ExistsTransactionSuccessProxyV1.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.IOException;
11 import java.io.ObjectInput;
12 import java.io.ObjectOutput;
13 import java.io.Serial;
14 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
15
16 /**
17  * Externalizable proxy for use with {@link ExistsTransactionSuccess}. It implements the initial (Boron) serialization
18  * format.
19  *
20  * @author Robert Varga
21  */
22 final class ExistsTransactionSuccessProxyV1 extends AbstractTransactionSuccessProxy<ExistsTransactionSuccess> {
23     @Serial
24     private static final long serialVersionUID = 1L;
25
26     private boolean exists;
27
28     // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
29     // be able to create instances via reflection.
30     @SuppressWarnings("checkstyle:RedundantModifier")
31     public ExistsTransactionSuccessProxyV1() {
32         // For Externalizable
33     }
34
35     ExistsTransactionSuccessProxyV1(final ExistsTransactionSuccess request) {
36         super(request);
37         exists = request.getExists();
38     }
39
40     @Override
41     public void writeExternal(final ObjectOutput out) throws IOException {
42         super.writeExternal(out);
43         out.writeBoolean(exists);
44     }
45
46     @Override
47     public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
48         super.readExternal(in);
49         exists = in.readBoolean();
50     }
51
52     @Override
53     protected ExistsTransactionSuccess createSuccess(final TransactionIdentifier target, final long sequence) {
54         return new ExistsTransactionSuccess(target, sequence, exists);
55     }
56 }