1 package com.puppycrawl.tools.checkstyle.checks.coding.returncount; 2 3 import java.lang.Integer; 4 import java.util.Optional; 5 import java.util.concurrent.Callable; 6 import java.util.function.Supplier; 7 8 9 public class InputReturnCountLambda { 10 11 Runnable fieldWithOneReturnInLambda = () -> { 12 return; 13 }; 14 15 Callable<Integer> fieldWithTwoReturnInLambda = () -> { 16 if (hashCode() == 0) return 0; 17 else return 1; 18 }; 19 20 Optional<Integer> methodWithOneReturnInLambda() { 21 return Optional.of(hashCode()).filter(i -> { 22 return i > 0; 23 }); 24 } 25 26 Optional<Integer> methodWithTwoReturnInLambda() { 27 return Optional.of(hashCode()).filter(i -> { 28 if (i > 0) return true; 29 else return false; 30 }); 31 } 32 33 Optional<Object> methodWithThreeReturnInLambda(int number) { 34 return Optional.of(number).map(i -> { 35 if (i == 42) return true; 36 else if (i == 7) return true; 37 else return false; 38 }); 39 } 40 41 int methodWithTwoReturnWithLambdas(final int number) { 42 if (hashCode() > 0) { 43 new Thread( 44 () -> { 45 } 46 ).start(); 47 return number; 48 } else { 49 return Optional.of(hashCode()).orElseGet(() -> { 50 if (number > 0) return number; 51 else return 0; 52 }); 53 } 54 } 55 56 Supplier<Supplier<Integer>> methodWithOneReturnPerLambda() { 57 return () -> { 58 return () -> { 59 return 1; 60 }; 61 }; 62 } 63 }