BUG-5280: introduce request/response Envelope
[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 org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
14
15 /**
16  * Externalizable proxy for use with {@link ExistsTransactionSuccess}. It implements the initial (Boron) serialization
17  * format.
18  *
19  * @author Robert Varga
20  */
21 final class ExistsTransactionSuccessProxyV1 extends AbstractTransactionSuccessProxy<ExistsTransactionSuccess> {
22     private static final long serialVersionUID = 1L;
23     private boolean exists;
24
25     public ExistsTransactionSuccessProxyV1() {
26         // For Externalizable
27     }
28
29     ExistsTransactionSuccessProxyV1(final ExistsTransactionSuccess request) {
30         super(request);
31         this.exists = request.getExists();
32     }
33
34     @Override
35     public void writeExternal(final ObjectOutput out) throws IOException {
36         super.writeExternal(out);
37         out.writeBoolean(exists);
38     }
39
40     @Override
41     public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
42         super.readExternal(in);
43         exists = in.readBoolean();
44     }
45
46     @Override
47     protected ExistsTransactionSuccess createSuccess(final TransactionIdentifier target) {
48         return new ExistsTransactionSuccess(target, exists);
49     }
50 }