All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ibm.icu.impl.MultiComparator Maven / Gradle / Ivy

Go to download

Vaadin is a web application framework for Rich Internet Applications (RIA). Vaadin enables easy development and maintenance of fast and secure rich web applications with a stunning look and feel and a wide browser support. It features a server-side architecture with the majority of the logic running on the server. Ajax technology is used at the browser-side to ensure a rich and interactive user experience.

There is a newer version: 1.2.0
Show newest version
/*
 *******************************************************************************
 * Copyright (C) 2009, International Business Machines Corporation and         *
 * others. All Rights Reserved.                                                *
 *******************************************************************************
 */
package com.ibm.icu.impl;

import java.util.Comparator;

public class MultiComparator implements Comparator {
    private Comparator[] comparators;

    public MultiComparator (Comparator... comparators) {
        this.comparators = comparators;
    }

    /* Lexigraphic compare. Returns the first difference
     * @return zero if equal. Otherwise +/- (i+1) 
     * where i is the index of the first comparator finding a difference
     * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
     */
    public int compare(T arg0, T arg1) {
        for (int i = 0; i < comparators.length; ++i) {
            int result = comparators[i].compare(arg0, arg1);
            if (result == 0) {
                continue;
            }
            if (result > 0) {
                return i + 1;
            }
            return -(i + 1);
        }
        return 0;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy