org.apache.commons.collections4.comparators.NullComparator Java Examples

The following examples show how to use org.apache.commons.collections4.comparators.NullComparator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainLogicImpl.java    From icure-backend with GNU General Public License v2.0 5 votes vote down vote up
private <E> void sort(List<E> entities, List<SortOrder<String>> sortOrders) {
	if (sortOrders != null && sortOrders.size() > 0) {
		ComparatorChain<E> comparatorChain = new ComparatorChain<>();
		for (SortOrder<String> sortOrder : sortOrders) {
			comparatorChain.addComparator(new BeanComparator<>(sortOrder.getKey(), new NullComparator<>(ComparableComparator.comparableComparator(), true)), sortOrder.getDirection() == SortDir.DESC);
		}
		Collections.sort(entities, comparatorChain);
	}
}
 
Example #2
Source File: CalculatedQuestionBean.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * getFormulasList returns a List of all formulas, sorted by formula name
 * @return
 */
public List<CalculatedQuestionFormulaBean> getFormulasList() {
    List<CalculatedQuestionFormulaBean> beanList = new ArrayList<CalculatedQuestionFormulaBean>(formulas.values());
    Collections.sort(beanList, new Comparator<CalculatedQuestionFormulaBean>() {
        public int compare(CalculatedQuestionFormulaBean bean1, CalculatedQuestionFormulaBean bean2) {
            return new NullComparator().compare(bean1.getName(), bean2.getName());
        }
    });
    return beanList;
}
 
Example #3
Source File: CalculatedQuestionBean.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * getVariablesList returns a List of all variables, sorted by variable name
 * @return
 */
public List<CalculatedQuestionVariableBean> getVariablesList() {
    List<CalculatedQuestionVariableBean> beanList = new ArrayList<CalculatedQuestionVariableBean>(variables.values());
    Collections.sort(beanList, new Comparator<CalculatedQuestionVariableBean>() {
        public int compare(CalculatedQuestionVariableBean bean1, CalculatedQuestionVariableBean bean2) {
            return new NullComparator().compare(bean1.getName(), bean2.getName());
        }
    });
    return beanList;
}
 
Example #4
Source File: AbstractOrderedMapTest.java    From jesterj with Apache License 2.0 5 votes vote down vote up
/**
 * The only confirmed collection we have that is ordered is the sorted one.
 * Thus, sort the keys.
 */
@Override
@SuppressWarnings("unchecked")
public K[] getSampleKeys() {
    final List<K> list = new ArrayList<>(Arrays.asList(super.getSampleKeys()));
    Collections.sort(list, new NullComparator<K>());
    return (K[]) list.toArray();
}
 
Example #5
Source File: CalculatedQuestionBean.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * getFormulasList returns a List of all formulas, sorted by formula name
 * @return
 */
public List<CalculatedQuestionFormulaBean> getFormulasList() {
    List<CalculatedQuestionFormulaBean> beanList = new ArrayList<CalculatedQuestionFormulaBean>(formulas.values());
    Collections.sort(beanList, new Comparator<CalculatedQuestionFormulaBean>() {
        public int compare(CalculatedQuestionFormulaBean bean1, CalculatedQuestionFormulaBean bean2) {
            return new NullComparator().compare(bean1.getName(), bean2.getName());
        }
    });
    return beanList;
}
 
Example #6
Source File: CalculatedQuestionBean.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * getVariablesList returns a List of all variables, sorted by variable name
 * @return
 */
public List<CalculatedQuestionVariableBean> getVariablesList() {
    List<CalculatedQuestionVariableBean> beanList = new ArrayList<CalculatedQuestionVariableBean>(variables.values());
    Collections.sort(beanList, new Comparator<CalculatedQuestionVariableBean>() {
        public int compare(CalculatedQuestionVariableBean bean1, CalculatedQuestionVariableBean bean2) {
            return new NullComparator().compare(bean1.getName(), bean2.getName());
        }
    });
    return beanList;
}
 
Example #7
Source File: AbstractOrderedMapTest.java    From jesterj with Apache License 2.0 2 votes vote down vote up
/**
 * OrderedMap uses TreeMap as its known comparison.
 *
 * @return a map that is known to be valid
 */
@Override
public Map<K, V> makeConfirmedMap() {
    return new TreeMap<>(new NullComparator<K>());
}