List of usage examples for java.util Comparator naturalOrder
@SuppressWarnings("unchecked") public static <T extends Comparable<? super T>> Comparator<T> naturalOrder()
From source file:org.opensingular.lib.wicket.util.lambda.ILambdasMixin.java
@SuppressWarnings("unchecked") default <T, R extends Comparable<R>> Comparator<T> compareWith(IFunction<T, R> func) { return (T a, T b) -> ComparatorUtils.nullLowComparator(Comparator.naturalOrder()).compare(func.apply(a), func.apply(b));// w w w . ja v a2 s . co m }
From source file:org.pdfsam.ui.selection.multiple.LoadingColumn.java
public Comparator<PdfDescriptorLoadingStatus> comparator() { return Comparator.naturalOrder(); }
From source file:org.pdfsam.ui.selection.multiple.PaceColumn.java
@Override public Comparator<String> comparator() { return Comparator.naturalOrder(); }
From source file:org.talend.dataprep.util.SortAndOrderHelper.java
/** * Return the string comparator to use for the given order name. * * @param orderKey the name of the order to apply. * @return the string comparator to use for the given order name. */// ww w . j a v a 2 s . c om private static Comparator<String> getOrderComparator(String orderKey) { final Comparator<String> comparisonOrder; // Select order (asc or desc) final Order order; try { order = Order.valueOf(orderKey.toUpperCase()); } catch (IllegalArgumentException e) { throw new TDPException(CommonErrorCodes.ILLEGAL_ORDER_FOR_LIST, build().put("order", orderKey)); } switch (order) { case ASC: comparisonOrder = Comparator.naturalOrder(); break; case DESC: comparisonOrder = Comparator.reverseOrder(); break; default: // this should not happen throw new TDPException(CommonErrorCodes.ILLEGAL_ORDER_FOR_LIST, build().put("order", orderKey)); } return comparisonOrder; }
From source file:org.xlrnet.tibaija.util.ComplexComparator.java
@Override public int compare(Complex o1, Complex o2) { boolean isNoneImaginary = o1.getImaginary() == 0 && o2.getImaginary() == 0; boolean isNoneReal = o1.getReal() == 0 && o2.getReal() == 0; if (isNoneImaginary && isNoneReal) // Comparison of zero and zero -> equal return 0; if (!isNoneImaginary && !isNoneReal) // Comparison of complex and imaginary throw new UnsupportedOperationException( "Comparison of complex numbers with imaginary part is not allowed"); if (isNoneImaginary) return Objects.compare(o1.getReal(), o2.getReal(), Comparator.naturalOrder()); else/*from w w w . j a v a2 s . c o m*/ return Objects.compare(o1.getImaginary(), o2.getImaginary(), Comparator.naturalOrder()); }