01: /*****************************************************************************
02: * Copyright (C) PicoContainer Committers. All rights reserved. *
03: * ------------------------------------------------------------------------- *
04: * The software in this package is published under the terms of the BSD *
05: * style license a copy of which has been included with this distribution in *
06: * the LICENSE.txt file. *
07: * *
08: * Original code by Joerg Schaibe *
09: *****************************************************************************/package org.picocontainer;
10:
11: import java.io.Serializable;
12: import java.lang.annotation.Annotation;
13:
14: /** @author Paul Hammant */
15: public class BindKey<T> implements Serializable {
16: /**
17: * Serialization UUID.
18: */
19: private static final long serialVersionUID = 563408828534240087L;
20:
21: private final Class<T> type;
22: private final Class<? extends Annotation> annotation;
23:
24: public BindKey(Class<T> type, Class<? extends Annotation> annotation) {
25: this .type = type;
26: this .annotation = annotation;
27: }
28:
29: public Class<T> getType() {
30: return type;
31: }
32:
33: public Class<? extends Annotation> getAnnotation() {
34: return annotation;
35: }
36:
37: public String toString() {
38: return type.getName() + ":" + annotation.getName();
39: }
40:
41: public boolean equals(Object o) {
42: if (this == o)
43: return true;
44: if (o == null || getClass() != o.getClass())
45: return false;
46:
47: BindKey<?> bindKey = (BindKey<?>) o;
48:
49: if (!annotation.equals(bindKey.annotation))
50: return false;
51: if (!type.equals(bindKey.type))
52: return false;
53:
54: return true;
55: }
56:
57: public int hashCode() {
58: int result;
59: result = type.hashCode();
60: result = 31 * result + annotation.hashCode();
61: return result;
62: }
63:
64: public static <T> BindKey<T> bindKey(Class<T> type,
65: Class<? extends Annotation> annotation) {
66: return new BindKey<T>(type, annotation);
67: }
68:
69: }
|