Lens

scalapb.lenses.Lens
See theLens companion object
trait Lens[Container, A] extends Serializable

Attributes

Companion:
object
Graph
Supertypes
trait Serializable
class Object
trait Matchable
class Any
Known subtypes
class ObjectLens[U, Container]
Self type
Lens[Container, A]

Members list

Concise view

Value members

Abstract methods

def get(c: Container): A

get knows how to extract some field of type A from a container

get knows how to extract some field of type A from a container

Attributes

def set(a: A): () => Container

Represents an assignment operator.

Represents an assignment operator.

Given a value of type A, sets knows how to transform a container such that a is assigned to the field.

We must have get(set(a)(c)) == a

Attributes

Concrete methods

def :++=(item: Iterable[(A, B)]): () => U
Implicitly added by MapLens
def :++=(item: IterableOnce[A]): () => U
Implicitly added by seqLikeLens
def :++=(item: IterableOnce[A]): () => U
Implicitly added by setLens
def :+=(pair: (A, B)): () => U
Implicitly added by MapLens
def :+=(item: A): () => U
Implicitly added by seqLikeLens
def :+=(item: A): () => U
Implicitly added by setLens
def :=(a: A): () => Container

alias to set

alias to set

Attributes

def apply(key: A): Lens[U, B]
Implicitly added by MapLens
def apply(i: Int): Lens[U, A]
Implicitly added by seqLikeLens
def compose[B](other: Lens[A, B]): Lens[Container, B]

Composes two lenses, this enables nesting.

Composes two lenses, this enables nesting.

If our field of type A has a sub-field of type B, then given a lens for it (other: Lens[A, B]) we can create a single lens from Container to B.

Attributes

def foreach(f: Lens[(A, B), (A, B)] => () => (A, B)): () => U
Implicitly added by MapLens
def foreach(f: Lens[A, A] => () => A): () => U
Implicitly added by seqLikeLens
def foreach(f: Lens[A, A] => () => A): () => U
Implicitly added by setLens
def foreachValue(f: Lens[B, B] => () => B): () => U
Implicitly added by MapLens
def head: Lens[U, A]
Implicitly added by seqLikeLens
def inplaceMap(f: Lens[A, A] => () => A): () => U
Implicitly added by OptLens
def last: Lens[U, A]
Implicitly added by seqLikeLens
def mapValues(f: B => B): () => U
Implicitly added by MapLens
def modify(f: A => A): () => Container

Represent an update operator (like x.y += 1 )

Represent an update operator (like x.y += 1 )

Attributes

def setIfDefined(aOpt: Option[A]): () => Container

Optional assignment.

Optional assignment.

Given a Some[A], assign the Some's value to the field. Given None, the container is unchanged.

Attributes

def zip[B](other: Lens[Container, B]): Lens[Container, (A, B)]

Given two lenses with the same origin, returns a new lens that can mutate both values represented by both lenses through a tuple.

Given two lenses with the same origin, returns a new lens that can mutate both values represented by both lenses through a tuple.

Attributes

Concrete fields

val lens: Lens[U, Map[A, B]]
Implicitly added by MapLens
val lens: Lens[U, Option[A]]
Implicitly added by OptLens
val lens: Lens[U, CC[A]]
Implicitly added by seqLikeLens
val lens: Lens[U, CC[A]]
Implicitly added by setLens