Coverage Report - org.jtheque.primary.view.impl.choice.ChoiceActionFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
ChoiceActionFactory
0 %
0/14
0 %
0/6
1.8
 
 1  
 package org.jtheque.primary.view.impl.choice;
 2  
 
 3  
 /*
 4  
  * This file is part of JTheque.
 5  
  *
 6  
  * JTheque is free software: you can redistribute it and/or modify
 7  
  * it under the terms of the GNU General Public License as published by
 8  
  * the Free Software Foundation, either version 3 of the License.
 9  
  *
 10  
  * JTheque is distributed in the hope that it will be useful,
 11  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13  
  * GNU General Public License for more details.
 14  
  *
 15  
  * You should have received a copy of the GNU General Public License
 16  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 17  
  */
 18  
 
 19  
 import java.util.ArrayList;
 20  
 import java.util.Collection;
 21  
 
 22  
 /**
 23  
  * A factory of choice actions.
 24  
  *
 25  
  * @author Baptiste Wicht
 26  
  */
 27  
 public final class ChoiceActionFactory {
 28  0
         private static final Collection<ChoiceAction> ACTIONS = new ArrayList<ChoiceAction>(6);
 29  
 
 30  
         /**
 31  
          * Construct a <code>ChoiceActionFactory</code>.
 32  
          */
 33  
         private ChoiceActionFactory(){
 34  0
                 super();
 35  0
         }
 36  
 
 37  
         /**
 38  
          * Get the good choice action for a specific type of action.
 39  
          *
 40  
          * @param action The type of the action
 41  
          *
 42  
          * @return The good choice action or null if we don't found it.
 43  
          */
 44  
         public static ChoiceAction getChoiceAction(String action){
 45  0
                 for (ChoiceAction choiceAction : ACTIONS){
 46  0
                         if (choiceAction.canDoAction(action)){
 47  0
                                 return choiceAction;
 48  
                         }
 49  
                 }
 50  
 
 51  0
                 return null;
 52  
         }
 53  
 
 54  
         /**
 55  
          * Add a choice action.
 56  
          *
 57  
          * @param action The choice action.
 58  
          */
 59  
         public static void addChoiceAction(ChoiceAction action){
 60  0
                 ACTIONS.add(action);
 61  0
         }
 62  
 
 63  
         /**
 64  
          * Remove a choice action.
 65  
          *
 66  
          * @param action The choice action.
 67  
          */
 68  
         public static void removeChoiceAction(ChoiceAction action){
 69  0
                 ACTIONS.remove(action);
 70  0
         }
 71  
 
 72  
         /**
 73  
          * Remove the specified choice actions.
 74  
          *
 75  
          * @param choiceActions The actions to remove.
 76  
          */
 77  
         public static void removeChoiceActions(ChoiceAction[] choiceActions){
 78  0
                 for (ChoiceAction action : choiceActions){
 79  0
                         removeChoiceAction(action);
 80  
                 }
 81  0
         }
 82  
 }