BUG-4283: experimenter msg support - serialization part
[openflowjava.git] / openflow-protocol-api / src / main / java / org / opendaylight / openflowjava / protocol / api / keys / ExperimenterIdTypeSerializerKey.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  * @param <T> class of object to be serialized
15  * @author michal.polkorab
16  */
17 public class ExperimenterIdTypeSerializerKey<T extends DataContainer> extends ExperimenterIdSerializerKey<T> {
18
19     private long type;
20
21     /**
22      * @param msgVersion     protocol wire version
23      * @param experimenterId experimenter / vendor ID
24      * @param type           data type according to vendor implementation
25      * @param objectClass    class of object to be serialized
26      */
27     public ExperimenterIdTypeSerializerKey(short msgVersion,
28                                            long experimenterId, long type, Class<T> objectClass) {
29         super(msgVersion, experimenterId, objectClass);
30         this.type = type;
31     }
32
33     @Override
34     public int hashCode() {
35         final int prime = 31;
36         int result = super.hashCode();
37         result = prime * result + hashCodeOfLong(type);
38         return result;
39     }
40
41     @Override
42     public boolean equals(Object obj) {
43         if (!super.equals(obj)) {
44             return false;
45         }
46         if (!(obj instanceof ExperimenterIdTypeSerializerKey)) {
47             return false;
48         }
49         ExperimenterIdTypeSerializerKey<?> other = (ExperimenterIdTypeSerializerKey<?>) obj;
50         if (type != other.type) {
51             return false;
52         }
53         return true;
54     }
55
56     @Override
57     public String toString() {
58         return super.toString() + "; type: " + type;
59     }
60 }