Coverage Report - org.apache.camel.processor.Resequencer
 
Classes in this File Line Coverage Branch Coverage Complexity
Resequencer
75% 
100% 
0
 
 1  
 /**
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.camel.processor;
 18  
 
 19  
 import java.util.Comparator;
 20  
 import java.util.List;
 21  
 import java.util.Set;
 22  
 import java.util.TreeSet;
 23  
 
 24  
 import org.apache.camel.Endpoint;
 25  
 import org.apache.camel.Exchange;
 26  
 import org.apache.camel.Expression;
 27  
 import org.apache.camel.Processor;
 28  
 import org.apache.camel.util.ExpressionComparator;
 29  
 import org.apache.camel.util.ExpressionListComparator;
 30  
 
 31  
 /**
 32  
  * An implementation of the <a href="http://activemq.apache.org/camel/resequencer.html">Resequencer</a>
 33  
  * which can reorder messages within a batch.
 34  
  *
 35  
  * @version $Revision: 1.1 $
 36  
  */
 37  
 public class Resequencer extends BatchProcessor {
 38  
     public Resequencer(Endpoint endpoint, Processor processor, Expression<Exchange> expression) {
 39  0
         this(endpoint, processor, createSet(expression));
 40  0
     }
 41  
 
 42  
     public Resequencer(Endpoint endpoint, Processor processor, List<Expression> expressions) {
 43  3
         this(endpoint, processor, createSet(expressions));
 44  3
     }
 45  
 
 46  
     public Resequencer(Endpoint endpoint, Processor processor, Set<Exchange> collection) {
 47  3
         super(endpoint, processor, collection);
 48  3
     }
 49  
 
 50  
     @Override
 51  
     public String toString() {
 52  6
         return "Resequencer[to: " + getProcessor() + "]";
 53  
     }
 54  
 
 55  
     // Implementation methods
 56  
     //-------------------------------------------------------------------------
 57  
 
 58  
     protected static Set<Exchange> createSet(Expression<Exchange> expression) {
 59  3
         return createSet(new ExpressionComparator<Exchange>(expression));
 60  
     }
 61  
 
 62  
     protected static Set<Exchange> createSet(List<Expression> expressions) {
 63  3
         if (expressions.size() == 1) {
 64  3
             return createSet(expressions.get(0));
 65  
         }
 66  0
         return createSet(new ExpressionListComparator(expressions));
 67  
     }
 68  
 
 69  
     protected static Set<Exchange> createSet(Comparator<? super Exchange> comparator) {
 70  3
         return new TreeSet<Exchange>(comparator);
 71  
     }
 72  
 }