Home » apache-openwebbeans-1.0.0-incubating-M3-sources » org.apache.webbeans.portable » [javadoc | source]

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements. See the NOTICE file distributed with this
    4    * work for additional information regarding copyright ownership. The ASF
    5    * licenses this file to You under the Apache License, Version 2.0 (the
    6    * "License"); you may not use this file except in compliance with the License.
    7    * You may obtain a copy of the License at
    8    * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
    9    * or agreed to in writing, software distributed under the License is
   10    * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   11    * KIND, either express or implied. See the License for the specific language
   12    * governing permissions and limitations under the License.
   13    */
   14   package org.apache.webbeans.portable;
   15   
   16   import java.lang.annotation.Annotation;
   17   import java.lang.reflect.Member;
   18   import java.lang.reflect.Type;
   19   import java.util.ArrayList;
   20   import java.util.List;
   21   
   22   import javax.enterprise.inject.spi.AnnotatedCallable;
   23   import javax.enterprise.inject.spi.AnnotatedParameter;
   24   import javax.enterprise.inject.spi.AnnotatedType;
   25   
   26   /**
   27    * Implementation of {@link AnnotatedCallable} interface.
   28    * 
   29    * @version $Rev: 788970 $ $Date: 2009-06-27 16:26:23 +0300 (Sat, 27 Jun 2009) $
   30    *
   31    * @param <X> declaring class
   32    */
   33   abstract class AbstractAnnotatedCallable<X> extends AbstractAnnotatedMember<X> implements AnnotatedCallable<X>
   34   {
   35       /**Annotated parameters*/
   36       private List<AnnotatedParameter<X>> annotatedParameters = new ArrayList<AnnotatedParameter<X>>();
   37       
   38       /**
   39        * Creates a new instance.
   40        * 
   41        * @param baseType base type
   42        * @param javaMember member
   43        */
   44       AbstractAnnotatedCallable(Type baseType, Member javaMember)
   45       {
   46           this(baseType, javaMember, null);
   47       }
   48       
   49       AbstractAnnotatedCallable(Type baseType, Member javaMember, AnnotatedType<X> declaringType)
   50       {
   51           super(baseType,javaMember,declaringType);
   52       }
   53       
   54       protected void setAnnotatedParameters(Type[] genericParameterTypes,Annotation[][] parameterAnnotations)
   55       {
   56           int i = 0;
   57           
   58           for(Type genericParameter : genericParameterTypes)
   59           {
   60               AnnotatedParameterImpl<X> parameterImpl = new AnnotatedParameterImpl<X>(genericParameter,this,i);
   61               parameterImpl.setAnnotations(parameterAnnotations[i]);
   62               
   63               addAnnotatedParameter(parameterImpl);
   64               
   65               i++;
   66           }
   67       }
   68   
   69       /**
   70        * Adds new annotated parameter.
   71        * 
   72        * @param parameter new annotated parameter
   73        */
   74       void addAnnotatedParameter(AnnotatedParameter<X> parameter)
   75       {
   76           this.annotatedParameters.add(parameter);
   77       }
   78       
   79       /**
   80        * {@inheritDoc}
   81        */
   82       @Override
   83       public List<AnnotatedParameter<X>> getParameters()
   84       {
   85           return this.annotatedParameters;
   86       }
   87       
   88       public String toString()
   89       {
   90           StringBuilder builder = new StringBuilder(super.toString());
   91           builder.append(",");
   92           builder.append("Annotated Parameters : [");
   93           for(AnnotatedParameter<X> parameter : annotatedParameters)
   94           {
   95               builder.append(parameter.toString());
   96           }
   97           builder.append("]");
   98           
   99           return builder.toString();
  100       }
  101    }

Home » apache-openwebbeans-1.0.0-incubating-M3-sources » org.apache.webbeans.portable » [javadoc | source]