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

org.springframework.contributions.util.DictionaryComparator Maven / Gradle / Ivy

Go to download

This project adds a so called contribution mechanism (like known from Tapestry IOC or Eclipse Plugins) for configuration and extension of services to the Spring project.

There is a newer version: 2.0.0
Show newest version
package org.springframework.contributions.util;

import java.text.Collator;
import java.util.Comparator;
import java.util.Locale;

/**
 * A comparator for {@link Orderable} objects to sort them alphabetical (the case is ignored)
 * 
 * @author Manfred Hantschel
 */
public class DictionaryComparator implements Comparator
{
    /**
     * A collator set to primary strength, which means 'a', 'A' and 'ä' is the same
     */
    public static final Collator DICTIONARY_COLLATOR;

    static
    {
        DICTIONARY_COLLATOR = Collator.getInstance(Locale.ENGLISH);

        DICTIONARY_COLLATOR.setStrength(Collator.PRIMARY);
        DICTIONARY_COLLATOR.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
    }

    /**
     * {@inheritDoc}
     */
    public int compare(final Orderable left, final Orderable right)
    {
        return DICTIONARY_COLLATOR.compare(left.getOrderableId(), right.getOrderableId());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy