* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
* Implements a {@link Comparator} for {@link DefinedTermBase} objects based on the term's label.
* The compare algorithm compares a term's label. Example: If used on an unsorted list of terms, the
* list will be alphabetically sorted by label afterwards.
* Implements a {@link Comparator} for {@link DefinedTermBase} objects based on the term's label.
* The compare algorithm compares a term's label. Example: If used on an unsorted list of terms, the
* list will be alphabetically sorted by label afterwards.
public class DefaultTermComparator<T extends DefinedTermBase> implements Comparator<T> {
@Override
public int compare(T o1, T o2) {
public class DefaultTermComparator<T extends DefinedTermBase> implements Comparator<T> {
@Override
public int compare(T o1, T o2) {
String label1 = o1.getLabel(CdmStore.getDefaultLanguage()) != null ? o1.getLabel(CdmStore.getDefaultLanguage()) : o1.getTitleCache();
String label2 = o2.getLabel(CdmStore.getDefaultLanguage()) != null ? o2.getLabel(CdmStore.getDefaultLanguage()) : o2.getTitleCache();
String label1 = o1.getLabel(CdmStore.getDefaultLanguage()) != null ? o1.getLabel(CdmStore.getDefaultLanguage()) : o1.getTitleCache();
String label2 = o2.getLabel(CdmStore.getDefaultLanguage()) != null ? o2.getLabel(CdmStore.getDefaultLanguage()) : o2.getTitleCache();