IDEA-164880 Refactoring to function composition methods

This commit is contained in:
Tagir Valeev
2016-12-06 11:48:52 +07:00
parent d76aee1576
commit d7cb4edc8d
17 changed files with 297 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
// "Replace nested function call with andThen call" "true"
import java.util.Collections;
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.UnaryOperator;
public class Main {
private void testFn() {
Function<String, Integer> lookup = Integer::parseInt;
UnaryOperator<String> selector = String::trim;
BinaryOperator<Integer> min = Math::min;
String foo = "xyz";
int res = min.andThen(Math::abs).apply(-1, -2);
}
}

View File

@@ -0,0 +1,19 @@
// "Replace nested function call with andThen call" "true"
import java.util.Collections;
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.UnaryOperator;
public class Main {
private void testFn() {
Function<String, Integer> lookup = Integer::parseInt;
UnaryOperator<String> selector = String::trim;
BinaryOperator<Integer> min = Math::min;
String foo = "xyz";
/*check*/
boolean b = selector.andThen(Collections.singleton(/* "xyz" here */ "xyz")::contains).apply(/* foo here */ foo);
}
}

View File

@@ -0,0 +1,11 @@
// "Replace nested function call with andThen call" "true"
import java.util.function.UnaryOperator;
public class Main {
private void testFn(boolean b) {
String foo = "xyz";
Integer f = (b ? (UnaryOperator<String>) String::trim : (UnaryOperator<String>) s -> s.substring(1)).andThen(Integer::parseInt).apply(foo);
}
}

View File

@@ -0,0 +1,16 @@
// "Replace nested function call with andThen call" "true"
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.UnaryOperator;
public class Main {
private void testFn() {
Function<String, Integer> lookup = Integer::parseInt;
UnaryOperator<String> selector = String::trim;
BinaryOperator<Integer> min = Math::min;
String foo = "xyz";
Integer integer = selector.andThen(lookup).apply(" " + foo);
}
}

View File

@@ -0,0 +1,17 @@
// "Replace nested function call with andThen call" "true"
import java.util.Collections;
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.UnaryOperator;
public class Main {
private void testFn() {
Function<String, Integer> lookup = Integer::parseInt;
UnaryOperator<String> selector = String::trim;
BinaryOperator<Integer> min = Math::min;
String foo = "xyz";
int res = Math.abs(min.a<caret>pply(-1,-2));
}
}

View File

@@ -0,0 +1,17 @@
// "Replace nested function call with andThen call" "true"
import java.util.Collections;
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.UnaryOperator;
public class Main {
private void testFn() {
Function<String, Integer> lookup = Integer::parseInt;
UnaryOperator<String> selector = String::trim;
BinaryOperator<Integer> min = Math::min;
String foo = "xyz";
boolean b = Collections.singleton(/* "xyz" here */ "xyz").contains(/*check*/sel<caret>ector.apply(/* foo here */ foo));
}
}

View File

@@ -0,0 +1,12 @@
// "Replace nested function call with andThen call" "true"
import java.util.function.UnaryOperator;
public class Main {
private void testFn(boolean b) {
String foo = "xyz";
Integer f = Integer.parseInt(
(b ? (UnaryOperator<String>) String::trim : (UnaryOperator<String>) s -> s.substring(1)).apply(fo<caret>o));
}
}

View File

@@ -0,0 +1,16 @@
// "Replace nested function call with andThen call" "true"
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.UnaryOperator;
public class Main {
private void testFn() {
Function<String, Integer> lookup = Integer::parseInt;
UnaryOperator<String> selector = String::trim;
BinaryOperator<Integer> min = Math::min;
String foo = "xyz";
Integer integer = lookup.apply(sele<caret>ctor.apply(" " + foo));
}
}