/** * @param toCoerce Efficiently / lazily Makes Stream repeatable, not thread safe, on initial iteration * @return */ public static <T> Streamable<T> asStreamable(Stream<T> toCoerce){ return new CoercedStreamable(collectStream(toCoerce)); } public static <T> Streamable<T> asStreamable(Iterable<T> toCoerce){
/** * @param toCoerce Efficiently / lazily Makes Stream repeatable, guards iteration with locks on initial iteration * @return */ public static <T> Streamable<T> asConcurrentStreamable(Stream<T> toCoerce){ return new CoercedStreamable(collectStreamConcurrent(toCoerce)); } public static <T> Streamable<T> asConcurrentStreamable(Iterable<T> toCoerce){
/** * Convert supplied object to a Mappable instance. * Mappable will convert the (non-static) fields of the supplied object into a map * * * @param toCoerce Object to convert to a Mappable * @return Mappable instance */ public static Mappable asMappable(Object toCoerce){ return new CoercedMappable(toCoerce); } @Value
/** * Answers the question how should this type behave when returned in a flatMap function * by another type? For example - Optional uses comp.of(opt.get()) when a value is present * and comp.empty() when no value is present. * * @param comp * @param apply * @return */ default Object resolveForCrossTypeFlatMap(Comprehender comp,T apply){ return comp.of(apply); }
/** * Construct an AnyM backed by a Stream of Characters from the text of a String * * */ public static AnyM<Character> anyMFromCharSequence(CharSequence anyM){ return AsAnyM.convertToAnyM(anyM); }
/** * (Lazily) Construct a Streamable from a Stream. * * @param stream to construct Streamable from * @return Streamable */ public static <T> Streamable<T> fromStream(Stream<T> stream){ return AsStreamable.asStreamable(stream); } /**
/** * Attempt to map this Monad to the same type as the supplied Monoid (using mapToType on the monoid interface) * Then use Monoid to reduce values * * @param reducer Monoid to reduce values * @return Reduce result */ public final static <T> T foldLeftMapToType(Stream<T> stream,Monoid<T> reducer){ return reducer.mapReduce(stream); } /**
/** * * * @param reducer Use supplied Monoid to reduce values * @return reduced values */ public final T reduce(Monoid<T> reducer){ return reducer.reduce(monad); } /*
/** * Create a Duck typing based Supplier * * * * @param toCoerce Object to convert into a Supplier, * must have a non-void get() method * @return Supplier that delegates to the supplied object */ public static <T> Supplier<T> asSupplier(Object toCoerce){ return AsSupplier.asSupplier(toCoerce); }
/** * @return Streamable that replay this SequenceM */ public Streamable<T> toConcurrentLazyStreamable(){ return AsStreamable.asConcurrentStreamable(monad); } public SequenceM<T> reverse(){
public static <T> Streamable<T> asStreamable(Iterable<T> toCoerce){ return new CoercedStreamable(collectStream(toCoerce)); } /**
public static <T> Streamable<T> asConcurrentStreamable(Iterable<T> toCoerce){ return new CoercedStreamable(collectStreamConcurrent(toCoerce)); }
/** * Construct an AnyM backed by a Stream of text from the lines of the supplied file * * */ public static AnyM<String> anyMFromFile(File anyM){ return AsAnyM.convertToAnyM(anyM); } /**
/** * @return Streamable that can replay this SequenceM */ public Streamable<T> toLazyStreamable(){ return AsStreamable.asStreamable(monad); } /**
/** * Attempt to map this Monad to the same type as the supplied Monoid (using mapToType on the monoid interface) * Then use Monoid to reduce values * * @param reducer Monoid to reduce values * @return Reduce result */ public final static<T,R> R mapReduce(Stream<T> stream,Monoid<R> reducer){ return reducer.mapReduce(stream); } /**
/** * * * @param reducer Use supplied Monoid to reduce values starting via foldLeft * @return Reduced result */ public final static <T> T foldLeft(Stream<T> stream,Monoid<T> reducer){ return reducer.reduce(stream); } /**
public static <T> Streamable<T> asStreamable(Object toCoerce){ return new CoercedStreamable(collectStream(toCoerce)); } /**
/** * Construct an AnyM backed by a Stream of text from the lines of the BufferedReader * * */ public static AnyM<String> anyMFromBufferedReader(BufferedReader anyM){ return AsAnyM.convertToAnyM(anyM); } /**
/** * @return Underlying monad converted to a Streamable instance */ public final static <T> Streamable<T> toStreamable(Stream<T> stream){ return AsStreamable.asStreamable(stream); } /**
/** * Attempt to map this Monad to the same type as the supplied Monoid (using mapToType on the monoid interface) * Then use Monoid to reduce values * * @param reducer Monoid to reduce values * @return Reduce result */ public final <R> R mapReduce(Monoid<R> reducer){ return reducer.mapReduce(monad); } /**