Bug 2245 - Synchronized classes and data structures replaced by unsynchronized.
[openflowjava.git] / 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.DataObject;
12
13 /**
14  * @author michal.polkorab
15  * @param <T> class of object to be serialized
16  */
17 public class ExperimenterIdSerializerKey<T extends DataObject> extends MessageTypeKey<T>
18         implements ExperimenterSerializerKey {
19
20     private Long experimenterId;
21
22     /**
23      * @param msgVersion protocol wire version
24      * @param experimenterId experimenter / vendor ID
25      * @param objectClass class of object to be serialized
26      */
27     public ExperimenterIdSerializerKey(short msgVersion,
28             Long experimenterId, Class<T> objectClass) {
29         super(msgVersion, objectClass);
30         this.experimenterId = experimenterId;
31     }
32
33     @Override
34     public int hashCode() {
35         final int prime = 31;
36         int result = super.hashCode();
37         result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode());
38         return result;
39     }
40
41     @Override
42     public boolean equals(Object obj) {
43         if (this == obj) {
44             return true;
45         }
46         if (!super.equals(obj)) {
47             return false;
48         }
49         if (!(obj instanceof ExperimenterIdSerializerKey)) {
50             return false;
51         }
52         ExperimenterIdSerializerKey<?> other = (ExperimenterIdSerializerKey<?>) obj;
53         if (experimenterId == null) {
54             if (other.experimenterId != null) {
55                 return false;
56             }
57         } else if (!experimenterId.equals(other.experimenterId)) {
58             return false;
59         }
60         return true;
61     }
62
63     @Override
64     public String toString() {
65         return super.toString() + " experimenterID: " + experimenterId;
66     }
67 }