Coverage Report - org.apache.tapestry5.util.AbstractSelectModel
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractSelectModel
100%
13/13
100%
8/8
0
 
 1  
 // Copyright 2007 The Apache Software Foundation
 2  
 //
 3  
 // Licensed under the Apache License, Version 2.0 (the "License");
 4  
 // you may not use this file except in compliance with the License.
 5  
 // You may obtain a copy of the License at
 6  
 //
 7  
 //     http://www.apache.org/licenses/LICENSE-2.0
 8  
 //
 9  
 // Unless required by applicable law or agreed to in writing, software
 10  
 // distributed under the License is distributed on an "AS IS" BASIS,
 11  
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12  
 // See the License for the specific language governing permissions and
 13  
 // limitations under the License.
 14  
 
 15  
 package org.apache.tapestry5.util;
 16  
 
 17  
 import org.apache.tapestry5.OptionGroupModel;
 18  
 import org.apache.tapestry5.OptionModel;
 19  
 import org.apache.tapestry5.SelectModel;
 20  
 import org.apache.tapestry5.SelectModelVisitor;
 21  
 
 22  
 import java.util.List;
 23  
 
 24  
 /**
 25  
  * Base class for {@link SelectModel} implementations, whose primary job is to provide the {@link
 26  
  * #visit(SelectModelVisitor)} method.
 27  
  */
 28  93
 public abstract class AbstractSelectModel implements SelectModel
 29  
 {
 30  
     public final void visit(SelectModelVisitor visitor)
 31  
     {
 32  174
         List<OptionGroupModel> groups = getOptionGroups();
 33  
 
 34  174
         if (groups != null)
 35  
         {
 36  6
             for (OptionGroupModel groupModel : groups)
 37  
             {
 38  8
                 visitor.beginOptionGroup(groupModel);
 39  
 
 40  8
                 visitOptions(groupModel.getOptions(), visitor);
 41  
 
 42  8
                 visitor.endOptionGroup(groupModel);
 43  
             }
 44  
         }
 45  
 
 46  174
         visitOptions(getOptions(), visitor);
 47  174
     }
 48  
 
 49  
     private void visitOptions(List<OptionModel> options, SelectModelVisitor vistor)
 50  
     {
 51  182
         if (options != null)
 52  
         {
 53  176
             for (OptionModel optionModel : options)
 54  736
                 vistor.option(optionModel);
 55  
         }
 56  182
     }
 57  
 
 58  
 }