com.jnape.palatable.lambda.optics.lenses

## Class CollectionLens

- java.lang.Object
- - com.jnape.palatable.lambda.optics.lenses.CollectionLens

-     public final class CollectionLens
      extends Object

  Lenses that operate on `Collection`s.

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <X,CX extends Collection<X>> Lens.Simple<CX,CX>` | `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>> Lens.Simple<CX,Set<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>> Lens.Simple<CX,Stream<X>>` | `asStream(Fn1<? super CX,? extends CX> copyFn)` Convenience static factory method for creating a lens that focuses on a Collection as a Stream.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### asCopy

          public static <X,CX extends Collection<X>> Lens.Simple<CX,CX> 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. Useful for composition to avoid mutating a `Collection` reference.
      Type Parameters:
        `X` - the collection element type
        `CX` - the type of the collection
      Parameters:
        `copyFn` - the copying function
      Returns:
        a lens that focuses on a copy of CX

    - #### asSet

          public static <X,CX extends Collection<X>> Lens.Simple<CX,Set<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`.
      Type Parameters:
        `X` - the collection element type
        `CX` - the type of the collection
      Parameters:
        `copyFn` - the copying function
      Returns:
        a lens that focuses on a Collection as a Set

    - #### asStream

          public static <X,CX extends Collection<X>> Lens.Simple<CX,Stream<X>> asStream(Fn1<? super CX,? extends CX> copyFn)

      Convenience static factory method for creating a lens that focuses on a Collection as a Stream.

      Note that this lens is effectively lawful, though difficult to prove given the intrinsically stateful and inequitable nature of `Stream`.

      Type Parameters:
        `X` - the collection element type
        `CX` - the type of the collection
      Parameters:
        `copyFn` - the copying function
      Returns:
        a lens that focuses on a Collection as a stream.