extract enum: change types accordingly (switch cases)

This commit is contained in:
anna
2010-06-08 22:16:06 +04:00
parent dba6215b4b
commit bcdcfd764c
36 changed files with 865 additions and 52 deletions

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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;
}
}
}

View File

@@ -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;
}
}
}

View File

@@ -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;
}
}
}

View File

@@ -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;
}
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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;
}
}

View File

@@ -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());
}
}

View File

@@ -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);
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -0,0 +1,5 @@
class Test {
void foo() {
System.out.println(EEnum.FOO.getValue());
}
}

View File

@@ -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);
}
}

View File

@@ -0,0 +1,7 @@
class Test {
public static final int FOO = 0;
public static final int BAR = 2;
void foo() {
System.out.println(FOO);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}