introduce code block parameter: extract method call with conditional exit

This commit is contained in:
Anna Kozlova
2014-12-11 11:16:44 +01:00
parent c6fbcb86a3
commit 1053a96872
8 changed files with 103 additions and 29 deletions
@@ -1,7 +1,7 @@
import java.util.function.Consumer;
class Test {
void bar() {
void bar() {
foo(1, new Consumer<Integer>() {
public void accept(Integer i) {
System.out.println(i);
@@ -1,7 +1,7 @@
import java.util.function.Consumer;
class Test {
void bar() {
void bar() {
foo(1, new Consumer<Integer>() {
public void accept(Integer i) {
System.out.println(i);
@@ -0,0 +1,23 @@
import java.util.function.IntPredicate;
class Test {
void bar() {
foo(1, new IntPredicate() {
public boolean test(int i) {
if (i > 0) {
System.out.println(i);
System.out.println(i);
return true;
}
return false;
}
});
}
void foo(int i, IntPredicate anObject) {
if (anObject.test(i)) return;
System.out.println("Hi");
}
}
@@ -1,5 +1,5 @@
class Test {
void bar() {
void bar() {
foo(new Runnable() {
public void run() {
System.out.println("");
@@ -0,0 +1,16 @@
class Test {
void bar() {
foo(1);
}
void foo(int i) {
<selection>
if (i > 0) {
System.out.println(i);
System.out.println(i);
return;
}
</selection>
System.out.println("Hi");
}
}