[webbeans-commits] Webbeans SVN: r378 - in ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans: model and 1 other directory.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Fri Nov 28 04:44:49 EST 2008


Author: nickarls
Date: 2008-11-28 04:44:49 -0500 (Fri, 28 Nov 2008)
New Revision: 378

Modified:
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/MergedStereotypes.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/AnnotationModel.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/BindingTypeModel.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/ScopeModel.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/StereotypeModel.java
Log:
javadocs/comments/toStrings

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/MergedStereotypes.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/MergedStereotypes.java	2008-11-28 08:20:56 UTC (rev 377)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/MergedStereotypes.java	2008-11-28 09:44:49 UTC (rev 378)
@@ -29,15 +29,19 @@
 /**
  * Meta model for the merged stereotype for a bean
  * 
- * @author pmuir
- * 
+ * @author Pete Muir
  */
 public class MergedStereotypes<T, E>
 {
+   // The possible deployment types
    private AnnotationMap possibleDeploymentTypes;
+   // The possible scope types
    private Set<Annotation> possibleScopeTypes;
+   // Is the bean name defaulted?
    private boolean beanNameDefaulted;
+   // The required types
    private Set<Class<?>> requiredTypes;
+   // The supported scopes
    private Set<Class<? extends Annotation>> supportedScopes;
 
    /**
@@ -148,6 +152,11 @@
       return false;
    }
 
+   /**
+    * Gets a string representation of the merged stereotypes
+    * 
+    * @return The string representation
+    */
    @Override
    public String toString()
    {

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/AnnotationModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/AnnotationModel.java	2008-11-28 08:20:56 UTC (rev 377)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/AnnotationModel.java	2008-11-28 09:44:49 UTC (rev 378)
@@ -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.model;
 
 import java.lang.annotation.Annotation;
@@ -7,24 +24,41 @@
 import org.jboss.webbeans.introspector.AnnotatedAnnotation;
 import org.jboss.webbeans.introspector.jlr.AnnotatedAnnotationImpl;
 
+/**
+ * Abstract representation of an annotation model
+ * 
+ * @author Pete Muir
+ */
 public abstract class AnnotationModel<T extends Annotation>
 {
-   
+   // The underlying annotation
    private AnnotatedAnnotation<T> annotatedAnnotation;
+   // Is the data valid?
    private boolean valid;
-   
+
+   /**
+    * Constructor
+    * 
+    * @param type The annotation type
+    */
    public AnnotationModel(Class<T> type)
    {
       this.annotatedAnnotation = new AnnotatedAnnotationImpl<T>(type);
       init();
    }
-   
+
+   /**
+    * Initializes the type and validates it
+    */
    protected void init()
    {
       initType();
       initValid();
    }
-   
+
+   /**
+    * Initializes the type
+    */
    protected void initType()
    {
       if (!Annotation.class.isAssignableFrom(getType()))
@@ -32,33 +66,64 @@
          throw new DefinitionException(getMetaAnnotation().toString() + " can only be applied to an annotation, it was applied to " + getType());
       }
    }
-   
+
+   /**
+    * Validates the data for correct annotation
+    */
    protected void initValid()
    {
       this.valid = annotatedAnnotation.isAnnotationPresent(getMetaAnnotation());
    }
 
+   /**
+    * Gets the type of the annotation
+    * 
+    * @return The type
+    */
    public Class<T> getType()
    {
       return annotatedAnnotation.getType();
    }
-   
+
+   /**
+    * Gets the meta-annotation that should be present
+    * 
+    * @return
+    */
    protected abstract Class<? extends Annotation> getMetaAnnotation();
-   
+
+   /**
+    * Indicates if the annotation is valid
+    * 
+    * @return True if valid, false otherwise
+    */
    public boolean isValid()
    {
       return valid;
    }
-   
+
+   /**
+    * Gets the annotated annotation
+    * 
+    * @return The annotation
+    */
    protected AnnotatedAnnotation<T> getAnnotatedAnnotation()
    {
       return annotatedAnnotation;
    }
-   
+
+   /**
+    * Gets a string representation of the annotation
+    * 
+    * @return The string representation
+    */
    @Override
    public String toString()
    {
-      return getClass().getSimpleName() + "[" + getAnnotatedAnnotation().toString() + "]";
+      StringBuffer buffer = new StringBuffer();
+      buffer.append("AnnotationModel:\n");
+      buffer.append("Annotated annotation: " + getAnnotatedAnnotation().toString());
+      buffer.append("Valid: " + isValid());
+      return buffer.toString();
    }
-   
 }
\ No newline at end of file

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/BindingTypeModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/BindingTypeModel.java	2008-11-28 08:20:56 UTC (rev 377)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/BindingTypeModel.java	2008-11-28 09:44:49 UTC (rev 378)
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 
-
 package org.jboss.webbeans.model;
 
 import java.lang.annotation.Annotation;
@@ -33,19 +32,28 @@
  * Model of a binding type
  * 
  * @author Pete Muir
- *
+ * 
  */
 public class BindingTypeModel<T extends Annotation> extends AnnotationModel<T>
 {
-   
+   // The non-binding types
    private Set<AnnotatedMethod<?>> nonBindingTypes;
+   // The hash code
    private Integer hashCode;
-   
+
+   /**
+    * Constructor
+    * 
+    * @param type The type
+    */
    public BindingTypeModel(Class<T> type)
    {
       super(type);
    }
-   
+
+   /**
+    * Initializes the non-binding types and validates the members
+    */
    @Override
    protected void init()
    {
@@ -53,7 +61,10 @@
       initNonBindingTypes();
       checkArrayAndAnnotationValuedMembers();
    }
-   
+
+   /**
+    * Validates the members
+    */
    private void checkArrayAndAnnotationValuedMembers()
    {
       for (AnnotatedMethod<?> annotatedMethod : getAnnotatedAnnotation().getMembers())
@@ -63,30 +74,56 @@
             throw new DefinitionException("Member of array type or annotation type must be annotated @NonBinding " + annotatedMethod);
          }
       }
-      
+
    }
 
