Merge "Replace project-specific checkstyle by odlparent's"
[openflowplugin.git] / openflowplugin-api / src / main / java / org / opendaylight / openflowplugin / api / openflow / protocol / deserialization / MessageCodeExperimenterKey.java
1 /*
2  * Copyright (c) 2016 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 package org.opendaylight.openflowplugin.api.openflow.protocol.deserialization;
9
10 import java.util.Objects;
11
12 import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterDeserializerKey;
13 import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
14
15 public class MessageCodeExperimenterKey extends MessageCodeKey implements ExperimenterDeserializerKey {
16
17     private Long experimenterId;
18
19     /**
20      * Constructor.
21      * @param version wire protocol version
22      * @param value used as distinguisher (read from binary data / buffer)
23      * @param clazz class of object that is going to be deserialized
24      * @param experimenterId experimenter id
25      */
26     public MessageCodeExperimenterKey(short version, int value, Class<?> clazz, Long experimenterId) {
27         super(version, value, clazz);
28         this.experimenterId = experimenterId;
29     }
30
31     public Long getExperimenterId() {
32         return experimenterId;
33     }
34
35     @Override
36     public int hashCode() {
37         final int prime = 31;
38         return prime * super.hashCode() + (Objects.isNull(experimenterId) ? 0 : experimenterId.intValue());
39     }
40
41     @Override
42     public boolean equals(Object obj) {
43         if (this == obj) {
44             return true;
45         }
46         if (obj == null) {
47             return false;
48         }
49         if (!(obj instanceof MessageCodeExperimenterKey)) {
50             return false;
51         }
52         MessageCodeExperimenterKey other = (MessageCodeExperimenterKey) obj;
53
54         if (experimenterId == null) {
55             if (other.experimenterId != null) {
56                 return false;
57             }
58         } else if (!experimenterId.equals(other.experimenterId)) {
59             return false;
60         }
61
62         return super.equals(obj);
63     }
64
65     @Override
66     public String toString() {
67         return super.toString() + " experimenterId: " + experimenterId;
68     }
69 }