Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
AnnotationMetaData |
|
| 0.0;0 |
1 | /* | |
2 | * $Id: AnnotationMetaData.java 17838 2010-07-03 10:27:17Z rossmason $ | |
3 | * -------------------------------------------------------------------------------------- | |
4 | * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com | |
5 | * | |
6 | * The software in this package is published under the terms of the CPAL v1.0 | |
7 | * license, a copy of which has been included with this distribution in the | |
8 | * LICENSE.txt file. | |
9 | */ | |
10 | package org.mule.util.annotation; | |
11 | ||
12 | import java.lang.annotation.Annotation; | |
13 | import java.lang.annotation.ElementType; | |
14 | import java.lang.reflect.Member; | |
15 | ||
16 | /** | |
17 | * A data class that associates context information about an annotation. This class allows for associated annotation data | |
18 | * to be passed between methods. | |
19 | */ | |
20 | public class AnnotationMetaData | |
21 | { | |
22 | private ElementType type; | |
23 | ||
24 | private Member member; | |
25 | ||
26 | private Class clazz; | |
27 | ||
28 | private Annotation annotation; | |
29 | ||
30 | public AnnotationMetaData(Class clazz, Member member, ElementType type, Annotation annotation) | |
31 | 0 | { |
32 | 0 | this.type = type; |
33 | 0 | this.clazz = clazz; |
34 | 0 | this.member = member; |
35 | 0 | this.annotation = annotation; |
36 | 0 | } |
37 | ||
38 | public ElementType getType() | |
39 | { | |
40 | 0 | return type; |
41 | } | |
42 | ||
43 | public String getElementName() | |
44 | { | |
45 | 0 | if (member == null) |
46 | { | |
47 | 0 | return clazz.getName(); |
48 | } | |
49 | 0 | return member.getName(); |
50 | } | |
51 | ||
52 | public Annotation getAnnotation() | |
53 | { | |
54 | 0 | return annotation; |
55 | } | |
56 | ||
57 | public Member getMember() | |
58 | { | |
59 | 0 | return member; |
60 | } | |
61 | ||
62 | public Class getClazz() | |
63 | { | |
64 | 0 | return clazz; |
65 | } | |
66 | ||
67 | @Override | |
68 | public String toString() | |
69 | { | |
70 | 0 | return "AnnotationMetaData{" + |
71 | "type=" + type + | |
72 | ", member=" + member + | |
73 | ", clazz=" + clazz + | |
74 | ", annotation=" + annotation + | |
75 | '}'; | |
76 | } | |
77 | ||
78 | @Override | |
79 | public boolean equals(Object o) | |
80 | { | |
81 | 0 | if (this == o) |
82 | { | |
83 | 0 | return true; |
84 | } | |
85 | 0 | if (o == null || getClass() != o.getClass()) |
86 | { | |
87 | 0 | return false; |
88 | } | |
89 | ||
90 | 0 | AnnotationMetaData that = (AnnotationMetaData) o; |
91 | ||
92 | 0 | if (annotation != null ? !annotation.equals(that.annotation) : that.annotation != null) |
93 | { | |
94 | 0 | return false; |
95 | } | |
96 | 0 | if (clazz != null ? !clazz.equals(that.clazz) : that.clazz != null) |
97 | { | |
98 | 0 | return false; |
99 | } | |
100 | 0 | if (member != null ? !member.equals(that.member) : that.member != null) |
101 | { | |
102 | 0 | return false; |
103 | } | |
104 | 0 | if (type != that.type) |
105 | { | |
106 | 0 | return false; |
107 | } | |
108 | ||
109 | 0 | return true; |
110 | } | |
111 | ||
112 | @Override | |
113 | public int hashCode() | |
114 | { | |
115 | 0 | int result = type != null ? type.hashCode() : 0; |
116 | 0 | result = 31 * result + (member != null ? member.hashCode() : 0); |
117 | 0 | result = 31 * result + (clazz != null ? clazz.hashCode() : 0); |
118 | 0 | result = 31 * result + (annotation != null ? annotation.hashCode() : 0); |
119 | 0 | return result; |
120 | } | |
121 | } |