+   /**
+    * Gets the meta-annotation type
+    * 
+    * @return The BindingType class
+    */
    @Override
    protected Class<? extends Annotation> getMetaAnnotation()
    {
       return BindingType.class;
    }
-   
+
+   /**
+    * Indicates if there are non-binding types present
+    * 
+    * @return True if present, false otherwise
+    */
    public boolean hasNonBindingTypes()
    {
       return nonBindingTypes.size() > 0;
    }
-   
+
+   /**
+    * Gets the non-binding types
+    * 
+    * @return A set of non-binding types, or an empty set if there are none
+    *         present
+    */
    public Set<AnnotatedMethod<?>> getNonBindingTypes()
    {
       return nonBindingTypes;
    }
-   
+
+   /**
+    * Initializes the non-binding types
+    */
    protected void initNonBindingTypes()
    {
       nonBindingTypes = getAnnotatedAnnotation().getAnnotatedMembers(NonBinding.class);
    }
-   
+
+   /**
+    * Comparator for checking equality
+    * 
+    * @param instance The instance to check against
+    * @param other The other binding type
+    * @return True if equal, false otherwise
+    */
    public boolean isEqual(Annotation instance, Annotation other)
    {
       if (instance.annotationType().equals(getType()) && other.annotationType().equals(getType()))
@@ -107,19 +144,26 @@
       }
       return false;
    }
-   
+
+   /**
+    * Gets a string representation of the stereotype
+    * 
+    * @return The string representation
+    */
    @Override
