Fix CS warnings in cds-access-api and enable enforcement
[controller.git] / opendaylight / md-sal / cds-access-api / src / main / java / org / opendaylight / controller / cluster / access / commands / ConnectClientRequestProxyV1.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 akka.actor.ActorRef;
11 import java.io.DataInput;
12 import java.io.IOException;
13 import java.io.ObjectInput;
14 import java.io.ObjectOutput;
15 import org.opendaylight.controller.cluster.access.ABIVersion;
16 import org.opendaylight.controller.cluster.access.concepts.AbstractRequestProxy;
17 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
18
19 /**
20  * Externalizable proxy for use with {@link ConnectClientRequest}. It implements the initial (Boron) serialization
21  * format.
22  *
23  * @author Robert Varga
24  */
25 final class ConnectClientRequestProxyV1 extends AbstractRequestProxy<ClientIdentifier, ConnectClientRequest> {
26     private ABIVersion minVersion;
27     private ABIVersion maxVersion;
28
29     // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
30     // be able to create instances via reflection.
31     @SuppressWarnings("checkstyle:RedundantModifier")
32     public ConnectClientRequestProxyV1() {
33         // for Externalizable
34     }
35
36     ConnectClientRequestProxyV1(final ConnectClientRequest request) {
37         super(request);
38         this.minVersion = request.getMinVersion();
39         this.maxVersion = request.getMaxVersion();
40     }
41
42     @Override
43     public void writeExternal(final ObjectOutput out) throws IOException {
44         super.writeExternal(out);
45         minVersion.writeTo(out);
46         maxVersion.writeTo(out);
47     }
48
49     @Override
50     public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
51         super.readExternal(in);
52         minVersion = ABIVersion.inexactReadFrom(in);
53         maxVersion = ABIVersion.inexactReadFrom(in);
54     }
55
56     @Override
57     protected ConnectClientRequest createRequest(final ClientIdentifier target, final long sequence,
58             final ActorRef replyTo) {
59         return new ConnectClientRequest(target, sequence, replyTo, minVersion, maxVersion);
60     }
61
62     @Override
63     protected ClientIdentifier readTarget(final DataInput in) throws IOException {
64         return ClientIdentifier.readFrom(in);
65     }
66 }