You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@causeway.apache.org by da...@apache.org on 2023/03/26 15:46:01 UTC
[causeway] 01/02: CAUSEWAY-3397: adds new method in _Annotations
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to branch CAUSEWAY-3397
in repository https://gitbox.apache.org/repos/asf/causeway.git
commit 3ca0b8a0f1e856057dfcebae09d45d4f2e24ff51
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Sun Mar 26 12:54:08 2023 +0100
CAUSEWAY-3397: adds new method in _Annotations
---
.../commons/internal/reflection/_Annotations.java | 23 ++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/commons/src/main/java/org/apache/causeway/commons/internal/reflection/_Annotations.java b/commons/src/main/java/org/apache/causeway/commons/internal/reflection/_Annotations.java
index 7d525032d4..dcb916545d 100644
--- a/commons/src/main/java/org/apache/causeway/commons/internal/reflection/_Annotations.java
+++ b/commons/src/main/java/org/apache/causeway/commons/internal/reflection/_Annotations.java
@@ -100,6 +100,29 @@ public final class _Annotations {
return synthesize(annotatedElement, annotationType, SearchStrategy.TYPE_HIERARCHY);
}
+ /**
+ * Optionally create a type-safe synthesized version of this annotation based on presence.
+ * <p>
+ * Also includes annotated fields, getter methods might be associated with.
+ * If annotations from a getter method are competing with annotations from its corresponding field,
+ * let the one win, that is 'nearer' to the <i>Class</i> that is subject to introspection.
+ * <p>
+ * Perform a full search of the entire type hierarchy,
+ * including super-classes and implemented interfaces.p
+ * Super-class annotations do not need to be meta-annotated with {@link Inherited}.
+ *
+ * @param <A>
+ * @param annotatedElement
+ * @param annotationType
+ * @return non-null
+ */
+ public static <A extends Annotation> Optional<A> synthesizeWrtEnclosingClass(
+ final AnnotatedElement annotatedElement,
+ final Class<A> annotationType) {
+
+ return synthesize(annotatedElement, annotationType, SearchStrategy.TYPE_HIERARCHY_AND_ENCLOSING_CLASSES);
+ }
+
/**
* Optionally create a type-safe synthesized version of this annotation based on presence.
* <p>