-   public String toString() {
+   public String toString()
+   {
       StringBuffer buffer = new StringBuffer();
-      buffer.append("Binding type model\n");
-      buffer.append("Hash code : " + hashCode() + "\n");
-      buffer.append("Valid : " + isValid() + "\n");
-      buffer.append("Non-binding types\n");
-      for (AnnotatedMethod<?> method : nonBindingTypes) {
-         method.toString();
+      buffer.append("BindingTypeModel:\n");
+      buffer.append(super.toString());
+      buffer.append("Hash code: " + hashCode);
+      buffer.append("Non-binding types: " + nonBindingTypes.size());
+      int i = 0;
+      for (AnnotatedMethod<?> nonBindingType : getNonBindingTypes())
+      {
+         buffer.append(++i + " - " + nonBindingType.toString());
       }
-      buffer.append("Annotated type " + getAnnotatedAnnotation().getName() + "\n");
       return buffer.toString();
    }
-   
+
 }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/ScopeModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/ScopeModel.java	2008-11-28 08:20:56 UTC (rev 377)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/ScopeModel.java	2008-11-28 09:44:49 UTC (rev 378)
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 
-
 package org.jboss.webbeans.model;
 
 import java.lang.annotation.Annotation;
@@ -27,39 +26,66 @@
  * Model of a scope
  * 
  * @author Pete Muir
- *
+ * 
  */
 public class ScopeModel<T extends Annotation> extends AnnotationModel<T>
 {
-   
+   /**
+    * Constrctor
+    * 
+    * @param scope The scope type
+    */
    public ScopeModel(Class<T> scope)
    {
       super(scope);
    }
-   
+
+   /**
+    * Indicates if the scope is "normal"
+    * 
+    * @return True if normal, false otherwise
+    */
    public boolean isNormal()
    {
       return getAnnotatedAnnotation().getAnnotation(ScopeType.class).normal();
    }
-   
+
+   /**
+    * Indicates if the scope is "passivating"
+    * 
+    * @return True if passivating, false otherwise
+    */
    public boolean isPassivating()
    {
       return getAnnotatedAnnotation().getAnnotation(ScopeType.class).passivating();
    }
-   
+
+   /**
+    * Gets the corresponding meta-annotation type class
+    * 
+    * @return The ScopeType class
+    */
    @Override
    protected Class<? extends Annotation> getMetaAnnotation()
    {
       return ScopeType.class;
    }
-   
+
+   /**
+    * Gets a string representation of the stereotype
+    * 
+    * @return The string representation
+    */
    @Override
-   public String toString() {
+   public String toString()
+   {
       StringBuffer buffer = new StringBuffer();
-      buffer.append("Scope model\n");
-      buffer.append("Valid : " + isValid() + "\n");
-      buffer.append("Annotated type " + getAnnotatedAnnotation().toString() + "\n");
+      buffer.append("ScopeModel:\n");
+      buffer.append(super.toString());
+      buffer.append("Normal: " + isNormal());
+      buffer.append("Passivating: " + isPassivating());
+      buffer.append("Meta-annotation: " + getMetaAnnotation().toString());
       return buffer.toString();
    }
-   
+
 }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/StereotypeModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/StereotypeModel.java	2008-11-28 08:20:56 UTC (rev 377)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/StereotypeModel.java	2008-11-28 09:44:49 UTC (rev 378)
@@ -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.model;
 
 import java.lang.annotation.Annotation;
@@ -14,20 +31,32 @@
 import javax.webbeans.Stereotype;
 
 /**
- * A meta model for a stereotype, allows us to cache a stereotype and to validate it
+ * A meta model for a stereotype, allows us to cache a stereotype and to
+ * validate it
  * 
- * @author pmuir
- *
+ * @author Pete Muir
+ * 
  */
 public class StereotypeModel<T extends Annotation> extends AnnotationModel<T>
 {
+   // The default deployment type
    private Annotation defaultDeploymentType;
+   // The default scope type
    private Annotation defaultScopeType;
+   // Is the bean name defaulted
    private boolean beanNameDefaulted;
+   // The supported scopes
    private Set<Class<? extends Annotation>> supportedScopes;
+   // The required types
    private Set<Class<?>> requiredTypes;
+   // The interceptor bindings
    private Set<Annotation> interceptorBindings;
-   
+
+   /**
+    * Constructor
+    * 
+    * @param sterotype The stereotype
+    */
    public StereotypeModel(Class<T> sterotype)
    {
       super(sterotype);
@@ -39,7 +68,10 @@
       initInterceptorBindings();
       checkBindingTypes();
    }
-   
+
+   /**
+    * Validates the binding types
+    */
    private void checkBindingTypes()
    {
       Set<Annotation> bindingTypes = getAnnotatedAnnotation().getMetaAnnotations(BindingType.class);
@@ -49,11 +81,17 @@
       }
    }
 
+   /**
+    * Initializes the interceptor bindings
+    */
    private void initInterceptorBindings()
    {
       interceptorBindings = getAnnotatedAnnotation().getMetaAnnotations(InterceptorBindingType.class);
    }
 
+   /**
+    * Initializes the supported scopes
+    */
    private void initSupportedScopes()
    {
       this.supportedScopes = new HashSet<Class<? extends Annotation>>();
@@ -63,7 +101,10 @@
          this.supportedScopes.addAll(Arrays.asList(supportedScopes));
       }
    }
-   
+
+   /**
+    * Initializes the required types
+    */
    private void initRequiredTypes()
    {
       this.requiredTypes = new HashSet<Class<?>>();
@@ -74,6 +115,9 @@
       }
    }
 
+   /**
+    * Initializes the bean name defaulted
+    */
    private void initBeanNameDefaulted()
    {
       if (getAnnotatedAnnotation().isAnnotationPresent(Named.class))
@@ -86,6 +130,9 @@
       }
    }
 
