openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r1481613 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable: AbstractAnnotatedMember.java AnnotatedTypeImpl.java
Date Sun, 12 May 2013 17:33:04 GMT
Author: dblevins
Date: Sun May 12 17:33:03 2013
New Revision: 1481613

URL: http://svn.apache.org/r1481613
Log:
OWB-858: Further improvement to the type-safety of AnnotatedTypeImpl

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedMember.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedTypeImpl.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedMember.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedMember.java?rev=1481613&r1=1481612&r2=1481613&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedMember.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedMember.java
Sun May 12 17:33:03 2013
@@ -52,34 +52,15 @@ abstract class AbstractAnnotatedMember<X
     AbstractAnnotatedMember(WebBeansContext webBeansContext, Type baseType, Member javaMember,
AnnotatedType<X> declaringType)
     {
         super(webBeansContext, baseType);
-        
-        this.javaMember = javaMember;
-        
-        if(declaringType == null)
-        {
-            this.declaringType = (AnnotatedType<X>) getWebBeansContext().getAnnotatedElementFactory().newAnnotatedType(this.javaMember.getDeclaringClass());
-            
-            AnnotatedTypeImpl<X> impl = (AnnotatedTypeImpl<X>)this.declaringType;
-            
-            if(this.javaMember instanceof Constructor)
-            {
-                impl.addAnnotatedConstructor((AnnotatedConstructor<X>)this);
-            }
-            
-            else if(this.javaMember instanceof Method)
-            {
-                impl.addAnnotatedMethod((AnnotatedMethod<X>)this);
-            }
-            
-            else if(this.javaMember instanceof Field)
-            {
-                impl.addAnnotatedField((AnnotatedField<X>)this);
-            }                
-        }
-        else
+
+        if (declaringType == null)
         {
-            this.declaringType = declaringType;
+            throw new IllegalArgumentException("declaringType cannot be null");
         }
+
+        this.javaMember = javaMember;
+        this.declaringType = declaringType;
+
     }
    /**
      * {@inheritDoc}

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedTypeImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedTypeImpl.java?rev=1481613&r1=1481612&r2=1481613&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedTypeImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedTypeImpl.java
Sun May 12 17:33:03 2013
@@ -105,44 +105,13 @@ class AnnotatedTypeImpl<X>
         return annotatedClass;
     }
 
-
-    /**
-     * Adds new annotated constructor.
-     *
-     * @param constructor new constructor
-     */
-    void addAnnotatedConstructor(AnnotatedConstructor<X> constructor)
-    {
-        getState().constructors.add(constructor);
-    }
-
-    /**
-     * Adds new annotated field.
-     *
-     * @param field new field
-     */
-    void addAnnotatedField(AnnotatedField<? super X> field)
-    {
-        getState().fields.add(field);
-    }
-
-    /**
-     * Adds new annotated method.
-     *
-     * @param method new method
-     */
-    void addAnnotatedMethod(AnnotatedMethod<? super X> method)
-    {
-        getState().methods.add(method);
-    }
-
     /**
      * {@inheritDoc}
      */
     @Override
     public Set<AnnotatedConstructor<X>> getConstructors()
     {
-        return Collections.unmodifiableSet(getState().constructors);
+        return getState().constructors;
     }
 
     /**
@@ -151,7 +120,7 @@ class AnnotatedTypeImpl<X>
     @Override
     public Set<AnnotatedField<? super X>> getFields()
     {
-        return Collections.unmodifiableSet(getState().fields);
+        return getState().fields;
     }
 
     /**
@@ -160,7 +129,7 @@ class AnnotatedTypeImpl<X>
     @Override
     public Set<AnnotatedMethod<? super X>> getMethods()
     {
-        return Collections.unmodifiableSet(getState().methods);
+        return getState().methods;
     }
 
     private State getState()
@@ -191,23 +160,31 @@ class AnnotatedTypeImpl<X>
         /**
          * Constructors
          */
-        private final Set<AnnotatedConstructor<X>> constructors = new HashSet<AnnotatedConstructor<X>>();
+        private final Set<AnnotatedConstructor<X>> constructors;
 
         /**
          * Fields
          */
-        private final Set<AnnotatedField<? super X>> fields = new HashSet<AnnotatedField<?
super X>>();
+        private final Set<AnnotatedField<? super X>> fields;
 
         /**
          * Methods
          */
-        private final Set<AnnotatedMethod<? super X>> methods = new HashSet<AnnotatedMethod<?
super X>>();
+        private final Set<AnnotatedMethod<? super X>> methods;
 
         private State()
         {
             Constructor<?>[] decCtxs =
                 getWebBeansContext().getSecurityService().doPrivilegedGetDeclaredConstructors(annotatedClass);
 
+            final Set<AnnotatedConstructor<X>> constructors = new HashSet<AnnotatedConstructor<X>>();
+            final Set<AnnotatedField<? super X>> fields = new HashSet<AnnotatedField<?
super X>>();
+            final Set<AnnotatedMethod<? super X>> methods = new HashSet<AnnotatedMethod<?
super X>>();
+
+            this.constructors = Collections.unmodifiableSet(constructors);
+            this.fields = Collections.unmodifiableSet(fields);
+            this.methods = Collections.unmodifiableSet(methods);
+
             for (Constructor<?> ct : decCtxs)
             {
                 if (!ct.isSynthetic())



Mime
View raw message