/** * Concat an Object and a Stream * If the Object is a Stream, Streamable or Iterable will be converted (or left) in Stream form and concatonated * Otherwise a new Stream.of(o) is created * * @param o Object to concat * @param stream Stream to concat * @return Concatonated Stream */ public static <U> Stream<U> concat(Object o, Stream<U> stream){ return StreamUtils.concat(o, stream); } /**
/** * Aggregate the contents of this Monad and the supplied Monad * * <pre>{@code * * List<Integer> result = monad(Stream.of(1,2,3,4)).<Integer>aggregate(monad(Optional.of(5))).toList(); assertThat(result,equalTo(Arrays.asList(1,2,3,4,5))); }</pre> * * @param next Monad to aggregate content with * @return Aggregated Monad */ default <R> Monad<MONAD,R> aggregate(Monad<?,?> next){ Stream concat = StreamUtils.concat(stream(),next.stream() ); return (Monad)withMonad(new ComprehenderSelector().selectComprehender( unwrap()).of(monad(concat) .flatMap(Function.identity()) .sequence().collect(Collectors.toList()))) .bind(Function.identity() ); } default <MONAD2,NT> Monad<MONAD2,NT> monadMap(Function<? super MONAD,? extends NT> fn) {