public interface CachedValues extends java.lang.Iterable, com.aol.cyclops.value.ValueObject, com.aol.cyclops.sequence.streamable.ToStream, com.aol.cyclops.comprehensions.donotation.Doable, com.aol.cyclops.matcher.recursive.Matchable, java.lang.Comparable<CachedValues>
| Modifier and Type | Interface and Description |
|---|---|
static class |
CachedValues.ConvertStep<T extends CachedValues> |
| Modifier and Type | Method and Description |
|---|---|
default <T extends CachedValues,X> |
append(X value) |
default <T extends CachedValues> |
appendAll(CachedValues values) |
int |
arity() |
default <T,A,R> java.util.stream.Collector<T,A,R> |
asCollector()
Wrap multiple collectors in a single Collector instance, so they can all run against a single Stream
e.g
PTuple2<Set<Integer>,List<Integer>> res = Stream.of(1, 2, 2)
.collect(tuple(Collectors.toSet(),Collectors.toList()).asCollector());
Filters all non-Collector instances out of the Tuple |
default <T extends java.util.stream.Stream<?>> |
asFlattenedStream()
Will attempt to convert each element in the tuple into a flattened Stream
|
default <T extends CachedValues> |
asReducer()
Wrap multiple reducers or monoids into a single reducer instance,
that can be used to reduce a given steam to multiple different values simultanously
Monoid<Integer> sum = Monoid.of(0,(a,b)->a+b);
Monoid<Integer> mult = Monoid.of(1,(a,b)->a*b);
val result = tuple(sum,mult).<PTuple2<Integer,Integer>>asReducer()
.mapReduce(Stream.of(1,2,3,4));
assertThat(result,equalTo(tuple(10,24)));
Or alternatively
Monoid<String> concat = Monoid.of("",(a,b)->a+b);
Monoid<String> join = Monoid.of("",(a,b)->a+","+b);
Monoid<CachedValues> reducer = PowerTuples.tuple(concat,join).asReducer();
assertThat(Stream.of("hello", "world", "woo!").map(CachedValues::of)
.reduce(reducer.zero(),reducer.reducer())
,equalTo(tuple("helloworldwoo!",",hello,world,woo!")));
|
default java.util.stream.Stream<java.lang.String> |
asStreamOfStrings() |
default <T extends java.util.stream.Stream<?>> |
asStreams()
Will attempt to convert each element in the tuple into a Stream
Collection::stream
CharSequence to stream
File to Stream
URL to Stream
|
default int |
compareTo(CachedValues o) |
default <T extends CachedValues> |
convert() |
default <T extends CachedValues> |
filter(java.util.function.Predicate<PTuple2<java.lang.Integer,java.lang.Object>> p) |
default <T extends CachedValues,X extends CachedValues> |
flatMap(java.util.function.Function<X,T> fn) |
default void |
forEach(java.util.function.Consumer c) |
java.util.List<java.lang.Object> |
getCachedValues() |
default java.lang.Object |
getMatchable() |
default java.util.Iterator |
iterator() |
default <T extends CachedValues> |
map(java.util.function.Function<java.util.List,java.util.List> fn) |
static CachedValues |
of(java.lang.Object... values) |
static <T> CachedValues |
of(T value) |
default java.util.stream.Stream |
stream() |
default <X> X |
to(java.lang.Class<X> to) |
default <T> java.util.List<T> |
toList() |
default <K,V> java.util.Map<K,V> |
toMap() |
CachedValues |
withArity(int arity) |
listOfValues, matches, matches, matches, matches, matches, mayMatch, mayMatch, mayMatch, mayMatch, mayMatch, ofDecomposable, ofStreamdefault java.lang.Object getMatchable()
getMatchable in interface com.aol.cyclops.matcher.recursive.Matchablejava.util.List<java.lang.Object> getCachedValues()
CachedValues withArity(int arity)
default <T extends CachedValues> CachedValues.ConvertStep<T> convert()
default <X> X to(java.lang.Class<X> to)
default <T extends CachedValues> com.aol.cyclops.sequence.Monoid<T> asReducer()
Monoid<Integer> sum = Monoid.of(0,(a,b)->a+b);
Monoid<Integer> mult = Monoid.of(1,(a,b)->a*b);
val result = tuple(sum,mult).<PTuple2<Integer,Integer>>asReducer()
.mapReduce(Stream.of(1,2,3,4));
assertThat(result,equalTo(tuple(10,24)));
Or alternatively
Monoid<String> concat = Monoid.of("",(a,b)->a+b);
Monoid<String> join = Monoid.of("",(a,b)->a+","+b);
Monoid<CachedValues> reducer = PowerTuples.tuple(concat,join).asReducer();
assertThat(Stream.of("hello", "world", "woo!").map(CachedValues::of)
.reduce(reducer.zero(),reducer.reducer())
,equalTo(tuple("helloworldwoo!",",hello,world,woo!")));
default <T,A,R> java.util.stream.Collector<T,A,R> asCollector()
PTuple2<Set<Integer>,List<Integer>> res = Stream.of(1, 2, 2)
.collect(tuple(Collectors.toSet(),Collectors.toList()).asCollector());
Filters all non-Collector instances out of the Tupledefault int compareTo(CachedValues o)
compareTo in interface java.lang.Comparable<CachedValues>default void forEach(java.util.function.Consumer c)
forEach in interface java.lang.Iterabledefault <T extends CachedValues> T filter(java.util.function.Predicate<PTuple2<java.lang.Integer,java.lang.Object>> p)
default <T> java.util.List<T> toList()
default <K,V> java.util.Map<K,V> toMap()
int arity()
default <T extends java.util.stream.Stream<?>> T asFlattenedStream()
default <T extends java.util.stream.Stream<?>> java.util.stream.Stream<T> asStreams()
default java.util.stream.Stream<java.lang.String> asStreamOfStrings()
default java.util.Iterator iterator()
iterator in interface java.lang.Iterableiterator in interface com.aol.cyclops.sequence.streamable.ToStreamdefault java.util.stream.Stream stream()
stream in interface com.aol.cyclops.sequence.streamable.ToStreamdefault <T extends CachedValues,X> T append(X value)
default <T extends CachedValues> T appendAll(CachedValues values)
default <T extends CachedValues,X extends CachedValues> T flatMap(java.util.function.Function<X,T> fn)
default <T extends CachedValues> T map(java.util.function.Function<java.util.List,java.util.List> fn)
static <T> CachedValues of(T value)
of in interface com.aol.cyclops.matcher.recursive.Matchablestatic CachedValues of(java.lang.Object... values)