@Test public void memo(){ Tuple3<String,Integer,Integer> lazy = Tuple.lazy(()->{ called++; return "lazy"; },()->10,()->5); lazy._1(); lazy._1(); assertThat(called,equalTo(2)); called= 0; Tuple3<String,Integer,Integer> memo = lazy.memo(); memo._1(); memo._1(); assertThat(called,equalTo(1)); }
public Tuple3<T1,T2,T3> memo(){ Tuple3<T1,T2,T3> host = this; return new Tuple3<T1,T2,T3>(null,null, null){ final Supplier<T1> memo1 = Memoize.memoizeSupplier(host::_1); final Supplier<T2> memo2 = Memoize.memoizeSupplier(host::_2); final Supplier<T3> memo3 = Memoize.memoizeSupplier(host::_3); @Override public T1 _1() { return memo1.get(); } @Override public T2 _2() { return memo2.get(); } @Override public T3 _3() { return memo3.get(); } }; }
Tuple3 implements To<Tuple3<T1,T2,T3>>,
                                        Serializable,
                                        Higher3<tuple3,T1,T2,T3> ,
                                        EqualTo<Higher<Higher<tuple3,T1>,T2>,T3,Tuple3<T1,T2,T3>>,
                                        OrderedBy<Higher<Higher<tuple3,T1>,T2>,T3,Tuple3<T1,T2,T3>>,
                                        Comparable<Tuple3<T1,T2,T3>> { public Tuple3<T1,T2,T3> memo(){ Tuple3<T1,T2,T3> host = this; return new Tuple3<T1,T2,T3>(null,null, null){ final Supplier<T1> memo1 = Memoize.memoizeSupplier(host::_1); final Supplier<T2> memo2 = Memoize.memoizeSupplier(host::_2); final Supplier<T3> memo3 = Memoize.memoizeSupplier(host::_3); @Override public T1 _1() { return memo1.get(); } @Override public T2 _2() { return memo2.get(); } @Override public T3 _3() { return memo3.get(); } }; } }
Tuple3 implements To<Tuple3<T1,T2,T3>>,
                                        Serializable,
                                        Higher3<tuple3,T1,T2,T3> ,
                                        EqualTo<Higher<Higher<tuple3,T1>,T2>,T3,Tuple3<T1,T2,T3>>,
                                        OrderedBy<Higher<Higher<tuple3,T1>,T2>,T3,Tuple3<T1,T2,T3>>,
                                        Comparable<Tuple3<T1,T2,T3>> { public Tuple3<T1,T2,T3> memo(){ Tuple3<T1,T2,T3> host = this; return new Tuple3<T1,T2,T3>(null,null, null){ final Supplier<T1> memo1 = Memoize.memoizeSupplier(host::_1); final Supplier<T2> memo2 = Memoize.memoizeSupplier(host::_2); final Supplier<T3> memo3 = Memoize.memoizeSupplier(host::_3); @Override public T1 _1() { return memo1.get(); } @Override public T2 _2() { return memo2.get(); } @Override public T3 _3() { return memo3.get(); } }; }  }
