mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 22:51:17 +07:00
extract enum: change types accordingly (switch cases)
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
public class Test {
|
||||
public static final int FOO = 0;
|
||||
public static final int BAR = 1;
|
||||
|
||||
void foo(int i) {
|
||||
switch (i) {
|
||||
case FOO:
|
||||
break;
|
||||
case BAR:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void foobar() {
|
||||
int max = Math.max(FOO, BAR);
|
||||
foo(max);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
public class Test {
|
||||
public static final int FOO = 0;
|
||||
public static final int BAR = 1;
|
||||
|
||||
void foo(int i) {
|
||||
switch (i) {
|
||||
case FOO:
|
||||
break;
|
||||
case BAR:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void foobar() {
|
||||
int max = Math.max(FOO, BAR);
|
||||
foo(max);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
public class Test {
|
||||
public static final int FOO = 0;
|
||||
public static final int BAR = 1;
|
||||
|
||||
void foo(int i) {
|
||||
switch (i) {
|
||||
case FOO:
|
||||
break;
|
||||
case BAR:
|
||||
break;
|
||||
}
|
||||
int k = Math.max(i * i, i + i);
|
||||
switch (k) {
|
||||
case FOO:
|
||||
break;
|
||||
case BAR:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
public class Test {
|
||||
public static final int FOO = 0;
|
||||
public static final int BAR = 1;
|
||||
|
||||
void foo(int i) {
|
||||
switch (i) {
|
||||
case FOO:
|
||||
break;
|
||||
case BAR:
|
||||
break;
|
||||
}
|
||||
int k = Math.max(i * i, i + i);
|
||||
switch (k) {
|
||||
case FOO:
|
||||
break;
|
||||
case BAR:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
public class Test {
|
||||
public static final int FOO = 0;
|
||||
public static final int BAR = 2;
|
||||
|
||||
void foo(String[] args) {
|
||||
switch (args.length) {
|
||||
case FOO:
|
||||
break;
|
||||
case BAR:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
public class Test {
|
||||
public static final int FOO = 0;
|
||||
public static final int BAR = 2;
|
||||
|
||||
void foo(String[] args) {
|
||||
switch (args.length) {
|
||||
case FOO:
|
||||
break;
|
||||
case BAR:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
public class Test {
|
||||
public static final int FOO = 0;
|
||||
public static final int BAR = 2;
|
||||
|
||||
void foo(String[] args) {
|
||||
switch (boo(args)) {
|
||||
case FOO:
|
||||
break;
|
||||
case BAR:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int boo(String[] args) {
|
||||
return args.length;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
public class Test {
|
||||
public static final int FOO = 0;
|
||||
public static final int BAR = 2;
|
||||
|
||||
void foo(String[] args) {
|
||||
switch (boo(args)) {
|
||||
case FOO:
|
||||
break;
|
||||
case BAR:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int boo(String[] args) {
|
||||
return args.length;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
public enum EEnum {
|
||||
FOO(0), BAR(1);
|
||||
private int value;
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
EEnum(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
public class Test {
|
||||
|
||||
void foo(EEnum i) {
|
||||
switch (i) {
|
||||
case FOO:
|
||||
break;
|
||||
case BAR:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void foobar() {
|
||||
foo(EEnum.FOO);
|
||||
foo(EEnum.BAR);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
public class Test {
|
||||
public static final int FOO = 0;
|
||||
public static final int BAR = 1;
|
||||
|
||||
void foo(int i) {
|
||||
switch (i) {
|
||||
case FOO:
|
||||
break;
|
||||
case BAR:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void foobar() {
|
||||
foo(FOO);
|
||||
foo(BAR);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
public enum EEnum {
|
||||
FOO(0), BAR(1);
|
||||
private int value;
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
EEnum(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
public class Test {
|
||||
|
||||
void foo(EEnum i) {
|
||||
switch (i) {
|
||||
case FOO:
|
||||
break;
|
||||
case BAR:
|
||||
break;
|
||||
}
|
||||
int k = Math.max(i.getValue() * i.getValue(), i.getValue() + i.getValue());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
public class Test {
|
||||
public static final int FOO = 0;
|
||||
public static final int BAR = 1;
|
||||
|
||||
void foo(int i) {
|
||||
switch (i) {
|
||||
case FOO:
|
||||
break;
|
||||
case BAR:
|
||||
break;
|
||||
}
|
||||
int k = Math.max(i * i, i + i);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
public enum EEnum {
|
||||
FOO(0), BAR(1);
|
||||
private int value;
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
EEnum(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
public class Test {
|
||||
|
||||
void foo() {
|
||||
EEnum i = foobar(false);
|
||||
switch (i) {
|
||||
case FOO:
|
||||
break;
|
||||
case BAR:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
EEnum foobar(boolean flag) {
|
||||
if (flag) {
|
||||
return EEnum.FOO;
|
||||
}
|
||||
return EEnum.BAR;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
public class Test {
|
||||
public static final int FOO = 0;
|
||||
public static final int BAR = 1;
|
||||
|
||||
void foo() {
|
||||
int i = foobar(false);
|
||||
switch (i) {
|
||||
case FOO:
|
||||
break;
|
||||
case BAR:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int foobar(boolean flag) {
|
||||
if (flag) {
|
||||
return FOO;
|
||||
}
|
||||
return BAR;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
public enum EEnum {
|
||||
FOO(0), BAR(2);
|
||||
private int value;
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
EEnum(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class Test {
|
||||
void foo() {
|
||||
System.out.println(EEnum.FOO.getValue());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
class Usage {
|
||||
void foo(EEnum i) {
|
||||
switch (i) {
|
||||
case FOO:
|
||||
break;
|
||||
case BAR:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void foobar() {
|
||||
foo(EEnum.FOO);
|
||||
foo(EEnum.BAR);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class Test {
|
||||
public static final int FOO = 0;
|
||||
public static final int BAR = 2;
|
||||
void foo() {
|
||||
System.out.println(FOO);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
class Usage {
|
||||
void foo(int i) {
|
||||
switch (i) {
|
||||
case Test.FOO:
|
||||
break;
|
||||
case Test.BAR:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void foobar() {
|
||||
foo(Test.FOO);
|
||||
foo(Test.BAR);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
public class Test {
|
||||
public static final int FOO = 0;
|
||||
public static final int BAR = 1;
|
||||
|
||||
void foo(int i) {
|
||||
switch (i) {
|
||||
case FOO:
|
||||
break;
|
||||
case BAR:
|
||||
break;
|
||||
case 8:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void foobar() {
|
||||
foo(FOO);
|
||||
foo(BAR);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
public class Test {
|
||||
public static final int FOO = 0;
|
||||
public static final int BAR = 1;
|
||||
|
||||
void foo(int i) {
|
||||
switch (i) {
|
||||
case FOO:
|
||||
break;
|
||||
case BAR:
|
||||
break;
|
||||
case 8:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void foobar() {
|
||||
foo(FOO);
|
||||
foo(BAR);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user