Coverage Report - org.apache.myfaces.flow.builder.NavigationCaseBuilderImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
NavigationCaseBuilderImpl
0%
0/28
0%
0/4
1.364
NavigationCaseBuilderImpl$RedirectBuilderImpl
0%
0/13
0%
0/4
1.364
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License.  You may obtain a copy of the License at
 9  
  *
 10  
  *   http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing,
 13  
  * software distributed under the License is distributed on an
 14  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15  
  * KIND, either express or implied.  See the License for the
 16  
  * specific language governing permissions and limitations
 17  
  * under the License.
 18  
  */
 19  
 package org.apache.myfaces.flow.builder;
 20  
 
 21  
 import java.util.ArrayList;
 22  
 import java.util.HashMap;
 23  
 import java.util.List;
 24  
 import java.util.Map;
 25  
 import javax.el.ValueExpression;
 26  
 import javax.faces.flow.builder.NavigationCaseBuilder;
 27  
 import org.apache.myfaces.flow.FlowImpl;
 28  
 import org.apache.myfaces.flow.NavigationCaseImpl;
 29  
 
 30  
 /**
 31  
  *
 32  
  * @author lu4242
 33  
  */
 34  0
 public class NavigationCaseBuilderImpl extends NavigationCaseBuilder
 35  
 {
 36  
     private FlowImpl _facesFlow;
 37  
     private FlowBuilderImpl _flowBuilder;
 38  
     private NavigationCaseImpl _navigationCaseImpl;
 39  
     
 40  
     public NavigationCaseBuilderImpl(FlowBuilderImpl flowBuilder, FlowImpl facesFlow)
 41  0
     {
 42  0
         this._flowBuilder = flowBuilder;
 43  0
         this._facesFlow = facesFlow;
 44  0
         this._navigationCaseImpl = new NavigationCaseImpl();
 45  0
     }
 46  
     
 47  
     @Override
 48  
     public NavigationCaseBuilder fromViewId(String fromViewId)
 49  
     {
 50  
         // This is the best place to add the navigation case into the flow, because
 51  
         // fromViewId is required (cannot be null, and null does not mean '*')
 52  0
         if (this._navigationCaseImpl.getFromViewId() != null)
 53  
         {
 54  0
             this._facesFlow.removeNavigationCase(_navigationCaseImpl);
 55  
         }
 56  0
         if (fromViewId != null)
 57  
         {
 58  0
             this._navigationCaseImpl.setFromViewId(fromViewId);
 59  0
             this._facesFlow.addNavigationCase(_navigationCaseImpl);
 60  
         }
 61  0
         return this;
 62  
     }
 63  
 
 64  
     @Override
 65  
     public NavigationCaseBuilder fromAction(String fromAction)
 66  
     {
 67  0
         this._navigationCaseImpl.setFromAction(fromAction);
 68  0
         return this;
 69  
     }
 70  
 
 71  
     @Override
 72  
     public NavigationCaseBuilder fromOutcome(String fromOutcome)
 73  
     {
 74  0
         this._navigationCaseImpl.setFromOutcome(fromOutcome);
 75  0
         return this;
 76  
     }
 77  
 
 78  
     @Override
 79  
     public NavigationCaseBuilder toViewId(String toViewId)
 80  
     {
 81  0
         this._navigationCaseImpl.setToViewId(toViewId);
 82  0
         return this;
 83  
     }
 84  
 
 85  
     @Override
 86  
     public NavigationCaseBuilder toFlowDocumentId(String toFlowDocumentId) 
 87  
     {
 88  0
         this._navigationCaseImpl.setToFlowDocumentId(toFlowDocumentId);
 89  0
         return this;
 90  
     }
 91  
 
 92  
     @Override
 93  
     public NavigationCaseBuilder condition(String condition)
 94  
     {
 95  0
         this._navigationCaseImpl.setConditionExpression(null);
 96  0
         this._navigationCaseImpl.setCondition(condition);
 97  0
         return this;
 98  
     }
 99  
 
 100  
     @Override
 101  
     public NavigationCaseBuilder condition(ValueExpression condition)
 102  
     {
 103  0
         this._navigationCaseImpl.setCondition(null);
 104  0
         this._navigationCaseImpl.setConditionExpression(condition);
 105  0
         return this;
 106  
     }
 107  
 
 108  
     @Override
 109  
     public RedirectBuilder redirect()
 110  
     {
 111  0
         this._navigationCaseImpl.setRedirect(true);
 112  0
         return new RedirectBuilderImpl();
 113  
     }
 114  
     
 115  0
     public class RedirectBuilderImpl extends RedirectBuilder
 116  
     {
 117  
 
 118  
         @Override
 119  
         public RedirectBuilder parameter(String name, String value)
 120  
         {
 121  
             //_navigationCaseImpl.
 122  0
             Map<String, List<String>> map = _navigationCaseImpl.getParameters();
 123  0
             if (map == null)
 124  
             {
 125  0
                 map = new HashMap<String, List<String>>();
 126  0
                 _navigationCaseImpl.setParameters(map);
 127  
             }
 128  0
             List<String> values = map.get(name);
 129  0
             if (values == null)
 130  
             {
 131  0
                 values = new ArrayList<String>();
 132  0
                 map.put(name, values);
 133  
             }
 134  0
             values.add(value);
 135  0
             return this;
 136  
         }
 137  
 
 138  
         @Override
 139  
         public RedirectBuilder includeViewParams()
 140  
         {
 141  0
             _navigationCaseImpl.setIncludeViewParams(true);
 142  0
             return this;
 143  
         }
 144  
         
 145  
     }
 146  
 }