[webbeans-commits] Webbeans SVN: r372 - ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Thu Nov 27 09:19:40 EST 2008


Author: nickarls
Date: 2008-11-27 09:19:40 -0500 (Thu, 27 Nov 2008)
New Revision: 372

Modified:
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedItemImpl.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedParameterImpl.java
Log:
some javadocs/comments

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java	2008-11-27 13:33:35 UTC (rev 371)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java	2008-11-27 14:19:40 UTC (rev 372)
@@ -80,7 +80,7 @@
     * annotations
     * 
     */
-   public static class MetaAnnotationMap extends ForwardingMap<Class<? extends Annotation>, Set<Annotation>>
+   private static class MetaAnnotationMap extends ForwardingMap<Class<? extends Annotation>, Set<Annotation>>
    {
       private Map<Class<? extends Annotation>, Set<Annotation>> delegate;
 

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java	2008-11-27 13:33:35 UTC (rev 371)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java	2008-11-27 14:19:40 UTC (rev 372)
@@ -48,7 +48,10 @@
 public class AnnotatedClassImpl<T> extends AbstractAnnotatedType<T> implements AnnotatedClass<T>
 {
 
-   protected static class AnnotatedFields extends ForwardingMap<Class<? extends Annotation>, Set<AnnotatedField<Object>>>
+   /**
+    * A (annotation type -> set of field abstractions with annotation) map
+    */
+   private static class AnnotatedFields extends ForwardingMap<Class<? extends Annotation>, Set<AnnotatedField<Object>>>
    {
       private Map<Class<? extends Annotation>, Set<AnnotatedField<Object>>> delegate;
 
@@ -64,7 +67,10 @@
       }
    }
 
-   protected static class MetaAnnotatedFields extends ForwardingMap<Class<? extends Annotation>, Set<AnnotatedField<Object>>>
+   /**
+    * A (annotation type -> set of field abstractions with meta-annotation) map
+    */
+   private static class MetaAnnotatedFields extends ForwardingMap<Class<? extends Annotation>, Set<AnnotatedField<Object>>>
    {
       private Map<Class<? extends Annotation>, Set<AnnotatedField<Object>>> delegate;
 
@@ -80,7 +86,10 @@
       }
    }
 
-   protected class AnnotatedMethods extends ForwardingMap<Class<? extends Annotation>, Set<AnnotatedMethod<Object>>>
+   /**
+    * A (annotation type -> set of method abstractions with annotation) map
+    */   
+   private class AnnotatedMethods extends ForwardingMap<Class<? extends Annotation>, Set<AnnotatedMethod<Object>>>
    {
       private Map<Class<? extends Annotation>, Set<AnnotatedMethod<Object>>> delegate;
 
@@ -96,7 +105,10 @@
       }
    }
 
-   protected class AnnotatedConstructors extends ForwardingMap<Class<? extends Annotation>, Set<AnnotatedConstructor<T>>>
+   /**
+    * A (annotation type -> set of constructor abstractions with annotation) map
+    */
+   private class AnnotatedConstructors extends ForwardingMap<Class<? extends Annotation>, Set<AnnotatedConstructor<T>>>
    {
       private Map<Class<? extends Annotation>, Set<AnnotatedConstructor<T>>> delegate;
 
@@ -112,7 +124,10 @@
       }
    }
 
