Modifier and Type | Method and Description |
---|---|
static <X> Lens.Simple<List<X>,List<X>> |
asCopy()
Convenience static factory method for creating a lens over a copy of a list.
|
static <X> Lens.Simple<List<X>,Maybe<X>> |
elementAt(int index)
Convenience static factory method for creating a lens that focuses on an element in a list at a particular index.
|
static <X> Lens.Simple<List<X>,X> |
elementAt(int index,
X defaultValue)
Convenience static factory method for creating a lens that focuses on an element in a list at a particular index,
returning
defaultValue if there is no value at that index. |
public static <X> Lens.Simple<List<X>,List<X>> asCopy()
X
- the list element typepublic static <X> Lens.Simple<List<X>,Maybe<X>> elementAt(int index)
Maybe
to handle null values or indexes that fall outside of list boundaries.X
- the list element typeindex
- the index to focus onpublic static <X> Lens.Simple<List<X>,X> elementAt(int index, X defaultValue)
defaultValue
if there is no value at that index.
Note that this lens is NOT lawful, since "putting back what you got changes nothing" fails for any value
B
where S
is the empty list
X
- the list element typeindex
- the index to focus ondefaultValue
- the value to use if there is no element at index