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