Bug 6674 - the key of the serialization function registered by the vendor is not...
[openflowjava.git] / openflow-protocol-api / src / main / java / org / opendaylight / openflowjava / protocol / api / keys / ExperimenterIdMeterSubTypeSerializerKey.java
1 /*
2  * Copyright (c) 2016 ZTE, 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.openflowjava.protocol.api.keys;
9
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterMeterBandSubType;
11 import org.opendaylight.yangtools.yang.binding.DataContainer;
12
13 /**
14  * Created by hyy on 2016/9/8.
15  */
16 public class ExperimenterIdMeterSubTypeSerializerKey<T extends DataContainer> extends ExperimenterIdSerializerKey<T> {
17
18     private Class<? extends ExperimenterMeterBandSubType> meterSubType;
19
20     /**
21      * @param msgVersion      protocol wire version
22      * @param experimenterId  experimenter / vendor ID
23      * @param objectClass     class of object to be serialized
24      * @param meterSubType    vendor defined subtype
25      */
26     public ExperimenterIdMeterSubTypeSerializerKey(short msgVersion, long experimenterId,
27                                                    Class<T> objectClass, Class<? extends ExperimenterMeterBandSubType> meterSubType) {
28         super(msgVersion, experimenterId, objectClass);
29         this.meterSubType = meterSubType;
30     }
31
32     @Override
33     public int hashCode() {
34         final int prime = 31;
35         int result = super.hashCode();
36         result = prime * result + ((meterSubType == null) ? 0 : meterSubType.hashCode());
37         return result;
38     }
39
40     @Override
41     public boolean equals(Object obj) {
42         if (this == obj) {
43             return true;
44         }
45         if (!super.equals(obj)) {
46             return false;
47         }
48         if (getClass() != obj.getClass()) {
49             return false;
50         }
51         ExperimenterIdMeterSubTypeSerializerKey other = (ExperimenterIdMeterSubTypeSerializerKey) obj;
52         if (meterSubType == null) {
53             if (other.meterSubType != null) {
54                 return false;
55             }
56         } else if (!meterSubType.equals(other.meterSubType)) {
57             return false;
58         }
59         return true;
60     }
61
62 }