Tuple3 implements To<Tuple3<T1,T2,T3>>,
                                        Serializable,
                                        Higher3<tuple3,T1,T2,T3> ,
                                        EqualTo<Higher<Higher<tuple3,T1>,T2>,T3,Tuple3<T1,T2,T3>>,
                                        OrderedBy<Higher<Higher<tuple3,T1>,T2>,T3,Tuple3<T1,T2,T3>>,
                                        Comparable<Tuple3<T1,T2,T3>> { public Tuple3<T1,T2,T3> memo(){ Tuple3<T1,T2,T3> host = this; return new Tuple3<T1,T2,T3>(null,null, null){ final Supplier<T1> memo1 = Memoize.memoizeSupplier(host::_1); final Supplier<T2> memo2 = Memoize.memoizeSupplier(host::_2); final Supplier<T3> memo3 = Memoize.memoizeSupplier(host::_3); @Override public T1 _1() { return memo1.get(); } @Override public T2 _2() { return memo2.get(); } @Override public T3 _3() { return memo3.get(); } }; }  static Tuple3<T1,T2,T3> of(T1 value1, T2 value2, T3 value3); static Tuple3<T1,T2,T3> lazy(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2,Supplier<? extends T3> supplier3); T1 _1(); T2 _2(); T3 _3(); Tuple1<T1> first(); Tuple1<T2> second(); Tuple1<T3> third(); Tuple3<T1,T2,T3> eager(); Tuple3<T1,T2,T3> memo(); R1 transform(Function3<? super T1, ? super T2, ? super T3, ? extends R1> fn); Tuple3<T1,T2,R> flatMap(Monoid<T1> m1, Monoid<T2> m2,Function<? super T3, ? extends Tuple3<T1,T2,R>> fn); Tuple3<R1,R2,R3> mapAll(Function<? super T1, ? extends R1> fn1, Function<? super T2,? extends R2> fn2,
                                                Function<? super T3,? extends R3> fn3); Tuple3<R1,R2,R3> lazyMapAll(Function<? super T1, ? extends R1> fn1, Function<? super T2,? extends R2> fn2,
                                                  Function<? super T3,? extends R3> fn3); Tuple3<R, T2,T3> map1(Function<? super T1, ? extends R> fn); Tuple3<R, T2,T3> lazyMap1(Function<? super T1, ? extends R> fn); Tuple3<T1, R, T3> map2(Function<? super T2, ? extends R> fn); Tuple3<T1, R, T3> lazyMap2(Function<? super T2, ? extends R> fn); Tuple3<T1, T2, R> map3(Function<? super T3, ? extends R> fn); Tuple3<T1, T2, R> lazyMap3(Function<? super T3, ? extends R> fn); R fold(Function3<? super T1, ? super T2, ? super T3, ? extends R> fn); @Override String toString(); static Tuple3<T1,T2,T3> narrowK3(Higher3<tuple3,T1,T2,T3> ds); static Tuple3<T1,T2,T3> narrowK(Higher<Higher<Higher<tuple3,T1>,T2>,T3> ds); @Override boolean equals(Object o); @Override int hashCode(); @Override int compareTo(Tuple3<T1, T2, T3> o); final Object[] toArray(); Tuple4<T1, T2, T3, T4> concat(Tuple1<T4> tuple); Tuple5<T1, T2, T3, T4, T5> concat(Tuple2<T4,T5> tuple); Tuple6<T1, T2, T3, T4, T5, T6> concat(Tuple3<T4, T5, T6> tuple); Tuple7<T1, T2, T3, T4, T5, T6, T7> concat(Tuple4<T4, T5, T6, T7> tuple); Tuple8<T1, T2, T3, T4, T5, T6, T7, T8> concat(Tuple5<T4, T5, T6, T7, T8> tuple); Tuple4<T1, T2, T3, T4> lazyConcat(Tuple1<T4> tuple); Tuple5<T1, T2, T3, T4, T5> lazyConcat(Tuple2<T4,T5> tuple); Tuple6<T1, T2, T3, T4, T5, T6> lazyConcat(Tuple3<T4, T5, T6> tuple); Tuple7<T1, T2, T3, T4, T5, T6, T7> lazyConcat(Tuple4<T4, T5, T6, T7> tuple); Tuple8<T1, T2, T3, T4, T5, T6, T7, T8> lazyConcat(Tuple5<T4, T5, T6, T7, T8> tuple); }
