Coverage Report - org.apache.tapestry5.internal.services.BeanBlockSourceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
BeanBlockSourceImpl
100%
17/17
100%
12/12
0
 
 1  
 // Copyright 2007, 2008 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.internal.services;
 16  
 
 17  
 import org.apache.tapestry5.Block;
 18  
 import org.apache.tapestry5.services.BeanBlockContribution;
 19  
 import org.apache.tapestry5.services.BeanBlockOverrideSource;
 20  
 import org.apache.tapestry5.services.BeanBlockSource;
 21  
 
 22  
 import java.util.Collection;
 23  
 
 24  
 public class BeanBlockSourceImpl implements BeanBlockSource
 25  
 {
 26  
     // This is checked before masterSource
 27  
     private final BeanBlockOverrideSource overrideSource;
 28  
 
 29  
     private final BeanBlockOverrideSource masterSource;
 30  
 
 31  
     public BeanBlockSourceImpl(RequestPageCache pageCache,
 32  
                                BeanBlockOverrideSource overrideSource, Collection<BeanBlockContribution> configuration)
 33  18
     {
 34  18
         this.overrideSource = overrideSource;
 35  18
         masterSource = new BeanBlockOverrideSourceImpl(pageCache, configuration);
 36  18
     }
 37  
 
 38  
     public boolean hasDisplayBlock(String datatype)
 39  
     {
 40  7386
         return overrideSource.hasDisplayBlock(datatype) || masterSource.hasDisplayBlock(datatype);
 41  
     }
 42  
 
 43  
     public Block getDisplayBlock(String datatype)
 44  
     {
 45  316
         Block result = overrideSource.getDisplayBlock(datatype);
 46  
 
 47  316
         if (result == null)
 48  310
             result = masterSource.getDisplayBlock(datatype);
 49  
 
 50  316
         if (result == null)
 51  2
             throw new RuntimeException(ServicesMessages.noDisplayForDataType(datatype));
 52  
 
 53  314
         return result;
 54  
     }
 55  
 
 56  
     public Block getEditBlock(String datatype)
 57  
     {
 58  268
         Block result = overrideSource.getEditBlock(datatype);
 59  
 
 60  268
         if (result == null)
 61  266
             result = masterSource.getEditBlock(datatype);
 62  
 
 63  268
         if (result == null)
 64  2
             throw new RuntimeException(ServicesMessages.noEditForDataType(datatype));
 65  
 
 66  266
         return result;
 67  
     }
 68  
 
 69  
 }