Merge "OPNFLWPLUG-1076 Migrate lldp-speaker, forwardingrules-sync and arbitratorrecon...
[openflowplugin.git] / openflowjava / openflow-protocol-api / src / main / java / org / opendaylight / openflowjava / protocol / api / keys / MatchEntryDeserializerKey.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 package org.opendaylight.openflowjava.protocol.api.keys;
9
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
11 import org.opendaylight.yangtools.yang.common.Uint32;
12
13 /**
14  * Key for a match entry deserializer.
15  *
16  * @author michal.polkorab
17  */
18 public final class MatchEntryDeserializerKey extends MessageCodeKey
19         implements ExperimenterDeserializerKey {
20
21     private final int oxmField;
22     private Uint32 experimenterId;
23
24     /**
25      * Constructor.
26      *
27      * @param version protocol wire version
28      * @param oxmClass oxm_class (see specification)
29      * @param oxmField oxm_field (see specification)
30      */
31     public MatchEntryDeserializerKey(final short version, final int oxmClass, final int oxmField) {
32         super(version, oxmClass, MatchEntry.class);
33         this.oxmField = oxmField;
34     }
35
36     /**
37      * Sets the experimenter id.
38      *
39      * @param experimenterId experimenter / vendor ID
40      */
41     public void setExperimenterId(final Uint32 experimenterId) {
42         this.experimenterId = experimenterId;
43     }
44
45     @Override
46     public int hashCode() {
47         final int prime = 31;
48         int result = super.hashCode();
49         result = prime * result + (experimenterId == null ? 0 : experimenterId.hashCode());
50         result = prime * result + oxmField;
51         return result;
52     }
53
54     @Override
55     public boolean equals(final Object obj) {
56         if (this == obj) {
57             return true;
58         }
59         if (!super.equals(obj)) {
60             return false;
61         }
62         if (getClass() != obj.getClass()) {
63             return false;
64         }
65         MatchEntryDeserializerKey other = (MatchEntryDeserializerKey) obj;
66         if (experimenterId == null) {
67             if (other.experimenterId != null) {
68                 return false;
69             }
70         } else if (!experimenterId.equals(other.experimenterId)) {
71             return false;
72         }
73         if (oxmField != other.oxmField) {
74             return false;
75         }
76         return true;
77     }
78
79     @Override
80     public String toString() {
81         return super.toString() + " oxm_field: " + oxmField + " experimenterID: " + experimenterId;
82     }
83 }