Search in sources :

Example 1 with ExchangeAccessor

use of com.predic8.membrane.core.exchange.accessors.ExchangeAccessor in project service-proxy by membrane.

the class ExchangeComparator method compare.

@SuppressWarnings({ "rawtypes", "unchecked" })
public int compare(AbstractExchange e1, AbstractExchange e2) {
    if (e1.getResponse() == null || e2.getResponse() == null)
        return 0;
    for (ExchangeAccessor accessor : accessors) {
        Comparable comp1 = (Comparable) accessor.get(e1);
        Comparable comp2 = (Comparable) accessor.get(e2);
        int result = comp1.compareTo(comp2);
        if (result != 0) {
            if (ascending) {
                return comp1.compareTo(comp2);
            } else {
                return comp2.compareTo(comp1);
            }
        }
    }
    return 0;
}
Also used : ExchangeAccessor(com.predic8.membrane.core.exchange.accessors.ExchangeAccessor)

Aggregations

ExchangeAccessor (com.predic8.membrane.core.exchange.accessors.ExchangeAccessor)1