Bug 5540 - PortConvertor, MatchConvertor
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / sal / convertor / common / InjectionResultTargetKey.java
1 /**
2  * Copyright (c) 2014 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
9 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common;
10
11 import com.google.common.base.MoreObjects.ToStringHelper;
12 import com.google.common.base.Preconditions;
13
14 /**
15  *
16  */
17 public class InjectionResultTargetKey extends InjectionKey {
18
19     private final Class<?> resultClazz;
20
21     /**
22      * @param version openflow version
23      * @param targetClazz target class
24      * @param resultClazz result class
25      */
26     public InjectionResultTargetKey(final int version, final Class<?> targetClazz, final Class<?> resultClazz) {
27         super(version, targetClazz);
28         this.resultClazz = Preconditions.checkNotNull(resultClazz);
29     }
30
31     @Override
32     public int hashCode() {
33         return super.hashCode() ^ resultClazz.hashCode();
34     }
35
36     @Override
37     public boolean equals(final Object obj) {
38         if (this == obj) {
39             return true;
40         }
41         if (!super.equals(obj)) {
42             return false;
43         }
44         final InjectionResultTargetKey other = (InjectionResultTargetKey) obj;
45         return resultClazz.equals(other.resultClazz);
46     }
47
48     @Override
49     protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
50         return super.addToStringAttributes(toStringHelper).add("resultClazz", resultClazz);
51     }
52 }