Coverage Report - org.apache.camel.spring.xml.BuilderStatement
 
Classes in this File Line Coverage Branch Coverage Complexity
BuilderStatement
88% 
100% 
0
 
 1  
 /**
 2  
  *
 3  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 4  
  * contributor license agreements.  See the NOTICE file distributed with
 5  
  * this work for additional information regarding copyright ownership.
 6  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 7  
  * (the "License"); you may not use this file except in compliance with
 8  
  * 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, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 17  
  */
 18  
 package org.apache.camel.spring.xml;
 19  
 
 20  
 import java.util.ArrayList;
 21  
 
 22  
 import org.springframework.beans.factory.BeanFactory;
 23  
 
 24  28
 public class BuilderStatement {
 25  
         private ArrayList<BuilderAction> actions;
 26  
         private Class returnType;
 27  
 
 28  
         public Object create(BeanFactory beanFactory, Object rootBuilder) {
 29  28
                 Object currentBuilder = rootBuilder;
 30  28
                 BuilderAction lastAction=null;
 31  28
                 for (BuilderAction action : actions) {
 32  
                         // The last action may have left us without a builder to invoke next!
 33  80
                         if( currentBuilder == null ) {
 34  0
                                 throw new IllegalArgumentException("Invalid configuration.  The '"+lastAction.getName()+"' action cannot be followed by the '"+action.getName()+"' action.");
 35  
                         }
 36  80
                         currentBuilder = action.invoke(beanFactory, rootBuilder, currentBuilder);
 37  80
                         lastAction = action;
 38  80
                 }
 39  28
                 return currentBuilder;
 40  
         }
 41  
 
 42  
         public ArrayList<BuilderAction> getActions() {
 43  0
                 return actions;
 44  
         }
 45  
         public void setActions(ArrayList<BuilderAction> actions) {
 46  28
                 this.actions = actions;
 47  28
         }
 48  
 
 49  
         public Class getReturnType() {
 50  8
                 return returnType;
 51  
         }
 52  
         public void setReturnType(Class returnType) {
 53  28
                 this.returnType = returnType;
 54  
                 
 55  28
         }
 56  
 
 57  
 }