You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2019/10/15 22:31:06 UTC
[commons-lang] branch master updated: AnnotationUtils little
cleanup (#467)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
The following commit(s) were added to refs/heads/master by this push:
new f3ad91c AnnotationUtils little cleanup (#467)
f3ad91c is described below
commit f3ad91ca383a8c0dd8d8f69d6276f2558ad7c924
Author: Peter Verhas <pe...@verhas.com>
AuthorDate: Wed Oct 16 00:30:59 2019 +0200
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-
---
.../org/apache/commons/lang3/AnnotationUtils.java | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/src/main/java/org/apache/commons/lang3/AnnotationUtils.java b/src/main/java/org/apache/commons/lang3/AnnotationUtils.java
index 81bd0f0..bc51037 100644
--- a/src/main/java/org/apache/commons/lang3/AnnotationUtils.java
+++ b/src/main/java/org/apache/commons/lang3/AnnotationUtils.java
@@ -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);