|
15 | 15 | */
|
16 | 16 | package com.opensymphony.xwork2.util;
|
17 | 17 |
|
18 |
| -import org.apache.commons.lang3.ArrayUtils; |
19 |
| -import org.apache.commons.lang3.ClassUtils; |
20 |
| - |
21 | 18 | import java.lang.annotation.Annotation;
|
22 |
| -import java.lang.reflect.AnnotatedElement; |
23 | 19 | import java.lang.reflect.Field;
|
24 | 20 | import java.lang.reflect.Method;
|
25 |
| -import java.util.ArrayList; |
26 | 21 | import java.util.Arrays;
|
27 |
| -import java.util.Collection; |
28 | 22 | import java.util.List;
|
29 | 23 | import java.util.regex.Matcher;
|
30 | 24 | import java.util.regex.Pattern;
|
@@ -107,113 +101,6 @@ public static void addAllInterfaces(Class clazz, List<Class> allInterfaces) {
|
107 | 101 | addAllInterfaces(clazz.getSuperclass(), allInterfaces);
|
108 | 102 | }
|
109 | 103 |
|
110 |
| - /** |
111 |
| - * For the given <code>Class</code> get a collection of the the {@link AnnotatedElement}s |
112 |
| - * that match the given <code>annotation</code>s or if no <code>annotation</code>s are |
113 |
| - * specified then return all of the annotated elements of the given <code>Class</code>. |
114 |
| - * Includes only the method level annotations. |
115 |
| - * |
116 |
| - * @param clazz The {@link Class} to inspect |
117 |
| - * @param annotation the {@link Annotation}s to find |
118 |
| - * @return A {@link Collection}<{@link AnnotatedElement}> containing all of the |
119 |
| - * method {@link AnnotatedElement}s matching the specified {@link Annotation}s |
120 |
| - * @deprecated Will be removed after release of <a href="https://github.com/apache/commons-lang/pull/261">LANG-1317</a> |
121 |
| - */ |
122 |
| - @Deprecated |
123 |
| - public static Collection<Method> getAnnotatedMethods(Class clazz, Class<? extends Annotation>... annotation) { |
124 |
| - List<Class<?>> allSuperclasses = ClassUtils.getAllSuperclasses(clazz); |
125 |
| - allSuperclasses.add(0, clazz); |
126 |
| - int sci = 0; |
127 |
| - List<Class<?>> allInterfaces = ClassUtils.getAllInterfaces(clazz); |
128 |
| - int ifi = 0; |
129 |
| - final List<Method> annotatedMethods = new ArrayList<>(); |
130 |
| - while (ifi < allInterfaces.size() || |
131 |
| - sci < allSuperclasses.size()) { |
132 |
| - Class<?> acls; |
133 |
| - if (ifi >= allInterfaces.size()) { |
134 |
| - acls = allSuperclasses.get(sci++); |
135 |
| - } |
136 |
| - else if (sci >= allSuperclasses.size()) { |
137 |
| - acls = allInterfaces.get(ifi++); |
138 |
| - } |
139 |
| - else if (sci <= ifi) { |
140 |
| - acls = allSuperclasses.get(sci++); |
141 |
| - } |
142 |
| - else { |
143 |
| - acls = allInterfaces.get(ifi++); |
144 |
| - } |
145 |
| - final Method[] allMethods = acls.getDeclaredMethods(); |
146 |
| - for (final Method method : allMethods) { |
147 |
| - if (ArrayUtils.isEmpty(annotation) && ArrayUtils.isNotEmpty(method.getAnnotations())) { |
148 |
| - annotatedMethods.add(method); |
149 |
| - continue; |
150 |
| - } |
151 |
| - for (Class<? extends Annotation> c : annotation) { |
152 |
| - if (method.getAnnotation(c) != null) { |
153 |
| - annotatedMethods.add(method); |
154 |
| - } |
155 |
| - } |
156 |
| - } |
157 |
| - } |
158 |
| - |
159 |
| - return annotatedMethods; |
160 |
| - } |
161 |
| - |
162 |
| - /** |
163 |
| - * <p>BFS to find the annotation object that is present on the given method or any equivalent method in |
164 |
| - * super classes and interfaces, with the given annotation type. Returns null if the annotation type was not present |
165 |
| - * on any of them.</p> |
166 |
| - * @param <A> |
167 |
| - * the annotation type |
168 |
| - * @param method |
169 |
| - * the {@link Method} to query |
170 |
| - * @param annotationCls |
171 |
| - * the {@link Annotation} to check if is present on the method |
172 |
| - * @return an Annotation (possibly null). |
173 |
| - * @deprecated Will be removed after release of <a href="https://github.com/apache/commons-lang/pull/261">LANG-1317</a> |
174 |
| - */ |
175 |
| - @Deprecated |
176 |
| - public static <A extends Annotation> A findAnnotation(final Method method, final Class<A> annotationCls) { |
177 |
| - A annotation = method.getAnnotation(annotationCls); |
178 |
| - |
179 |
| - if(annotation == null) { |
180 |
| - Class<?> mcls = method.getDeclaringClass(); |
181 |
| - List<Class<?>> allSuperclasses = ClassUtils.getAllSuperclasses(mcls); |
182 |
| - int sci = 0; |
183 |
| - List<Class<?>> allInterfaces = ClassUtils.getAllInterfaces(mcls); |
184 |
| - int ifi = 0; |
185 |
| - while (ifi < allInterfaces.size() || |
186 |
| - sci < allSuperclasses.size()) { |
187 |
| - Class<?> acls; |
188 |
| - if(ifi >= allInterfaces.size()) { |
189 |
| - acls = allSuperclasses.get(sci++); |
190 |
| - } |
191 |
| - else if(sci >= allSuperclasses.size()) { |
192 |
| - acls = allInterfaces.get(ifi++); |
193 |
| - } |
194 |
| - else if(ifi <= sci) { |
195 |
| - acls = allInterfaces.get(ifi++); |
196 |
| - } |
197 |
| - else { |
198 |
| - acls = allSuperclasses.get(sci++); |
199 |
| - } |
200 |
| - Method equivalentMethod = null; |
201 |
| - try { |
202 |
| - equivalentMethod = acls.getDeclaredMethod(method.getName(), method.getParameterTypes()); |
203 |
| - } catch (NoSuchMethodException e) { |
204 |
| - // If not found, just keep on breadth first search |
205 |
| - } |
206 |
| - if(equivalentMethod != null) { |
207 |
| - annotation = equivalentMethod.getAnnotation(annotationCls); |
208 |
| - if(annotation != null) { |
209 |
| - break; |
210 |
| - } |
211 |
| - } |
212 |
| - } |
213 |
| - } |
214 |
| - return annotation; |
215 |
| - } |
216 |
| - |
217 | 104 | /**
|
218 | 105 | * Returns the property name for a method.
|
219 | 106 | * This method is independent from property fields.
|
|
0 commit comments