8ceb7ccb197b34b983fed511239268a79c176403
[openflowjava.git] / openflow-protocol-api / src / main / java / org / opendaylight / openflowjava / protocol / api / keys / MatchEntrySerializerKey.java
1 /*\r
2  * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 \r
9 package org.opendaylight.openflowjava.protocol.api.keys;\r
10 \r
11 import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey;\r
12 import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterSerializerKey;\r
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase;\r
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
16 \r
17 /**\r
18  * @author michal.polkorab\r
19  * @param <OXM_CLASS> oxm_class (see specification)\r
20  * @param <OXM_FIELD> oxm_field (see specification)\r
21  */\r
22 public class MatchEntrySerializerKey<OXM_CLASS extends OxmClassBase, OXM_FIELD extends MatchField>\r
23         extends MessageTypeKey<MatchEntries> implements ExperimenterSerializerKey{\r
24 \r
25     private Class<OXM_CLASS> oxmClass;\r
26     private Class<OXM_FIELD> oxmField;\r
27     private Long experimenterId;\r
28 \r
29     /**\r
30      * @param msgVersion protocol wire version\r
31      * @param objectType class of serialized object\r
32      * @param oxmClass oxm_class (see specification)\r
33      * @param oxmField oxm_field (see specification)\r
34      */\r
35     public MatchEntrySerializerKey(short msgVersion, Class<OXM_CLASS> oxmClass,\r
36             Class<OXM_FIELD> oxmField) {\r
37         super(msgVersion, MatchEntries.class);\r
38         this.oxmClass = oxmClass;\r
39         this.oxmField = oxmField;\r
40     }\r
41 \r
42     /**\r
43      * @param experimenterId experimenter / vendor ID\r
44      */\r
45     public void setExperimenterId(Long experimenterId) {\r
46         this.experimenterId = experimenterId;\r
47     }\r
48 \r
49     @Override\r
50     public boolean equals(Object obj) {\r
51         if (this == obj)\r
52             return true;\r
53         if (!super.equals(obj))\r
54             return false;\r
55         if (getClass() != obj.getClass())\r
56             return false;\r
57         @SuppressWarnings("rawtypes")\r
58         MatchEntrySerializerKey other = (MatchEntrySerializerKey) obj;\r
59         if (experimenterId == null) {\r
60             if (other.experimenterId != null)\r
61                 return false;\r
62         } else if (!experimenterId.equals(other.experimenterId))\r
63             return false;\r
64         if (oxmClass == null) {\r
65             if (other.oxmClass != null)\r
66                 return false;\r
67         } else if (!oxmClass.equals(other.oxmClass))\r
68             return false;\r
69         if (oxmField == null) {\r
70             if (other.oxmField != null)\r
71                 return false;\r
72         } else if (!oxmField.equals(other.oxmField))\r
73             return false;\r
74         return true;\r
75     }\r
76 \r
77     @Override\r
78     public String toString() {\r
79         return super.toString() + " oxm_class: " + oxmClass.getName() + " oxm_field: "\r
80                 + oxmField.getName() + " experimenterID: " + experimenterId;\r
81     }\r
82 }