class ResultComposer {

    public static <T, R> Result compose(T value, Collection<Result<R>>... results) {
        List<MarshallingMessage> messages = Stream.of(results).flatMap(Collection::stream)
                .map(Result::messages)
                .flatMap(List::stream)
                .collect(Collectors.toList());
        return Result.success(value, messages.stream().toArray(MarshallingMessage[]::new));
    }

}