MCPcopy Index your code
hub / github.com/apache/groovy / OrderBy

Class OrderBy

src/main/java/groovy/util/OrderBy.java:35–142  ·  view source on GitHub ↗

A helper class for sorting objects via a closure to return the field or operation on which to sort.

Source from the content-addressed store, hash-verified

33 * or operation on which to sort.
34 */
35public class OrderBy<T> implements Comparator<T>, Serializable {
36
37 @Serial private static final long serialVersionUID = 8385130064804116654L;
38 private final List<Closure> closures;
39 private boolean equalityCheck;
40 private final NumberAwareComparator<Object> numberAwareComparator = new NumberAwareComparator<Object>();
41
42 /**
43 * Creates an ordering with no comparison closures.
44 */
45 public OrderBy() {
46 this(new ArrayList<Closure>(), false);
47 }
48
49 /**
50 * Creates an ordering with no comparison closures.
51 *
52 * @param equalityCheck whether equality-only comparison should be used for non-comparable values
53 */
54 public OrderBy(boolean equalityCheck) {
55 this(new ArrayList<Closure>(), equalityCheck);
56 }
57
58 /**
59 * Creates an ordering using a single comparison closure.
60 *
61 * @param closure the comparison closure
62 */
63 public OrderBy(Closure closure) {
64 this(closure, false);
65 }
66
67 /**
68 * Creates an ordering using a single comparison closure.
69 *
70 * @param closure the comparison closure
71 * @param equalityCheck whether equality-only comparison should be used for non-comparable values
72 */
73 public OrderBy(Closure closure, boolean equalityCheck) {
74 this(new ArrayList<Closure>(), equalityCheck);
75 closures.add(closure);
76 }
77
78 /**
79 * Creates an ordering using the supplied comparison closures.
80 *
81 * @param closures the comparison closures
82 */
83 public OrderBy(List<Closure> closures) {
84 this(closures, false);
85 }
86
87 /**
88 * Creates an ordering using the supplied comparison closures.
89 *
90 * @param closures the comparison closures
91 * @param equalityCheck whether equality-only comparison should be used for non-comparable values
92 */

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…