org.springframework.contributions.util.DictionaryComparator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spring-contributions Show documentation
Show all versions of spring-contributions Show documentation
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.
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