From da15d0b2c61d8a5d32c4e70217dd1409e1ccd8d9 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Tue, 23 Aug 2016 20:00:07 +1200 Subject: [PATCH] No effective change - format javadoc --- .../server/deploy/parse/AnnotationBase.java | 73 +++++++++---------- 1 file changed, 34 insertions(+), 39 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationBase.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationBase.java index c3f64f1fc..d6fc3b540 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationBase.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationBase.java @@ -1,5 +1,9 @@ package com.avaje.ebeaninternal.server.deploy.parse; +import com.avaje.ebean.config.NamingConvention; +import com.avaje.ebean.config.dbplatform.DatabasePlatform; +import com.avaje.ebeaninternal.server.deploy.meta.DeployBeanProperty; + import java.lang.annotation.Annotation; import java.lang.reflect.AnnotatedElement; import java.lang.reflect.Field; @@ -7,10 +11,6 @@ import java.lang.reflect.Method; import java.util.HashSet; import java.util.Set; -import com.avaje.ebean.config.NamingConvention; -import com.avaje.ebean.config.dbplatform.DatabasePlatform; -import com.avaje.ebeaninternal.server.deploy.meta.DeployBeanProperty; - /** * Provides some base methods for processing deployment annotations. */ @@ -69,31 +69,28 @@ public abstract class AnnotationBase { protected T find(DeployBeanProperty prop, Class annClass) { T a = get(prop, annClass); if (a == null) { - a = findAnnotation(prop.getOwningType(),annClass); + a = findAnnotation(prop.getOwningType(), annClass); } return a; } - + // this code is taken from the spring framework to find annotations recursively - + /** - * Determine if the supplied {@link Annotation} is defined in the core JDK - * {@code java.lang.annotation} package. + * Determine if the supplied {@link Annotation} is defined in the core JDK {@code java.lang.annotation} package. */ public static boolean isInJavaLangAnnotationPackage(Annotation annotation) { return annotation.annotationType().getName().startsWith("java.lang.annotation"); } - + /** - * Find a single {@link Annotation} of {@code annotationType} on the - * supplied {@link AnnotatedElement}. - *

Meta-annotations will be searched if the annotation is not - * directly present on the supplied element. - *

Warning: this method operates generically on - * annotated elements. In other words, this method does not execute - * specialized search algorithms for classes or methods. It only - * traverses through Annotations!

+ * Find a single {@link Annotation} of {@code annotationType} on the supplied {@link AnnotatedElement}. + *

+ * Meta-annotations will be searched if the annotation is not directly present on the supplied element. + *

+ * Warning: this method operates generically on annotated elements. In other words, this method + * does not execute specialized search algorithms for classes or methods. It only traverses through Annotations! */ public static A findAnnotation(AnnotatedElement annotatedElement, Class annotationType) { if (annotationType == null) { @@ -109,12 +106,10 @@ public abstract class AnnotationBase { } /** - * Find a single {@link Annotation} of {@code annotationType} on the - * supplied {@link clazz}. - *

Meta-annotations will be searched if the annotation is not - * directly present on the supplied element. - *

Note: this method searches for annotations at - * class & superClass(es)!

+ * Find a single {@link Annotation} of {@code annotationType} on the supplied class. + *

Meta-annotations will be searched if the annotation is not directly present on + * the supplied element. + *

Note: this method searches for annotations at class & superClass(es)! */ public static A findAnnotation(Class clazz, Class annotationType) { if (annotationType == null) { @@ -136,28 +131,28 @@ public abstract class AnnotationBase { return null; } } + /** - * Perform the search algorithm for {@link #findAnnotation(AnnotatedElement, Class)} - * avoiding endless recursion by tracking which annotations have already - * been visited. + * Perform the search algorithm avoiding endless recursion by tracking which + * annotations have already been visited. */ @SuppressWarnings("unchecked") private static A findAnnotation(AnnotatedElement annotatedElement, Class annotationType, Set visited) { - - Annotation[] anns = annotatedElement.getDeclaredAnnotations(); - for (Annotation ann : anns) { - if (ann.annotationType() == annotationType) { - return (A) ann; - } + + Annotation[] anns = annotatedElement.getDeclaredAnnotations(); + for (Annotation ann : anns) { + if (ann.annotationType() == annotationType) { + return (A) ann; } - for (Annotation ann : anns) { - if (!isInJavaLangAnnotationPackage(ann) && visited.add(ann)) { - A annotation = findAnnotation((AnnotatedElement) ann.annotationType(), annotationType, visited); - if (annotation != null) { - return annotation; - } + } + for (Annotation ann : anns) { + if (!isInJavaLangAnnotationPackage(ann) && visited.add(ann)) { + A annotation = findAnnotation(ann.annotationType(), annotationType, visited); + if (annotation != null) { + return annotation; } } + } return null; } }