Coverage Report - org.apache.camel.processor.FilterProcessor
 
Classes in this File Line Coverage Branch Coverage Complexity
FilterProcessor
100% 
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.processor;
 19  
 
 20  
 import org.apache.camel.Predicate;
 21  
 import org.apache.camel.Processor;
 22  
 import org.apache.camel.Exchange;
 23  
 import org.apache.camel.impl.ServiceSupport;
 24  
 import org.apache.camel.util.ServiceHelper;
 25  
 
 26  
 /**
 27  
  * @version $Revision: 534941 $
 28  
  */
 29  
 public class FilterProcessor extends ServiceSupport implements Processor {
 30  
     private Predicate<Exchange> predicate;
 31  
     private Processor processor;
 32  
 
 33  23
     public FilterProcessor(Predicate<Exchange> predicate, Processor processor) {
 34  23
         this.predicate = predicate;
 35  23
         this.processor = processor;
 36  23
     }
 37  
 
 38  
     public void process(Exchange exchange) throws Exception {
 39  8
         if (predicate.matches(exchange)) {
 40  4
             processor.process(exchange);
 41  
         }
 42  8
     }
 43  
 
 44  
     @Override
 45  
     public String toString() {
 46  27
         return "filter (" + predicate + ") " + processor;
 47  
     }
 48  
 
 49  
     public Predicate<Exchange> getPredicate() {
 50  26
         return predicate;
 51  
     }
 52  
 
 53  
     public Processor getProcessor() {
 54  25
         return processor;
 55  
     }
 56  
 
 57  
     protected void doStart() throws Exception {
 58  16
         ServiceHelper.startServices(processor);
 59  16
     }
 60  
 
 61  
     protected void doStop() throws Exception {
 62  16
         ServiceHelper.stopServices(processor);
 63  16
     }
 64  
 }