Coverage Report - org.eclipse.swtbot.generator.SWTBotGeneratorFactoryReader
 
Classes in this File Line Coverage Branch Coverage Complexity
SWTBotGeneratorFactoryReader
0%
0/17
0%
0/6
2
 
 1  
 /*******************************************************************************
 2  
  * Copyright (c) 2008 Ketan Padegaonkar and others.
 3  
  * All rights reserved. This program and the accompanying materials
 4  
  * are made available under the terms of the Eclipse Public License v1.0
 5  
  * which accompanies this distribution, and is available at
 6  
  * http://www.eclipse.org/legal/epl-v10.html
 7  
  *
 8  
  * Contributors:
 9  
  *     Ketan Padegaonkar - initial API and implementation
 10  
  *******************************************************************************/
 11  
 package org.eclipse.swtbot.generator;
 12  
 
 13  
 import java.lang.reflect.Constructor;
 14  
 import java.util.ArrayList;
 15  
 import java.util.Collection;
 16  
 
 17  
 import org.eclipse.swtbot.swt.finder.SWTBotWidget;
 18  
 
 19  
 /**
 20  
  * @author Ketan Padegaonkar <KetanPadegaonkar [at] gmail [dot] com>
 21  
  * @version $Id$
 22  
  */
 23  
 public class SWTBotGeneratorFactoryReader {
 24  
 
 25  
         private SWTBotWidget        annotation;
 26  
         private Constructor<?>        constructor;
 27  
         private Class<?>                clasz;
 28  
 
 29  0
         public SWTBotGeneratorFactoryReader(String className) throws ClassNotFoundException {
 30  0
                 clasz = Class.forName(className);
 31  0
                 annotation = getSWTBotAnnotation();
 32  0
                 constructor = getConstructor();
 33  0
         }
 34  
 
 35  
         public ArrayList<String> getMethods() {
 36  0
                 if (annotation == null)
 37  0
                         return new ArrayList<String>();
 38  
 
 39  
                 Class<?> returnType;
 40  
 
 41  0
                 returnType = annotation.returnType();
 42  0
                 if (returnType == Object.class)
 43  0
                         returnType = constructor.getDeclaringClass();
 44  
 
 45  0
                 Class<?> creationType = constructor.getDeclaringClass();
 46  0
                 return MethodFactory.methods(annotation, returnType, creationType, annotation.clasz(), annotation.preferredName());
 47  
         }
 48  
 
 49  
         public Collection<? extends String> getImports() {
 50  0
                 if (annotation == null)
 51  0
                         return new ArrayList<String>();
 52  0
                 return MethodFactory.imports(annotation, constructor.getDeclaringClass(), annotation.clasz(), annotation.preferredName());
 53  
         }
 54  
 
 55  
         private Constructor<?> getConstructor() {
 56  0
                 return clasz.getConstructors()[0];
 57  
         }
 58  
 
 59  
         private SWTBotWidget getSWTBotAnnotation() {
 60  0
                 return clasz.getAnnotation(SWTBotWidget.class);
 61  
         }
 62  
 
 63  
 }