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 ConvertorKey {
21 private final int version;
22 private final Class<?> targetClazz;
25 * @param version openflow version
26 * @param targetClazz target class
28 public ConvertorKey(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 ConvertorKey other = (ConvertorKey) obj;
50 return version == other.version && targetClazz.equals(other.targetClazz);
54 public final String toString() {
55 return addToStringAttributes(MoreObjects.toStringHelper(this)).toString();
58 protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
59 return toStringHelper.add("version", version).add("targetClazz", targetClazz);