public final class CollectionLens extends Object
Collections.| Modifier and Type | Method and Description |
|---|---|
static <X,CX extends Collection<X>> |
asCopy(Fn1<? super CX,? extends CX> copyFn)
Convenience static factory method for creating a lens that focuses on a copy of a
Collection, given
a function that creates the copy. |
static <X,CX extends Collection<X>> |
asSet(Fn1<? super CX,? extends CX> copyFn)
Convenience static factory method for creating a lens that focuses on an arbitrary
Collection as a
Set. |
static <X,CX extends Collection<X>> |
asStream(Fn1<? super CX,? extends CX> copyFn)
Convenience static factory method for creating a lens that focuses on a Collection as a Stream.
|
public static <X,CX extends Collection<X>> Lens.Simple<CX,CX> asCopy(Fn1<? super CX,? extends CX> copyFn)
Collection, given
a function that creates the copy. Useful for composition to avoid mutating a Collection reference.X - the collection element typeCX - the type of the collectioncopyFn - the copying functionpublic static <X,CX extends Collection<X>> Lens.Simple<CX,Set<X>> asSet(Fn1<? super CX,? extends CX> copyFn)
Collection as a
Set.X - the collection element typeCX - the type of the collectioncopyFn - the copying functionpublic static <X,CX extends Collection<X>> Lens.Simple<CX,Stream<X>> asStream(Fn1<? super CX,? extends CX> copyFn)
Note that this lens is effectively lawful, though difficult to prove given the intrinsically
stateful and inequitable nature of Stream.
X - the collection element typeCX - the type of the collectioncopyFn - the copying function