| 1 |
import java.util.Collection; |
| 2 |
import java.util.Optional; |
| 3 |
import java.util.stream.Stream; |
| 4 |
|
| 5 |
@SuppressWarnings("") |
| 6 |
public class Issue2370 { |
| 7 |
private Stream<Action2370> getAction2370s(final State2370 state) { |
| 8 |
return Stream.of( |
| 9 |
toStream(state.getOnExit()).flatMap(t -> t.getAction2370s().stream()), |
| 10 |
toStream(state.getOnSignal()).flatMap(t -> t.getAction2370s().stream()), |
| 11 |
toStream(state.getOnEnter()).flatMap(t -> t.getAction2370s().stream())) |
| 12 |
.flatMap(actionStream -> actionStream); |
| 13 |
} |
| 14 |
|
| 15 |
private <T> Stream<T> toStream(final Collection<T> obj) { |
| 16 |
return Optional.ofNullable(obj) |
| 17 |
.map(Stream::of) |
| 18 |
.orElseGet(Stream::empty) |
| 19 |
.flatMap(Collection::stream); |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
interface Action2370 { |
| 24 |
public Collection<Action2370> getAction2370s(); |
| 25 |
} |
| 26 |
|
| 27 |
interface State2370 { |
| 28 |
public Collection<Action2370> getOnExit(); |
| 29 |
|
| 30 |
public Collection<Action2370> getOnSignal(); |
| 31 |
|
| 32 |
public Collection<Action2370> getOnEnter(); |
| 33 |
} |