Merge "Fix table miss flow push"
[openflowplugin.git] / openflowplugin-api / src / main / java / org / opendaylight / openflowplugin / api / openflow / md / core / TranslatorKey.java
1 /**
2  * Copyright (c) 2013 Cisco Systems, Inc. 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.openflowplugin.api.openflow.md.core;
9
10 public class TranslatorKey {
11
12     private final int version;
13     private final String messageClass;
14
15     /**
16      * Constructor.
17      * @param version version
18      * @param messageClass message class
19      */
20     public TranslatorKey(int version, String messageClass) {
21         this.version = version;
22         this.messageClass = messageClass;
23     }
24
25     @Override
26     public int hashCode() {
27         final int prime = 31;
28         int result = 1;
29         result = prime * result
30                 + ((messageClass == null) ? 0 : messageClass.hashCode());
31         result = prime * result + version;
32         return result;
33     }
34
35     @Override
36     public boolean equals(Object obj) {
37         if (this == obj) {
38             return true;
39         }
40         if (obj == null) {
41             return false;
42         }
43         if (getClass() != obj.getClass()) {
44             return false;
45         }
46         TranslatorKey other = (TranslatorKey) obj;
47         if (messageClass == null) {
48             if (other.messageClass != null) {
49                 return false;
50             }
51         } else if (!messageClass.equals(other.messageClass)) {
52             return false;
53         }
54         return version == other.version;
55     }
56
57 }