+   /**
+    * Initializes the default scope type
+    */
    private void initDefaultScopeType()
    {
       Set<Annotation> scopeTypes = getAnnotatedAnnotation().getMetaAnnotations(ScopeType.class);
@@ -99,6 +146,9 @@
       }
    }
 
+   /**
+    * Initializes the default deployment type
+    */
    private void initDefaultDeploymentType()
    {
       Set<Annotation> deploymentTypes = getAnnotatedAnnotation().getMetaAnnotations(DeploymentType.class);
@@ -111,77 +161,123 @@
          this.defaultDeploymentType = deploymentTypes.iterator().next();
       }
    }
-   
+
    /**
-    * Get the default deployment type the stereotype specifies, or null if none
-    * is specified
+    * Get the default deployment type the stereotype specifies
+    * 
+    * @return The default deployment type, or null if none is specified
     */
    public Annotation getDefaultDeploymentType()
    {
       return defaultDeploymentType;
    }
-   
+
    /**
-    * Get the default scope type the stereotype specifies, or null if none is
-    * specified
+    * Get the default scope type the stereotype specifies
+    * 
+    * @return The default scope type, or null if none is specified
     */
    public Annotation getDefaultScopeType()
    {
       return defaultScopeType;
    }
-   
+
    /**
-    * Get any interceptor bindings the the stereotype specifies, or an empty set
-    * if none are specified
+    * Get any interceptor bindings the the stereotype specifies
+    * 
+    * @return The interceptor bindings, or an empty set if none are specified.
     */
    public Set<Annotation> getInterceptorBindings()
    {
       return interceptorBindings;
    }
-   
+
    /**
-    * Returns true if the stereotype specifies the bean name should be 
-    * defaulted
+    * Indicates if the bean name is defaulted
+    * 
+    * @return True if defaulted, false otherwise
     */
    public boolean isBeanNameDefaulted()
    {
       return beanNameDefaulted;
    }
-   
+
    /**
-    * Returns the scopes this stereotype allows, or an empty set if none are 
-    * specified
+    * Gets the supported scopes
+    * 
+    * @return A set of supported scopes, or an empty set if none are specified
     */
    public Set<Class<? extends Annotation>> getSupportedScopes()
    {
       return supportedScopes;
    }
-   
+
    /**
-    * Returns the types this stereotype requires, or an empty set if none are
-    * specified
+    * Gets the required types
+    * 
+    * @return A set of required types, or an empty set if none are specified
     */
    public Set<Class<?>> getRequiredTypes()
    {
       return requiredTypes;
    }
-   
+
+   /**
+    * Gets the type
+    * 
+    * @return The type
+    */
    @Deprecated
    public Class<? extends Annotation> getStereotypeClass()
    {
       return getType();
    }
-   
+
+   /**
+    * Gets a string representation of the stereotype
+    * 
+    * @return The string representation
+    */
    @Override
    public String toString()
    {
-      return "StereotypeModel[" + getType() + "]";
+      StringBuffer buffer = new StringBuffer();
+      buffer.append("StereotypeModel:\n");
+      buffer.append(super.toString());
+      buffer.append("Bean name defaulted: " + isBeanNameDefaulted());
+      buffer.append("Default deployment type: " + getDefaultDeploymentType());
+      buffer.append("Default scope type: " + getDefaultScopeType());
+      buffer.append("Meta-annotation: " + getMetaAnnotation().toString());
+      buffer.append("Interceptor bindings: " + getInterceptorBindings().size());
+      int i = 0;
+      for (Annotation annotation : getInterceptorBindings())
+      {
+         buffer.append(++i + " - " + annotation.toString());
+      }
+      buffer.append("Required types: " + getRequiredTypes().size());
+      i = 0;
+      for (Class<?> requiredType : getRequiredTypes())
+      {
+         buffer.append(++i + " - " + requiredType.toString());
+      }
+      buffer.append("Supported scopes: " + getSupportedScopes().size());
+      i = 0;
+      for (Class<?> supportedScope : getSupportedScopes())
+      {
+         buffer.append(++i + " - " + supportedScope.toString());
+      }
+      return buffer.toString();
    }
 
+   /**
+    * Gets the meta-annotation type
+    * 
+    * @return The Stereotype class
+    */
    @Override
    protected Class<? extends Annotation> getMetaAnnotation()
    {
       return Stereotype.class;
    }
-   
+
 }




More information about the weld-commits mailing list