Package dev.fritz2.lenses

Types

IdProvider
Link copied to clipboard
common
typealias IdProvider<T, I> = (T) -> I

function to derive a valid id for a given instance that does not change over time.

Lens
Link copied to clipboard
common
interface Lens<P, T>
Describes a focus point into a data structure, i.e.
Lenses
Link copied to clipboard
common
@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class Lenses
Used by the fritz2 gradle-plugin to identify data classes it should generate Lenses for.
LensException
Link copied to clipboard
common
class LensException : Exception
Occurs when Lens points to non existing element.

Functions

asString
Link copied to clipboard
js
fun <P> Lens<P, Boolean>.asString(): Lens<P, String>
Creates a Lens from Boolean to String
fun <P> Lens<P, Byte>.asString(): Lens<P, String>
Creates a Lens from Byte to String
fun <P> Lens<P, Double>.asString(): Lens<P, String>
Creates a Lens from Double to String
fun <P> Lens<P, Float>.asString(): Lens<P, String>
Creates a Lens from Float to String
fun <P> Lens<P, Int>.asString(): Lens<P, String>
Creates a Lens from Int to String
fun <P> Lens<P, Long>.asString(): Lens<P, String>
Creates a Lens from Long to String
fun <P> Lens<P, Short>.asString(): Lens<P, String>
Creates a Lens from Short to String
fun <P> Lens<P, Boolean?>.asString(emptyValue: String = ""): Lens<P, String>
Creates a Lens from Boolean to String
fun <P> Lens<P, Byte?>.asString(emptyValue: String = ""): Lens<P, String>
Creates a Lens from Byte to String
fun <P> Lens<P, Double?>.asString(emptyValue: String = ""): Lens<P, String>
Creates a Lens from Double to String
fun <P> Lens<P, Float?>.asString(emptyValue: String = ""): Lens<P, String>
Creates a Lens from Float to String
fun <P> Lens<P, Int?>.asString(emptyValue: String = ""): Lens<P, String>
Creates a Lens from Int to String
fun <P> Lens<P, Long?>.asString(emptyValue: String = ""): Lens<P, String>
Creates a Lens from Long to String
fun <P> Lens<P, Short?>.asString(emptyValue: String = ""): Lens<P, String>
Creates a Lens from Short to String
fun <P> Lens<P, List<Byte>>.asString(separator: String = ", ", prefix: String = "", postfix: String = ""): Lens<P, String>
Creates a Lens from List of Byte to String
fun <P> Lens<P, List<Double>>.asString(separator: String = ", ", prefix: String = "", postfix: String = ""): Lens<P, String>
Creates a Lens from List of Double to String
fun <P> Lens<P, List<Float>>.asString(separator: String = ", ", prefix: String = "", postfix: String = ""): Lens<P, String>
Creates a Lens from List of Float to String
fun <P> Lens<P, List<Int>>.asString(separator: String = ", ", prefix: String = "", postfix: String = ""): Lens<P, String>
Creates a Lens from List of Int to String
fun <P> Lens<P, List<Long>>.asString(separator: String = ", ", prefix: String = "", postfix: String = ""): Lens<P, String>
Creates a Lens from List of Long to String
fun <P> Lens<P, List<Short>>.asString(separator: String = ", ", prefix: String = "", postfix: String = ""): Lens<P, String>
Creates a Lens from List of Short to String
fun <P> Lens<P, List<String>>.asString(separator: String = ", ", prefix: String = "", postfix: String = ""): Lens<P, String>
Creates a Lens from List of String to String
buildLens
Link copied to clipboard
common
inline fun <P, T> buildLens(id: String, crossinline getter: (P) -> T, crossinline setter: (P, T) -> P): Lens<P, T>
convenience function to create a Lens
elementLens
Link copied to clipboard
common
fun <T, I> elementLens(element: T, idProvider: IdProvider<T, I>): Lens<List<T>, T>
creates a Lens pointing to a certain element in a list
format
Link copied to clipboard
common
inline fun <P> format(crossinline parse: (String) -> P, crossinline format: (P) -> String): Lens<P, String>
creates a Lens converting P to and from a String
positionLens
Link copied to clipboard
common
fun <T> positionLens(index: Int): Lens<List<T>, T>
creates a Lens pointing to a certain position in a list