geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1796171 - in /geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi: Annotated.java AnnotatedConstructor.java AnnotatedField.java AnnotatedMethod.java AnnotatedParameter.java AnnotatedType.java
Date Thu, 25 May 2017 16:34:03 GMT
Author: struberg
Date: Thu May 25 16:34:03 2017
New Revision: 1796171

URL: http://svn.apache.org/viewvc?rev=1796171&view=rev
Log:
GERONIMO-6553 support for repeating annotations

Modified:
    geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/Annotated.java
    geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/AnnotatedConstructor.java
    geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/AnnotatedField.java
    geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/AnnotatedMethod.java
    geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/AnnotatedParameter.java
    geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/AnnotatedType.java

Modified: geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/Annotated.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/Annotated.java?rev=1796171&r1=1796170&r2=1796171&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/Annotated.java
(original)
+++ geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/Annotated.java
Thu May 25 16:34:03 2017
@@ -54,6 +54,15 @@ public interface Annotated
     <T extends Annotation> T getAnnotation(Class<T> annotationType);
 
     /**
+     * Gets annotated element's annotation member if exist, null otherwise
+     *
+     * @param <T> generic annotatation class type
+     * @param annotationType class of the annotation
+     * @return annotations of the given type, if exist - empty collection otherwise
+     */
+    <T extends Annotation> Set<T> getAnnotations(Class<T> annotationType);
+
+    /**
      * Gets annotated member all annotations.
      *
      * @return annotated member annotations

Modified: geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/AnnotatedConstructor.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/AnnotatedConstructor.java?rev=1796171&r1=1796170&r2=1796171&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/AnnotatedConstructor.java
(original)
+++ geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/AnnotatedConstructor.java
Thu May 25 16:34:03 2017
@@ -18,7 +18,11 @@
  */
 package javax.enterprise.inject.spi;
 
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Constructor;
+import java.util.Arrays;
+import java.util.LinkedHashSet;
+import java.util.Set;
 
 /**
  * Defines member constructor contract.
@@ -33,4 +37,10 @@ public interface AnnotatedConstructor<X>
      * {@inheritDoc}
      */
     Constructor<X> getJavaMember();
+
+    @Override
+    default <T extends Annotation> Set<T> getAnnotations(Class<T> annotationType)
+    {
+        return new LinkedHashSet<>(Arrays.asList(getJavaMember().getAnnotationsByType(annotationType)));
+    }
 }

Modified: geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/AnnotatedField.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/AnnotatedField.java?rev=1796171&r1=1796170&r2=1796171&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/AnnotatedField.java
(original)
+++ geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/AnnotatedField.java
Thu May 25 16:34:03 2017
@@ -18,7 +18,11 @@
  */
 package javax.enterprise.inject.spi;
 
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Field;
+import java.util.Arrays;
+import java.util.LinkedHashSet;
+import java.util.Set;
 
 /**
  * Defines field member contract.
@@ -33,4 +37,11 @@ public interface AnnotatedField<X> exten
      * {@inheritDoc}
      */
     Field getJavaMember();
+
+    @Override
+    default <T extends Annotation> Set<T> getAnnotations(Class<T> annotationType)
+    {
+        return new LinkedHashSet<>(Arrays.asList(getJavaMember().getAnnotationsByType(annotationType)));
+    }
+
 }

Modified: geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/AnnotatedMethod.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/AnnotatedMethod.java?rev=1796171&r1=1796170&r2=1796171&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/AnnotatedMethod.java
(original)
+++ geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/AnnotatedMethod.java
Thu May 25 16:34:03 2017
@@ -18,7 +18,11 @@
  */
 package javax.enterprise.inject.spi;
 
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.LinkedHashSet;
+import java.util.Set;
 
 /**
  * Define method member contract.
@@ -33,4 +37,11 @@ public interface AnnotatedMethod<X> exte
      * {@inheritDoc}
      */
     Method getJavaMember();
+
+    @Override
+    default <T extends Annotation> Set<T> getAnnotations(Class<T> annotationType)
+    {
+        return new LinkedHashSet<>(Arrays.asList(getJavaMember().getAnnotationsByType(annotationType)));
+    }
+
 }

Modified: geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/AnnotatedParameter.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/AnnotatedParameter.java?rev=1796171&r1=1796170&r2=1796171&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/AnnotatedParameter.java
(original)
+++ geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/AnnotatedParameter.java
Thu May 25 16:34:03 2017
@@ -18,6 +18,14 @@
  */
 package javax.enterprise.inject.spi;
 
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Executable;
+import java.lang.reflect.Member;
+import java.lang.reflect.Parameter;
+import java.util.Arrays;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
 /**
  * Defines member parameter contract.
  * 
@@ -41,4 +49,20 @@ public interface AnnotatedParameter<X> e
      */
     AnnotatedCallable<X> getDeclaringCallable();
 
+    default Parameter getJavaParameter()
+    {
+        final Member javaMember = getDeclaringCallable().getJavaMember();
+        if (!Executable.class.isInstance(javaMember))
+        {
+            throw new IllegalStateException("Parameter does not belong to a Constructor or
Method: " + javaMember);
+        }
+        return ((Executable) javaMember).getParameters()[getPosition()];
+    }
+
+    @Override
+    default <T extends Annotation> Set<T> getAnnotations(Class<T> annotationType)
+    {
+        return new LinkedHashSet<>(Arrays.asList(getJavaParameter().getAnnotationsByType(annotationType)));
+    }
+
 }

Modified: geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/AnnotatedType.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/AnnotatedType.java?rev=1796171&r1=1796170&r2=1796171&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/AnnotatedType.java
(original)
+++ geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/AnnotatedType.java
Thu May 25 16:34:03 2017
@@ -19,6 +19,9 @@
 package javax.enterprise.inject.spi;
 
 import javax.enterprise.inject.spi.configurator.AnnotatedTypeConfigurator;
+import java.lang.annotation.Annotation;
+import java.util.Arrays;
+import java.util.LinkedHashSet;
 import java.util.Set;
 
 /**
@@ -61,4 +64,11 @@ public interface AnnotatedType<X> extend
     * @return
     */
     AnnotatedTypeConfigurator<X> configureAnnotatedType();
+
+    @Override
+    default <T extends Annotation> Set<T> getAnnotations(Class<T> annotationType)
+    {
+        return new LinkedHashSet<>(Arrays.asList(getJavaClass().getAnnotationsByType(annotationType)));
+    }
+
 }



Mime
View raw message