1
2 package com.puppycrawl.tools.checkstyle.checks.indentation.indentation;
3
4 import java.util.Arrays;
5 import java.util.List;
6 import java.util.Optional;
7 import java.util.function.BinaryOperator;
8 import java.util.function.Consumer;
9 import java.util.stream.Collectors;
10 import java.util.stream.Stream;
11
12
13 public class InputIndentationLambda3 {
14 public <T> Consumer<Integer> par(Consumer<Integer> f1, Consumer<Integer> f2) {
15 return f2;
16 }
17
18 private void print(int i) {
19 }
20
21 public Consumer<Integer> returnFunctionOfLambda() {
22 return par(
23 (x) -> print(x * 1),
24 (x) -> print(x * 2)
25 );
26 }
27
28 public static <T> BinaryOperator<T> returnLambda() {
29 return (t1, t2) -> {
30 return t1;
31 };
32 }
33
34 class TwoParams {
35 TwoParams(Consumer<Integer> c1, Consumer<Integer> c2) {
36 }
37 }
38
39 public void makeTwoParams() {
40 TwoParams t0 = new TwoParams(
41 intValueA
42 -> print(intValueA * 1),
43 (x) ->
44 print(x * 2)
45 );
46
47 TwoParams t1 = new TwoParams(
48 x
49 -> print(x * 1),
50 (aggregateValue) ->
51 print(aggregateValue * 2));
52 }
53
54
55 List<Integer> test(List<String> input) {
56 return input.stream()
57 .flatMap(each -> Arrays.stream(each.split("")))
58 .flatMap(in -> Arrays.stream(in.split("")))
59
60 .map(Integer::valueOf)
61 .collect(Collectors.toList());
62 }
63
64 String test2(String input) {
65 return Optional.ofNullable(input)
66 .filter(in
67 ->
68 in.contains("e"))
69 .filter(inp -> inp.contains("e"))
70
71 .orElse(null);
72 }
73
74
75 public void test(Stream<Inner<?>> stream) {
76 stream
77 .sorted()
78 .filter(ps -> ps instanceof Inner)
79 .map(ps -> ((Inner<?>) ps).getPropertyNames())
80
81 .forEach(System.out::println);
82 }
83
84 private static class Inner<T> {
85 String[] getPropertyNames() {
86 return new String[] {"a", "b"};
87 }
88 }
89 }