V - Input type.public class When<V> extends Object
{code@
import static org.jooby.funzy.When.when;
Object value = ...;
String result = when(value)
.is(Number.class, "Got a number")
.is(String.class, "Got a string")
.orElse("Unknown");
System.out.println(result);
}
Automatic cast example:
import static org.jooby.funzy.When.when;
Object value = ...;
int result = when(value)
.is(Integer.class, i -> i * 2)
.orElse(-1);
System.out.println(result);
| Modifier and Type | Class and Description |
|---|---|
static class |
When.Value<V,R> |
| Modifier and Type | Method and Description |
|---|---|
<T extends V,R> |
is(Class<T> predicate,
R result) |
<T extends V,R> |
is(Class<T> predicate,
Throwing.Function<T,R> result) |
<T extends V,R> |
is(Throwing.Predicate<T> predicate,
Throwing.Function<T,R> result) |
<T extends V,R> |
is(Throwing.Predicate<T> predicate,
Throwing.Supplier<R> result) |
<R> When.Value<V,R> |
is(V value,
R result) |
<R> When.Value<V,R> |
is(V value,
Throwing.Supplier<R> result) |
static <V> When<V> |
when(V value) |
public When(V source)
public static final <V> When<V> when(V value)
public <R> When.Value<V,R> is(V value, R result)
public <T extends V,R> When.Value<V,R> is(Class<T> predicate, R result)
public <R> When.Value<V,R> is(V value, Throwing.Supplier<R> result)
public <T extends V,R> When.Value<V,R> is(Class<T> predicate, Throwing.Function<T,R> result)
public <T extends V,R> When.Value<V,R> is(Throwing.Predicate<T> predicate, Throwing.Supplier<R> result)
public <T extends V,R> When.Value<V,R> is(Throwing.Predicate<T> predicate, Throwing.Function<T,R> result)
Copyright © 2017. All rights reserved.