Tuple3 implements To<Tuple3<T1,T2,T3>>,
                                        Serializable,
                                        Higher3<tuple3,T1,T2,T3> ,
                                        EqualTo<Higher<Higher<tuple3,T1>,T2>,T3,Tuple3<T1,T2,T3>>,
                                        OrderedBy<Higher<Higher<tuple3,T1>,T2>,T3,Tuple3<T1,T2,T3>>,
                                        Comparable<Tuple3<T1,T2,T3>> { public Tuple3<T1,T2,T3> memo(){ Tuple3<T1,T2,T3> host = this; return new Tuple3<T1,T2,T3>(null,null, null){ final Supplier<T1> memo1 = Memoize.memoizeSupplier(host::_1); final Supplier<T2> memo2 = Memoize.memoizeSupplier(host::_2); final Supplier<T3> memo3 = Memoize.memoizeSupplier(host::_3); @Override public T1 _1() { return memo1.get(); } @Override public T2 _2() { return memo2.get(); } @Override public T3 _3() { return memo3.get(); } }; }  static Tuple3<T1,T2,T3> of(T1 value1, T2 value2, T3 value3); static Tuple3<T1,T2,T3> lazy(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2,Supplier<? extends T3> supplier3); T1 _1(); T2 _2(); T3 _3(); Tuple1<T1> first(); Tuple1<T2> second(); Tuple1<T3> third(); Tuple3<T1,T2,T3> eager(); Tuple3<T1,T2,T3> memo(); R1 transform(Function3<? super T1, ? super T2, ? super T3, ? extends R1> fn); Tuple3<T1,T2,R> flatMap(Monoid<T1> m1, Monoid<T2> m2,Function<? super T3, ? extends Tuple3<T1,T2,R>> fn); Tuple3<R1,R2,R3> mapAll(Function<? super T1, ? extends R1> fn1, Function<? super T2,? extends R2> fn2,
                                                Function<? super T3,? extends R3> fn3); Tuple3<R1,R2,R3> lazyMapAll(Function<? super T1, ? extends R1> fn1, Function<? super T2,? extends R2> fn2,
                                                  Function<? super T3,? extends R3> fn3); Tuple3<R, T2,T3> map1(Function<? super T1, ? extends R> fn); Tuple3<R, T2,T3> lazyMap1(Function<? super T1, ? extends R> fn); Tuple3<T1, R, T3> map2(Function<? super T2, ? extends R> fn); Tuple3<T1, R, T3> lazyMap2(Function<? super T2, ? extends R> fn); Tuple3<T1, T2, R> map3(Function<? super T3, ? extends R> fn); Tuple3<T1, T2, R> lazyMap3(Function<? super T3, ? extends R> fn); R fold(Function3<? super T1, ? super T2, ? super T3, ? extends R> fn); @Override String toString(); static Tuple3<T1,T2,T3> narrowK3(Higher3<tuple3,T1,T2,T3> ds); static Tuple3<T1,T2,T3> narrowK(Higher<Higher<Higher<tuple3,T1>,T2>,T3> ds); @Override boolean equals(Object o); @Override int hashCode(); @Override int compareTo(Tuple3<T1, T2, T3> o); final Object[] toArray(); Tuple4<T1, T2, T3, T4> concat(Tuple1<T4> tuple); Tuple5<T1, T2, T3, T4, T5> concat(Tuple2<T4,T5> tuple); Tuple6<T1, T2, T3, T4, T5, T6> concat(Tuple3<T4, T5, T6> tuple); Tuple7<T1, T2, T3, T4, T5, T6, T7> concat(Tuple4<T4, T5, T6, T7> tuple); Tuple8<T1, T2, T3, T4, T5, T6, T7, T8> concat(Tuple5<T4, T5, T6, T7, T8> tuple); Tuple4<T1, T2, T3, T4> lazyConcat(Tuple1<T4> tuple); Tuple5<T1, T2, T3, T4, T5> lazyConcat(Tuple2<T4,T5> tuple); Tuple6<T1, T2, T3, T4, T5, T6> lazyConcat(Tuple3<T4, T5, T6> tuple); Tuple7<T1, T2, T3, T4, T5, T6, T7> lazyConcat(Tuple4<T4, T5, T6, T7> tuple); Tuple8<T1, T2, T3, T4, T5, T6, T7, T8> lazyConcat(Tuple5<T4, T5, T6, T7, T8> tuple);  }