1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 package org.perfidix.exceptions;
28
29 import java.lang.annotation.Annotation;
30 import java.lang.reflect.Method;
31
32
33
34
35
36
37
38 public abstract class AbstractPerfidixMethodException extends Exception {
39
40 private static final long serialVersionUID = 5251116501564408317L;
41
42
43
44
45 private transient final Throwable exec;
46
47
48
49
50 private transient final Method meth;
51
52
53 private transient final Class<? extends Annotation> relatedAnno;
54
55
56
57
58
59
60
61
62
63
64
65 public AbstractPerfidixMethodException(final Throwable paramExec, final Method paramMeth,
66 final Class<? extends Annotation> paramAnnotation) {
67 super();
68 this.exec = paramExec;
69 this.meth = paramMeth;
70 this.relatedAnno = paramAnnotation;
71 }
72
73
74
75
76
77
78 public final Method getMethod() {
79 return meth;
80 }
81
82
83
84
85
86
87 public final Throwable getExec() {
88 return exec;
89 }
90
91
92
93
94
95
96 public final Class<? extends Annotation> getRelatedAnno() {
97 return relatedAnno;
98 }
99
100
101 @Override
102 public final int hashCode() {
103 final int prime = 31;
104 int result = 1;
105 if (exec == null) {
106 result = prime * result;
107 } else {
108 result = prime * result + exec.hashCode();
109 }
110 if (meth == null) {
111 result = prime * result;
112 } else {
113 result = prime * result + meth.hashCode();
114 }
115 if (relatedAnno == null) {
116 result = prime * result;
117 } else {
118 result = prime * result + relatedAnno.hashCode();
119 }
120 return result;
121 }
122
123
124 @Override
125 public final boolean equals(final Object obj) {
126 boolean returnVal = true;
127 if (this == obj) {
128 returnVal = true;
129 }
130 if (obj == null) {
131 returnVal = false;
132 }
133 if (getClass() != obj.getClass()) {
134 returnVal = false;
135 }
136 final AbstractPerfidixMethodException other = (AbstractPerfidixMethodException)obj;
137 if (exec == null) {
138 if (other.exec != null) {
139 returnVal = false;
140 }
141 } else {
142 if (!exec.equals(other.exec)) {
143 returnVal = false;
144 }
145 }
146 if (meth == null) {
147 if (other.meth != null) {
148 returnVal = false;
149 }
150 } else {
151 if (!meth.equals(other.meth)) {
152 returnVal = false;
153 }
154 }
155 if (relatedAnno == null) {
156 if (other.relatedAnno != null) {
157 returnVal = false;
158 }
159 } else {
160 if (!relatedAnno.equals(other.relatedAnno)) {
161 returnVal = false;
162 }
163 }
164 return returnVal;
165 }
166
167
168
169
170 @Override
171 public final String toString() {
172 final StringBuilder builder = new StringBuilder();
173 builder.append(this.getClass().getSimpleName());
174 builder.append(":");
175 builder.append(this.exec.getClass().getSimpleName());
176 builder.append(":");
177 builder.append(this.relatedAnno.getClass().getSimpleName());
178 builder.append(":");
179 builder.append(this.meth.getName());
180 return builder.toString();
181 }
182
183 }