-   protected class ConstructorsByArgument extends ForwardingMap<List<Class<?>>, AnnotatedConstructor<T>>
+   /**
+    * A (class list -> set of constructor abstractions with matching parameters) map
+    */
+   private class ConstructorsByArgument extends ForwardingMap<List<Class<?>>, AnnotatedConstructor<T>>
    {
       private Map<List<Class<?>>, AnnotatedConstructor<T>> delegate;
 

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java	2008-11-27 13:33:35 UTC (rev 371)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java	2008-11-27 14:19:40 UTC (rev 372)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.jboss.webbeans.introspector.jlr;
 
 import java.lang.annotation.Annotation;
@@ -16,18 +33,58 @@
 import org.jboss.webbeans.introspector.AnnotatedParameter;
 import org.jboss.webbeans.introspector.AnnotatedType;
 
+import com.google.common.collect.ForwardingMap;
+
+/**
+ * Represents an annotated constructor
+ * 
+ * @author Pete Muir
+ * 
+ * @param <T>
+ */
 public class AnnotatedConstructorImpl<T> extends AbstractAnnotatedMember<T, Constructor<T>> implements AnnotatedConstructor<T>
 {
 
+   /**
+    * An annotation type -> list of annotations map 
+    */
+   private class AnnotatedParameters extends ForwardingMap<Class<? extends Annotation>, List<AnnotatedParameter<Object>>>
+   {
+      private Map<Class<? extends Annotation>, List<AnnotatedParameter<Object>>> delegate;
+
+      public AnnotatedParameters()
+      {
+         delegate = new HashMap<Class<? extends Annotation>, List<AnnotatedParameter<Object>>>();
+      }
+
+      @Override
+      protected Map<Class<? extends Annotation>, List<AnnotatedParameter<Object>>> delegate()
+      {
+         return delegate;
+      }
+   }
+
+   // The type arguments
    private static final Type[] actualTypeArguments = new Type[0];
-   
+   // The underlying constructor
    private Constructor<T> constructor;
-   
+
+   // The list of parameter abstractions
    private List<AnnotatedParameter<Object>> parameters;
-   private Map<Class<? extends Annotation>, List<AnnotatedParameter<Object>>> annotatedParameters;
-   
+   // The mapping of annotation -> parameter abstraction
+   private AnnotatedParameters annotatedParameters;
+
+   // The declaring class abstraction
    private AnnotatedType<T> declaringClass;
-   
+
+   /**
+    * Constructor
+    * 
+    * Initializes the superclass with the build annotations map
+    * 
+    * @param constructor The constructor method
+    * @param declaringClass The declaring class
+    */
    public AnnotatedConstructorImpl(Constructor<T> constructor, AnnotatedType<T> declaringClass)
    {
       super(buildAnnotationMap(constructor));
@@ -35,26 +92,53 @@
       this.declaringClass = declaringClass;
    }
 
+   /**
+    * Gets the constructor
+    * 
+    * @return The constructor
+    */
    public Constructor<T> getAnnotatedConstructor()
    {
       return constructor;
    }
 
+   /**
+    * Gets the delegate (constructor)
+    * 
+    * @return The delegate
+    */
    public Constructor<T> getDelegate()
    {
       return constructor;
    }
-   
+
+   /**
+    * Gets the type of the constructor
+    * 
+    * @return The type of the constructor
+    */
    public Class<T> getType()
    {
       return constructor.getDeclaringClass();
    }
-   
+
+   /**
+    * Gets the actual type arguments
+    * 
+    * @return The type arguments
+    */
    public Type[] getActualTypeArguments()
    {
       return actualTypeArguments;
    }
-   
+
+   /**
+    * Gets the abstracted parameters
+    * 
+    * If the parameters are null, initalize them first
+    * 
+    * @return A list of annotated parameter abstractions
+    */
    public List<AnnotatedParameter<Object>> getParameters()
    {
       if (parameters == null)
@@ -63,10 +147,17 @@
       }
       return parameters;
    }
-   
+
+   /**
+    * Initializes the parameter abstractions
+    * 
+    * Iterates over the constructor parameters, adding the parameter abstraction
+    * to the parameters list.
+    */
+   @SuppressWarnings("unchecked")
    private void initParameters()
    {
-      this.parameters = new ArrayList<AnnotatedParameter<Object>>();
+      parameters = new ArrayList<AnnotatedParameter<Object>>();
       for (int i = 0; i < constructor.getParameterTypes().length; i++)
       {
          if (constructor.getParameterAnnotations()[i].length > 0)
@@ -83,14 +174,23 @@
          }
       }
    }
