@Override public Stream convertToMonadicForm(Object f) { return StreamSupport.stream(((Iterable)((Decomposable)f).unapply()).spliterator(),false); }
/** * @return Values of the fields of this Decomposable instance */ @SuppressWarnings("unchecked") default <I extends Iterable<?>> I unapply(){ if(unwrap() instanceof Iterable) return (I)unwrap(); try { return (I)ReflectionCache.getFields(unwrap().getClass()).stream().map(f ->{ try { return f.get(unwrap()); } catch (Exception e) { ExceptionSoftener.singleton.factory.getInstance().throwSoftenedException(e); return null; } }).collect(Collectors.toList()); } catch (Exception e) { ExceptionSoftener.singleton.factory.getInstance() .throwSoftenedException(e); return (I)null; } }
@Override public Stream convertToMonadicForm(Object f) { return StreamSupport.stream(((Iterable)AsDecomposable.asDecomposable(f).unapply()).spliterator(),false); }
/** * @return New Stream */ default Stream<T> stream(){ Object streamable = getStreamable(); if(streamable instanceof Stream) return (Stream)streamable; if(streamable instanceof Iterable) return StreamSupport.stream(((Iterable)streamable).spliterator(), false); return new InvokeDynamic().stream(streamable).orElseGet( ()-> (Stream)StreamSupport.stream(asDecomposable(streamable) .unapply() .spliterator(), false)); }