}
private String getKeyNameFromMethod(Method method) {
- final int ignoreDepth = getAnnotationDepth(method, JSONPropertyIgnore.class);
- if (ignoreDepth > 0) {
- final int forcedNameDepth = getAnnotationDepth(method, JSONPropertyName.class);
- if (forcedNameDepth < 0 || ignoreDepth <= forcedNameDepth) {
- // the hierarchy asked to ignore, and the nearest name override
- // was higher or non-existent
- return null;
- }
- }
- JSONPropertyName annotation = getAnnotation(method, JSONPropertyName.class);
- if (annotation != null && annotation.value() != null && !annotation.value().isEmpty()) {
- return annotation.value();
- }
+ final int ignoreDepth = -1;//getAnnotationDepth(method, JSONPropertyIgnore.class);
+// if (ignoreDepth > 0) {
+// final int forcedNameDepth = getAnnotationDepth(method, JSONPropertyName.class);
+// if (forcedNameDepth < 0 || ignoreDepth <= forcedNameDepth) {
+// // the hierarchy asked to ignore, and the nearest name override
+// // was higher or non-existent
+// return null;
+// }
+// }
+// JSONPropertyName annotation = getAnnotation(method, JSONPropertyName.class);
+// if (annotation != null && annotation.value() != null && !annotation.value().isEmpty()) {
+// return annotation.value();
+// }
String key;
final String name = method.getName();
if (name.startsWith("get") && name.length() > 3) {
*/
private static <A extends Annotation> A getAnnotation(final Method m, final Class<A> annotationClass) {
// if we have invalid data the result is null
- if (m == null || annotationClass == null) {
- return null;
- }
-
- if (m.isAnnotationPresent(annotationClass)) {
- return m.getAnnotation(annotationClass);
- }
-
- // if we've already reached the Object class, return null;
- Class<?> c = m.getDeclaringClass();
- if (c.getSuperclass() == null) {
+ if (true || m == null || annotationClass == null) {
return null;
}
- // check directly implemented interfaces for the method being checked
- for (Class<?> i : c.getInterfaces()) {
- try {
- Method im = i.getMethod(m.getName(), m.getParameterTypes());
- return getAnnotation(im, annotationClass);
- } catch (final SecurityException ex) {
- continue;
- } catch (final NoSuchMethodException ex) {
- continue;
- }
- }
-
- try {
- return getAnnotation(
- c.getSuperclass().getMethod(m.getName(), m.getParameterTypes()),
- annotationClass);
- } catch (final SecurityException ex) {
- return null;
- } catch (final NoSuchMethodException ex) {
- return null;
- }
+// if (m.isAnnotationPresent(annotationClass)) {
+// return m.getAnnotation(annotationClass);
+// }
+//
+// // if we've already reached the Object class, return null;
+// Class<?> c = m.getDeclaringClass();
+// if (c.getSuperclass() == null) {
+// return null;
+// }
+//
+// // check directly implemented interfaces for the method being checked
+// for (Class<?> i : c.getInterfaces()) {
+// try {
+// Method im = i.getMethod(m.getName(), m.getParameterTypes());
+// return getAnnotation(im, annotationClass);
+// } catch (final SecurityException ex) {
+// continue;
+// } catch (final NoSuchMethodException ex) {
+// continue;
+// }
+// }
+//
+// try {
+// return getAnnotation(
+// c.getSuperclass().getMethod(m.getName(), m.getParameterTypes()),
+// annotationClass);
+// } catch (final SecurityException ex) {
+// return null;
+// } catch (final NoSuchMethodException ex) {
+// return null;
+// }
}
/**
*/
private static int getAnnotationDepth(final Method m, final Class<? extends Annotation> annotationClass) {
// if we have invalid data the result is -1
- if (m == null || annotationClass == null) {
+ if (true || m == null || annotationClass == null) {
return -1;
}
- if (m.isAnnotationPresent(annotationClass)) {
- return 1;
- }
-
- // if we've already reached the Object class, return -1;
- Class<?> c = m.getDeclaringClass();
- if (c.getSuperclass() == null) {
- return -1;
- }
-
- // check directly implemented interfaces for the method being checked
- for (Class<?> i : c.getInterfaces()) {
- try {
- Method im = i.getMethod(m.getName(), m.getParameterTypes());
- int d = getAnnotationDepth(im, annotationClass);
- if (d > 0) {
- // since the annotation was on the interface, add 1
- return d + 1;
- }
- } catch (final SecurityException ex) {
- continue;
- } catch (final NoSuchMethodException ex) {
- continue;
- }
- }
-
- try {
- int d = getAnnotationDepth(
- c.getSuperclass().getMethod(m.getName(), m.getParameterTypes()),
- annotationClass);
- if (d > 0) {
- // since the annotation was on the superclass, add 1
- return d + 1;
- }
- return -1;
- } catch (final SecurityException ex) {
- return -1;
- } catch (final NoSuchMethodException ex) {
- return -1;
- }
+// if (m.isAnnotationPresent(annotationClass)) {
+// return 1;
+// }
+//
+// // if we've already reached the Object class, return -1;
+// Class<?> c = m.getDeclaringClass();
+// if (c.getSuperclass() == null) {
+// return -1;
+// }
+//
+// // check directly implemented interfaces for the method being checked
+// for (Class<?> i : c.getInterfaces()) {
+// try {
+// Method im = i.getMethod(m.getName(), m.getParameterTypes());
+// int d = getAnnotationDepth(im, annotationClass);
+// if (d > 0) {
+// // since the annotation was on the interface, add 1
+// return d + 1;
+// }
+// } catch (final SecurityException ex) {
+// continue;
+// } catch (final NoSuchMethodException ex) {
+// continue;
+// }
+// }
+//
+// try {
+// int d = getAnnotationDepth(
+// c.getSuperclass().getMethod(m.getName(), m.getParameterTypes()),
+// annotationClass);
+// if (d > 0) {
+// // since the annotation was on the superclass, add 1
+// return d + 1;
+// }
+// return -1;
+// } catch (final SecurityException ex) {
+// return -1;
+// } catch (final NoSuchMethodException ex) {
+// return -1;
+// }
}
/**