Fix checkstyle violations in openflow-protocol-api
[openflowplugin.git] / openflowjava / openflow-protocol-api / src / main / java / org / opendaylight / openflowjava / protocol / api / keys / ExperimenterIdSerializerKey.java
1 /*
2  * Copyright (c) 2014 Pantheon Technologies s.r.o. 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
9 package org.opendaylight.openflowjava.protocol.api.keys;
10
11 import org.opendaylight.yangtools.yang.binding.DataContainer;
12
13 /**
14  * Key for an experimenter id serializer.
15  *
16  * @author michal.polkorab
17  * @param <T> class of object to be serialized
18  */
19 public class ExperimenterIdSerializerKey<T extends DataContainer> extends MessageTypeKey<T>
20         implements ExperimenterSerializerKey {
21
22     private final long experimenterId;
23
24     /**
25      * Constructor.
26      *
27      * @param msgVersion protocol wire version
28      * @param experimenterId experimenter / vendor ID
29      * @param objectClass class of object to be serialized
30      */
31     public ExperimenterIdSerializerKey(short msgVersion,
32                                        long experimenterId, Class<T> objectClass) {
33         super(msgVersion, objectClass);
34         this.experimenterId = experimenterId;
35     }
36
37     @Override
38     public int hashCode() {
39         final int prime = 31;
40         int result = super.hashCode();
41         result = prime * result + hashCodeOfLong(experimenterId);
42         return result;
43     }
44
45     protected int hashCodeOfLong(long longValue) {
46         return (int) (longValue ^ longValue >>> 32);
47     }
48
49     @Override
50     public boolean equals(Object obj) {
51         if (this == obj) {
52             return true;
53         }
54         if (!super.equals(obj)) {
55             return false;
56         }
57         if (!(obj instanceof ExperimenterIdSerializerKey)) {
58             return false;
59         }
60         ExperimenterIdSerializerKey<?> other = (ExperimenterIdSerializerKey<?>) obj;
61         if (experimenterId != other.experimenterId) {
62             return false;
63         }
64         return true;
65     }
66
67     @Override
68     public String toString() {
69         return super.toString() + " experimenterID: " + experimenterId;
70     }
71 }