replaces primitive comparison with x.compare() where x is a wrapper class of the primitive

This commit is contained in:
Igor Curdvanovschi 2018-06-25 22:17:41 +02:00
parent 4aa4291ffc
commit ae6a24dd43
2 changed files with 6 additions and 6 deletions

View File

@ -475,7 +475,7 @@ public class CompareToBuilder implements Builder<Integer> {
if (comparison != 0) { if (comparison != 0) {
return this; return this;
} }
comparison = lhs < rhs ? -1 : lhs > rhs ? 1 : 0; comparison = Long.compare(lhs, rhs);
return this; return this;
} }
@ -491,7 +491,7 @@ public class CompareToBuilder implements Builder<Integer> {
if (comparison != 0) { if (comparison != 0) {
return this; return this;
} }
comparison = lhs < rhs ? -1 : lhs > rhs ? 1 : 0; comparison = Integer.compare(lhs, rhs);
return this; return this;
} }
@ -507,7 +507,7 @@ public class CompareToBuilder implements Builder<Integer> {
if (comparison != 0) { if (comparison != 0) {
return this; return this;
} }
comparison = lhs < rhs ? -1 : lhs > rhs ? 1 : 0; comparison = Short.compare(lhs, rhs);
return this; return this;
} }
@ -523,7 +523,7 @@ public class CompareToBuilder implements Builder<Integer> {
if (comparison != 0) { if (comparison != 0) {
return this; return this;
} }
comparison = lhs < rhs ? -1 : lhs > rhs ? 1 : 0; comparison = Character.compare(lhs, rhs);
return this; return this;
} }
@ -539,7 +539,7 @@ public class CompareToBuilder implements Builder<Integer> {
if (comparison != 0) { if (comparison != 0) {
return this; return this;
} }
comparison = lhs < rhs ? -1 : lhs > rhs ? 1 : 0; comparison = Byte.compare(lhs, rhs);
return this; return this;
} }

View File

@ -61,7 +61,7 @@ public class CompareToBuilderTest {
} }
@Override @Override
public int compareTo(final TestObject rhs) { public int compareTo(final TestObject rhs) {
return a < rhs.a ? -1 : a > rhs.a ? +1 : 0; return Integer.compare(a, rhs.a);
} }
} }