mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 03:13:40 +07:00
IDEA-171854 Suggest replacing boxed compareTo with convenience methods from Java 7
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
||||
// "Fix all 'Unnecessary boxing to compare primitives' problems in file" "true"
|
||||
public class Test {
|
||||
public void test(int a, int b) {
|
||||
if(Integer.compare(a, b) > 0) {
|
||||
System.out.println(1);
|
||||
}
|
||||
if(Long.compare(a, b) > 0) {
|
||||
System.out.println(1);
|
||||
}
|
||||
if(Double.compare(a, b) > 0) {
|
||||
System.out.println(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Fix all 'Unnecessary boxing to compare primitives' problems in file" "true"
|
||||
public class Test {
|
||||
public int test(String s1, String s2) {
|
||||
int res = Integer.compare(s1.length(), s2.length());
|
||||
if(res == 0) {
|
||||
/*reverse order!*/
|
||||
res = Character.compare(s2.charAt(0), s1.charAt(0));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Fix all 'Unnecessary boxing to compare primitives' problems in file" "true"
|
||||
public class Test {
|
||||
public void test(int a, int b) {
|
||||
if(((Integer)a).compa<caret>reTo(b) > 0) {
|
||||
System.out.println(1);
|
||||
}
|
||||
if(Long.valueOf(a).compareTo(Long.valueOf(b)) > 0) {
|
||||
System.out.println(1);
|
||||
}
|
||||
if(new Double(a).compareTo(new Double(b)) > 0) {
|
||||
System.out.println(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Fix all 'Unnecessary boxing to compare primitives' problems in file" "true"
|
||||
public class Test {
|
||||
public int test(String s1, String s2) {
|
||||
int res = new Integer(s1.length()).co<caret>mpareTo(s2.length());
|
||||
if(res == 0) {
|
||||
res = new Character(/*reverse order!*/s2.charAt(0)).compareTo(s1.charAt(0));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user