public class When extends Object
| Constructor and Description |
|---|
When() |
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
multiWhen(Object... results)
Execute multiple
when(java.lang.Boolean, it.techgap.common.utils.WhenLambda, java.lang.Object...) and returns the first value that isn't null. |
static <T> T |
when(Boolean expression,
WhenLambda lambda)
Evaluate a new condition that doesn't need any parameter
|
static <T> T |
when(Boolean expression,
WhenLambda lambda,
Object... lambdaParams)
Evaluate a new condition
|
public static <T> T when(Boolean expression, WhenLambda lambda, Object... lambdaParams)
T - Return type of the methodexpression - boolean condition that triggers the lambda executionlambda - code to run when the condition is truelambdaParams - parameters that can be passed to the WhenLambdaWhenLambda.execute(java.lang.Object...), or null if the expression is falseypublic static <T> T when(Boolean expression, WhenLambda lambda)
T - Return type of the methodexpression - boolean condition that triggers the lambda executionlambda - code to run when the condition is trueWhenLambda.execute(java.lang.Object...), or null if the expression is falseypublic static <T> T multiWhen(Object... results)
when(java.lang.Boolean, it.techgap.common.utils.WhenLambda, java.lang.Object...) and returns the first value that isn't null.
Should be used with multiple mutually exclusive whens to execute the correct one based on a precise condition.
Ideally, only one of the whens should return a non-null value at a time.T - return typeresults - outputs of multiple when(java.lang.Boolean, it.techgap.common.utils.WhenLambda, java.lang.Object...)Copyright © 2016–2018 TechGap Italia. All rights reserved.