Coverage Report - org.eclipse.swtbot.generator.MethodFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
MethodFactory
0%
0/18
0%
0/4
1.667
 
 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.util.ArrayList;
 14  
 import java.util.Arrays;
 15  
 import java.util.Collection;
 16  
 import java.util.List;
 17  
 
 18  
 import org.eclipse.swt.widgets.Widget;
 19  
 import org.eclipse.swtbot.swt.finder.ReferenceBy;
 20  
 import org.eclipse.swtbot.swt.finder.SWTBotWidget;
 21  
 
 22  
 /**
 23  
  * @author Ketan Padegaonkar <KetanPadegaonkar [at] gmail [dot] com>
 24  
  * @version $Id$
 25  
  */
 26  0
 public class MethodFactory {
 27  
 
 28  
         public static ArrayList<String> methods(SWTBotWidget annotation, Class<?> returnType, Class<?> creationType, Class<? extends Widget> widgetType, String methodPrefix) {
 29  0
                 ArrayList<String> result = new ArrayList<String>();
 30  
 
 31  0
                 List<List<ReferenceBy>> references = getReferenceCombinations(annotation);
 32  0
                 for (List<ReferenceBy> list : references) {
 33  0
                         result.add(new MethodGenerator(returnType, creationType, widgetType, methodPrefix, annotation.style().name(), list).commentContents());
 34  0
                         result.add(new MethodGenerator(returnType, creationType, widgetType, methodPrefix, annotation.style().name(), list).methodContents());
 35  0
                         result.add(new MethodGenerator(returnType, creationType, widgetType, methodPrefix, annotation.style().name(), list).commentContentsWithIndex());
 36  0
                         result.add(new MethodGenerator(returnType, creationType, widgetType, methodPrefix, annotation.style().name(), list).methodContentsWithIndex());
 37  
                 }
 38  0
                 return result;
 39  
         }
 40  
 
 41  
         private static List<List<ReferenceBy>> getReferenceCombinations(SWTBotWidget annotation) {
 42  0
                 List<ReferenceBy> value = new ArrayList<ReferenceBy>(Arrays.asList(annotation.referenceBy()));
 43  0
                 value.addAll(Arrays.asList(annotation.defaultReferenceBy()));
 44  0
                 ReferenceBy[] array = value.toArray(new ReferenceBy[] {});
 45  0
                 return ReferenceBy.getCombinations(array);
 46  
         }
 47  
 
 48  
         public static Collection<? extends String> imports(SWTBotWidget annotation, Class<?> returnType, Class<? extends Widget> widgetType, String methodPrefix) {
 49  0
                 ArrayList<String> result = new ArrayList<String>();
 50  0
                 List<List<ReferenceBy>> references = getReferenceCombinations(annotation);
 51  0
                 for (List<ReferenceBy> list : references) {
 52  0
                         result.addAll(new MethodGenerator(returnType, null, widgetType, methodPrefix, annotation.style().name(), list).imports());
 53  
                 }
 54  0
                 return result;
 55  
         }
 56  
 }