Coverage Report - org.apache.camel.util.ExpressionListComparator
 
Classes in this File Line Coverage Branch Coverage Complexity
ExpressionListComparator
0% 
0% 
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.util;
 19  
 
 20  
 import org.apache.camel.Exchange;
 21  
 import org.apache.camel.Expression;
 22  
 
 23  
 import java.util.Comparator;
 24  
 import java.util.List;
 25  
 
 26  
 /**
 27  
  * An implementation of {@link java.util.Comparator} which takes a list of
 28  
  * {@link org.apache.camel.Expression} objects which is evaluated
 29  
  * on each exchange to compare them
 30  
  *
 31  
  * @version $Revision: 1.1 $
 32  
  */
 33  0
 public class ExpressionListComparator<E extends Exchange> implements Comparator<E> {
 34  
     private final List<Expression<E>> expressions;
 35  
 
 36  0
     public ExpressionListComparator(List<Expression<E>> expressions) {
 37  0
         this.expressions = expressions;
 38  0
     }
 39  
 
 40  
     public int compare(E e1, E e2) {
 41  0
         for (Expression<E> expression : expressions) {
 42  0
             Object o1 = expression.evaluate(e1);
 43  0
             Object o2 = expression.evaluate(e2);
 44  0
             int answer = ObjectHelper.compare(o1, o2);
 45  0
             if (answer != 0) {
 46  0
                 return answer;
 47  
             }
 48  0
         }
 49  0
         return 0;
 50  
     }
 51  
 }