2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common;
11 import com.google.common.base.MoreObjects;
12 import com.google.common.base.MoreObjects.ToStringHelper;
13 import com.google.common.base.Preconditions;
17 * injection lookup key based on version and target object
19 public class InjectionKey {
21 private final int version;
22 private final Class<?> targetClazz;
25 * @param version openflow version
26 * @param targetClazz target class
28 public InjectionKey(final int version, final Class<?> targetClazz) {
29 this.version = version;
30 this.targetClazz = Preconditions.checkNotNull(targetClazz);
34 public int hashCode() {
35 return 31 * version + targetClazz.hashCode();
39 public boolean equals(final Object obj) {
46 if (getClass() != obj.getClass()) {
49 final InjectionKey other = (InjectionKey) obj;
50 if (version != other.version) {
53 return targetClazz.equals(other.targetClazz);
57 public final String toString() {
58 return addToStringAttributes(MoreObjects.toStringHelper(this)).toString();
61 protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
62 return toStringHelper.add("version", version).add("targetClazz", targetClazz);