public final static <T>Optional<ListX<T>> streamToOptional(final Stream<T> stream){
  final List<T> collected=stream.collect(Collectors.toList());
  if (collected.size() == 0)   return Optional.empty();
  return Optional.of(ListX.fromIterable(collected));
}

public final static < T > Optional < ListX < T > > streamToOptional ( final Stream < T > stream ) { final List < T > collected = stream . collect ( Collectors . toList ( ) ) ; if ( collected . size ( ) == 0 ) return Optional . empty ( ) ; return Optional . of ( ListX . fromIterable ( collected ) ) ; }
create an optional containing a list materialized from a stream
