Mass replace CRLF->LF
[openflowjava.git] / openflow-protocol-api / src / main / java / org / opendaylight / openflowjava / protocol / api / keys / MatchEntrySerializerKey.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.openflowjava.protocol.api.extensibility.MessageTypeKey;
12 import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterSerializerKey;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
16
17 /**
18  * @author michal.polkorab
19  * @param <OXM_CLASS> oxm_class (see specification)
20  * @param <OXM_FIELD> oxm_field (see specification)
21  */
22 public final class MatchEntrySerializerKey<OXM_CLASS extends OxmClassBase, OXM_FIELD extends MatchField>
23         extends MessageTypeKey<MatchEntries> implements ExperimenterSerializerKey {
24
25     private Class<OXM_CLASS> oxmClass;
26     private Class<OXM_FIELD> oxmField;
27     private Long experimenterId;
28
29     /**
30      * @param msgVersion protocol wire version
31      * @param objectType class of serialized object
32      * @param oxmClass oxm_class (see specification)
33      * @param oxmField oxm_field (see specification)
34      */
35     public MatchEntrySerializerKey(short msgVersion, Class<OXM_CLASS> oxmClass,
36             Class<OXM_FIELD> oxmField) {
37         super(msgVersion, MatchEntries.class);
38         this.oxmClass = oxmClass;
39         this.oxmField = oxmField;
40     }
41
42     /**
43      * @param experimenterId experimenter / vendor ID
44      */
45     public void setExperimenterId(Long experimenterId) {
46         this.experimenterId = experimenterId;
47     }
48
49     @Override
50     public int hashCode() {
51         final int prime = 31;
52         int result = super.hashCode();
53         result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode());
54         result = prime * result + ((oxmClass == null) ? 0 : oxmClass.hashCode());
55         result = prime * result + ((oxmField == null) ? 0 : oxmField.hashCode());
56         return result;
57     }
58
59     @Override
60     public boolean equals(Object obj) {
61         if (this == obj) {
62             return true;
63         }
64         if (!super.equals(obj)) {
65             return false;
66         }
67         if (getClass() != obj.getClass()) {
68             return false;
69         }
70         MatchEntrySerializerKey<?, ?> other = (MatchEntrySerializerKey<?, ?>) obj;
71         if (experimenterId == null) {
72             if (other.experimenterId != null) {
73                 return false;
74             }
75         } else if (!experimenterId.equals(other.experimenterId)) {
76             return false;
77         }
78         if (oxmClass == null) {
79             if (other.oxmClass != null) {
80                 return false;
81             }
82         } else if (!oxmClass.equals(other.oxmClass)) {
83             return false;
84         }
85         if (oxmField == null) {
86             if (other.oxmField != null) {
87                 return false;
88             }
89         } else if (!oxmField.equals(other.oxmField)) {
90             return false;
91         }
92         return true;
93     }
94
95     @Override
96     public String toString() {
97         return super.toString() + " oxm_class: " + oxmClass.getName() + " oxm_field: "
98                 + oxmField.getName() + " experimenterID: " + experimenterId;
99     }
100 }