AnnotationUtils little cleanup (#467)
* LANG-1480 getAbbreviatedName refactored to create appropriate length short class names * LANG-1480 code fixed for special extreme case ".." abbreviated to 1 length should result ".." it was throwing exception. Tests are added * import changed to avoid wild cards apache master merged into current branch * Mutable object import was moved to it's original place * some accidental formatting reverted * some accidental formatting reverted * some accidental formatting reverted * some accidental formatting reverted * some accidental formatting reverted * some accidental formatting reverted * some accidental formatting reverted * added another test case * LANG-1480 fixing JavaDoc documentation as per requested by garydgregory * LANG-1480 shortcut implemented, argument renamed, more tests * LANG-1480 checkstyle update * LANG-1492 tests methods modified to be public * LANG-1480 imports rearranged * LANG-1480 imports rearranged * LANG-1480 imports rearranged * little refactor * unused import deleted * space+ * space-
This commit is contained in:
parent
bedae6950d
commit
f3ad91ca38
|
@ -68,19 +68,13 @@ public class AnnotationUtils {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected String getShortClassName(final java.lang.Class<?> cls) {
|
||||
Class<? extends Annotation> annotationType = null;
|
||||
protected String getShortClassName(final Class<?> cls) {
|
||||
for (final Class<?> iface : ClassUtils.getAllInterfaces(cls)) {
|
||||
if (Annotation.class.isAssignableFrom(iface)) {
|
||||
@SuppressWarnings("unchecked") // OK because we just checked the assignability
|
||||
final
|
||||
Class<? extends Annotation> found = (Class<? extends Annotation>) iface;
|
||||
annotationType = found;
|
||||
break;
|
||||
return "@" + iface.getName();
|
||||
}
|
||||
}
|
||||
return new StringBuilder(annotationType == null ? StringUtils.EMPTY : annotationType.getName())
|
||||
.insert(0, '@').toString();
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -125,15 +119,15 @@ public class AnnotationUtils {
|
|||
if (a1 == null || a2 == null) {
|
||||
return false;
|
||||
}
|
||||
final Class<? extends Annotation> type = a1.annotationType();
|
||||
final Class<? extends Annotation> type1 = a1.annotationType();
|
||||
final Class<? extends Annotation> type2 = a2.annotationType();
|
||||
Validate.notNull(type, "Annotation %s with null annotationType()", a1);
|
||||
Validate.notNull(type1, "Annotation %s with null annotationType()", a1);
|
||||
Validate.notNull(type2, "Annotation %s with null annotationType()", a2);
|
||||
if (!type.equals(type2)) {
|
||||
if (!type1.equals(type2)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
for (final Method m : type.getDeclaredMethods()) {
|
||||
for (final Method m : type1.getDeclaredMethods()) {
|
||||
if (m.getParameterTypes().length == 0
|
||||
&& isValidAnnotationMemberType(m.getReturnType())) {
|
||||
final Object v1 = m.invoke(a1);
|
||||
|
|
Loading…
Reference in New Issue