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