Merge "OPNFLWPLUG-929 : Remove deprecated guava library"
[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
9 package org.opendaylight.openflowjava.protocol.api.keys;
10
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
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 Long 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(short version,
32             int oxmClass, int oxmField) {
33         super(version, oxmClass, MatchEntry.class);
34         this.oxmField = oxmField;
35     }
36
37     /**
38      * Sets the experimenter id.
39      *
40      * @param experimenterId experimenter / vendor ID
41      */
42     public void setExperimenterId(Long experimenterId) {
43         this.experimenterId = experimenterId;
44     }
45
46     @Override
47     public int hashCode() {
48         final int prime = 31;
49         int result = super.hashCode();
50         result = prime * result + (experimenterId == null ? 0 : experimenterId.hashCode());
51         result = prime * result + oxmField;
52         return result;
53     }
54
55     @Override
56     public boolean equals(Object obj) {
57         if (this == obj) {
58             return true;
59         }
60         if (!super.equals(obj)) {
61             return false;
62         }
63         if (getClass() != obj.getClass()) {
64             return false;
65         }
66         MatchEntryDeserializerKey other = (MatchEntryDeserializerKey) obj;
67         if (experimenterId == null) {
68             if (other.experimenterId != null) {
69                 return false;
70             }
71         } else if (!experimenterId.equals(other.experimenterId)) {
72             return false;
73         }
74         if (oxmField != other.oxmField) {
75             return false;
76         }
77         return true;
78     }
79
80     @Override
81     public String toString() {
82         return super.toString() + " oxm_field: " + oxmField + " experimenterID: " + experimenterId;
83     }
84 }