-   
+
+   /**
+    * Gets the parameter abstractions with a given annotation type
+    * 
+    * if the annotated parameters map is null, it is initialized first.
+    * 
+    * @param annotationType The annotation type to match
+    * @return The list of parameter abstractions with given annotation type. An
+    *         empty list is returned if there are no matches.
+    */
    public List<AnnotatedParameter<Object>> getAnnotatedMethods(Class<? extends Annotation> annotationType)
    {
       if (annotatedParameters == null)
       {
          initAnnotatedParameters();
       }
-       
+
       if (!annotatedParameters.containsKey(annotationType))
       {
          return new ArrayList<AnnotatedParameter<Object>>();
@@ -101,13 +201,20 @@
       }
    }
 
+   /**
+    * Initializes the annotated parameters
+    * 
+    * If the parameters are null, they are initialized first. Iterate over the
+    * parameters and for each parameter annotation map it under the annotation
+    * type.
+    */
    private void initAnnotatedParameters()
    {
       if (parameters == null)
       {
          initParameters();
       }
-      annotatedParameters = new HashMap<Class<? extends Annotation>, List<AnnotatedParameter<Object>>>();
+      annotatedParameters = new AnnotatedParameters();
       for (AnnotatedParameter<Object> parameter : parameters)
       {
          for (Annotation annotation : parameter.getAnnotations())
@@ -121,6 +228,15 @@
       }
    }
 
+   /**
+    * Gets parameter abstractions with a given annotation type.
+    * 
+    * If the parameters are null, they are initializes first.
+    * 
+    * @param annotationType The annotation type to match
+    * @return A list of matching parameter abstractions. An empty list is
+    *         returned if there are no matches.
+    */
    public List<AnnotatedParameter<Object>> getAnnotatedParameters(Class<? extends Annotation> annotationType)
    {
       if (annotatedParameters == null)
@@ -133,11 +249,18 @@
       }
       return annotatedParameters.get(annotationType);
    }
-   
+
+   /**
+    * Creates a new instance
+    * 
+    * @param manager The Web Beans manager
+    * @return An instance
+    */
    public T newInstance(ManagerImpl manager)
    {
       try
       {
+         // TODO: more details in the exceptions
          return getDelegate().newInstance(getParameterValues(parameters, manager));
       }
       catch (IllegalArgumentException e)
@@ -157,11 +280,17 @@
          throw new ExecutionException(e);
       }
    }
-   
+
+   /**
+    * The overridden equals operation
+    * 
+    * @param other The instance to compare to
+    * @return True if equal, false otherwise
+    */
    @Override
    public boolean equals(Object other)
    {
-      
+
       if (super.equals(other) && other instanceof AnnotatedConstructor)
       {
          AnnotatedConstructor<?> that = (AnnotatedConstructor<?>) other;
@@ -169,13 +298,25 @@
       }
       return false;
    }
-   
+
+   /**
+    * The overridden hashcode
+    * 
+    * Gets the hash code from the delegate
+    * 
+    * @return The hash code
+    */
    @Override
    public int hashCode()
    {
       return getDelegate().hashCode();
    }
-   
+
+   /**
+    * Gets the declaring class
+    * 
+    * @return The declaring class
+    */
    public AnnotatedType<T> getDeclaringClass()
    {
       return declaringClass;

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java	2008-11-27 13:33:35 UTC (rev 371)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java	2008-11-27 14:19:40 UTC (rev 372)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.jboss.webbeans.introspector.jlr;
 
 import java.lang.reflect.Field;

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedItemImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedItemImpl.java	2008-11-27 13:33:35 UTC (rev 371)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedItemImpl.java	2008-11-27 14:19:40 UTC (rev 372)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.jboss.webbeans.introspector.jlr;
 
 import java.lang.annotation.Annotation;

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java	2008-11-27 13:33:35 UTC (rev 371)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java	2008-11-27 14:19:40 UTC (rev 372)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.jboss.webbeans.introspector.jlr;
 
 import java.lang.annotation.Annotation;

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedParameterImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedParameterImpl.java	2008-11-27 13:33:35 UTC (rev 371)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedParameterImpl.java	2008-11-27 14:19:40 UTC (rev 372)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.jboss.webbeans.introspector.jlr;
 
 import java.lang.annotation.Annotation;




More information about the weld-commits mailing list