Skip to content

Type Interfaces : To

johnmcclean-aol edited this page Nov 22, 2016 · 1 revision

The To interface

A To represents a type that is convertable in a fluent manner to another type. To's allow both type conversion and custom operators

To contains a single method

  • to : execute the user supplied function, which recieves the current instance and returns a user defined value

Examples

ListX<Integer> list = ListX.of(1,2,3)
                           .to(l->l.stream())
                           .map(i->i*2)
                           .to(r->r.toSetX())
                           .to(s->s.toMaybe())
                           .get();
        
assertThat(list,equalTo(ListX.of(2,4,6)));

   api.doThis(a->a*2)
      .doThat(a->a+2)
      .to(Stream::toStream)
      .peek(System.out::println);

ReactiveSeq.of(1,2,3)
           .to(customZip(Stream.of('a','b','c'))
           .forEach(System.out::println)

Implementations

CollectionXImpl, CompletableFutureTSeq, CompletableFutureTValue, DequeXImpl, Eval.Module.Always, Eval.Module.Later, CompletableFutureTSeq, CompletableFutureTValue, DequeXImpl, Eval.Module.Always, Eval.Module.Later, EvalTSeq, EvalTValue, FeatureToggle.Disabled, FeatureToggle.Enabled, FutureW, FutureWTSeq, FutureWTValue, Ior.Both, Ior.Primary, Ior.Secondary, LazyImmutable, ListTSeq, ListTValue, ListXImpl, MapXImpl, Maybe.Just, Maybe.Lazy, Maybe.Nothing, MaybeTSeq, MaybeTValue, Mutable, MutableBoolean, MutableByte, MutableChar, MutableDouble, MutableFloat, MutableInt, MutableLong, MutableShort, OptionalTSeq, OptionalTValue, PBagXImpl, PMapXImpl, POrderedSetXImpl, PQueueXImpl, PSetXImpl, PStackXImpl, PVectorXImpl, QueueXImpl, SetTSeq, SetTValue, SetXImpl, SortedSetXImpl, StreamableTSeq, StreamableTValue, StreamTSeq, StreamTValue, Try.Failure, Try.Success, TryTSeq, TryTValue, Xor.Primary, Xor.Secondary, XorTSeq, XorTValue

Clone this wiki locally