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

Method compare

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

{@inheritDoc}

(T object1, T object2)

Source from the content-addressed store, hash-verified

106
107 /** {@inheritDoc} */
108 @Override
109 public int compare(T object1, T object2) {
110 for (Closure closure : closures) {
111 Object value1 = closure.call(object1);
112 Object value2 = closure.call(object2);
113 int result;
114 if (!equalityCheck || (value1 instanceof Comparable && value2 instanceof Comparable)) {
115 result = numberAwareComparator.compare(value1, value2);
116 } else {
117 result = DefaultTypeTransformation.compareEqual(value1, value2) ? 0 : -1;
118 }
119 if (result == 0) continue;
120 return result;
121 }
122 return 0;
123 }
124
125 /**
126 * Indicates whether equality-only comparison is enabled for non-comparable values.

Callers

nothing calls this directly

Calls 3

compareEqualMethod · 0.95
callMethod · 0.65
compareMethod · 0.65

Tested by

no test coverage detected