A node that stands for another node, built the first time it is needed. A recursive type uses it to refer to itself: in the derived schema of case class Tree(value: Int, children: List[Tree]), the node of the children field is a Deferred. Derivation also uses it for every field with a default value.
Its methods forward to value, except for the default value and examples set on this node, and the type ID when _typeId is set. The methods that walk the tree stop when they come back to this node: typeId then returns a placeholder named ``, toString prints deferred => and the type ID, equals returns true, and the as* and is* methods return None and false.
Value parameters
- _typeId
-
a type ID to return instead of that node's
- _value
-
builds the node that this one stands for
Attributes
- Companion
- object
- Source
- Reflect.scala
- Graph
-
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait Reflectable[A]class Objecttrait Matchableclass AnyShow all
- Self type
-
Members list
Type members
Types
The kind of binding this node holds, such as BindingType.Record for a record. It fixes the types of metadata and binding.
The kind of binding this node holds, such as BindingType.Record for a record. It fixes the types of metadata and binding.
Attributes
- Source
- Reflect.scala
Inherited types
The type that this reflect describes.
Value members
Concrete methods
Returns this node as a Reflect.Dynamic, or None for another kind of node.
Returns this node as a Reflect.Dynamic, or None for another kind of node.
Attributes
- Definition Classes
- Source
- Reflect.scala
Returns this node as a Reflect.Map typed with the key, value and map types that IsMap gives for A, or None for another kind of node.
Returns this node as a Reflect.Map typed with the key, value and map types that IsMap gives for A, or None for another kind of node.
Attributes
- Definition Classes
- Source
- Reflect.scala
Returns this node as a map node whose key, value and map types are not known statically, or None for another kind of node. Use it when A is not known to be a map type.
Returns this node as a map node whose key, value and map types are not known statically, or None for another kind of node. Use it when A is not known to be a map type.
Attributes
- Definition Classes
- Source
- Reflect.scala
Returns this node as a Reflect.Primitive, or None for another kind of node.
Returns this node as a Reflect.Primitive, or None for another kind of node.
Attributes
- Definition Classes
- Source
- Reflect.scala
Returns this node as a Reflect.Record, or None for another kind of node.
Returns this node as a Reflect.Record, or None for another kind of node.
Attributes
- Definition Classes
- Source
- Reflect.scala
Returns this node as a Reflect.Sequence typed with the element and collection types that IsCollection gives for A, or None for another kind of node.
Returns this node as a Reflect.Sequence typed with the element and collection types that IsCollection gives for A, or None for another kind of node.
Attributes
- Definition Classes
- Source
- Reflect.scala
Returns this node as a sequence node whose element and collection types are not known statically, or None for another kind of node. Use it when A is not known to be a collection type.
Returns this node as a sequence node whose element and collection types are not known statically, or None for another kind of node. Use it when A is not known to be a collection type.
Attributes
- Definition Classes
- Source
- Reflect.scala
Returns this node as a Reflect.Variant, or None for another kind of node.
Returns this node as a Reflect.Variant, or None for another kind of node.
Attributes
- Definition Classes
- Source
- Reflect.scala
Returns this node as a wrapper node whose wrapped type is not known statically, or None for another kind of node.
Returns this node as a wrapper node whose wrapped type is not known statically, or None for another kind of node.
Attributes
- Definition Classes
- Source
- Reflect.scala
Returns the Binding of this node: the functions that build and take apart values of A.
Returns the Binding of this node: the functions that build and take apart values of A.
Attributes
- Source
- Reflect.scala
Returns a copy whose default value is dv. Unlike the other nodes, it does not evaluate dv: getDefaultValue evaluates it on every call.
Returns a copy whose default value is dv. Unlike the other nodes, it does not evaluate dv: getDefaultValue evaluates it on every call.
Attributes
- Source
- Reflect.scala
Returns a copy that stands for the node with the documentation value.
Returns a copy that stands for the node with the documentation value.
Attributes
- Source
- Reflect.scala
Returns the documentation of value.
Checks whether this instance is equal to that. This universal equality method is defined in AnyRef.
Checks whether this instance is equal to that. This universal equality method is defined in AnyRef.
Attributes
- Definition Classes
- Source
- Reflect.scala
Returns the examples set on this node, or else the examples of value.
Returns the examples set on this node, or else the examples of value.
Attributes
- Source
- Reflect.scala
Returns a copy whose examples are value and values, kept as values of A instead of DynamicValues.
Returns a copy whose examples are value and values, kept as values of A instead of DynamicValues.
Attributes
- Source
- Reflect.scala
Returns the default value set on this node, evaluated on each call, or else the default value of value.
Returns the default value set on this node, evaluated on each call, or else the default value of value.
Attributes
- Source
- Reflect.scala
Calculates a hash code value for the object.
Calculates a hash code value for the object.
The default hashing algorithm is platform dependent.
Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)) yet not be equal (o1.equals(o2) returns false). A degenerate implementation could always return 0. However, it is required that if two objects are equal (o1.equals(o2) returns true) that they have identical hash codes (o1.hashCode.equals(o2.hashCode)). Therefore, when overriding this method, be sure to verify that the behavior is consistent with the equals method.
Attributes
- Returns
-
the hash code value for this object.
- Definition Classes
-
Reflect -> Any
- Source
- Reflect.scala
Returns true when this is a Reflect.Dynamic node.
Returns true when this is a Reflect.Dynamic node.
Attributes
- Definition Classes
- Source
- Reflect.scala
Returns true when this is a Reflect.Map node.
Returns true when this is a Reflect.Primitive node.
Returns true when this is a Reflect.Primitive node.
Attributes
- Definition Classes
- Source
- Reflect.scala
Returns true when this is a Reflect.Record node.
Returns true when this is a Reflect.Sequence node.
Returns true when this is a Reflect.Sequence node.
Attributes
- Definition Classes
- Source
- Reflect.scala
Returns true when this is a Reflect.Variant node.
Returns true when this is a Reflect.Variant node.
Attributes
- Definition Classes
- Source
- Reflect.scala
Returns true when this is a Reflect.Wrapper node.
Returns true when this is a Reflect.Wrapper node.
Attributes
- Definition Classes
- Source
- Reflect.scala
Returns what this node holds besides its structure: a Binding in a bound reflect, NoBinding in an unbound one.
Returns what this node holds besides its structure: a Binding in a bound reflect, NoBinding in an unbound one.
Attributes
- Source
- Reflect.scala
Returns a copy that stands for the node with modifier added.
Returns the modifiers of value.
Returns a copy that stands for the node with modifiers added.
Returns the kind of value.
Converts value into a DynamicValue with the same shape as this reflect: a DynamicValue.Record with the fields in declaration order, a DynamicValue.Variant named after the value's case, a DynamicValue.Sequence, a DynamicValue.Map or a DynamicValue.Primitive. A wrapper gives the dynamic value of the value it wraps, and a dynamic node returns value as it is. fromDynamicValue converts the result back.
Converts value into a DynamicValue with the same shape as this reflect: a DynamicValue.Record with the fields in declaration order, a DynamicValue.Variant named after the value's case, a DynamicValue.Sequence, a DynamicValue.Map or a DynamicValue.Primitive. A wrapper gives the dynamic value of the value it wraps, and a dynamic node returns value as it is. fromDynamicValue converts the result back.
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val value = Book.schema.reflect.toDynamicValue(Book("Zionomicon", 2021))
// {
// title: "Zionomicon",
// year: 2021
// }
Attributes
- See also
- Source
- Reflect.scala
Returns a string representation of the object.
Returns a string representation of the object.
The default representation is platform dependent.
Attributes
- Returns
-
a string representation of the object.
- Definition Classes
-
Any
- Source
- Reflect.scala
Returns a deferred node that transforms value with f when it is first needed. The result is cached per thread under this node and f, which is what makes the transformation of a recursive type terminate.
Returns a deferred node that transforms value with f when it is first needed. The result is cached per thread under this node and f, which is what makes the transformation of a recursive type terminate.
Attributes
- Source
- Reflect.scala
Returns _typeId when it is set, or else the type ID of value, or the placeholder `` when looking it up comes back to this node.
Returns _typeId when it is set, or else the type ID of value, or the placeholder `` when looking it up comes back to this node.
Attributes
- Source
- Reflect.scala
Returns a copy whose type ID is newTypeId, without building value.
Inherited methods
Returns a Term named name whose value is this node, to use as a field or case of a record or variant of type S.
Returns a Term named name whose value is this node, to use as a field or case of a record or variant of type S.
Attributes
- Inherited from:
- Reflect
- Source
- Reflect.scala
Returns this reflect with aspect applied to the node that optic focuses on, or this reflect unchanged when the optic's path does not lead to a node.
Returns this reflect with aspect applied to the node that optic focuses on, or this reflect unchanged when the optic's path does not lead to a node.
Attributes
- Inherited from:
- Reflect
- Source
- Reflect.scala
Returns this reflect with the SchemaAspect aspect applied to it.
Returns this reflect with the SchemaAspect aspect applied to it.
Attributes
- Inherited from:
- Reflect
- Source
- Reflect.scala
Returns a copy of this node whose documentation is value, as a single paragraph of plain text, replacing any it had. doc without an argument reads it back.
Returns a copy of this node whose documentation is value, as a single paragraph of plain text, replacing any it had. doc without an argument reads it back.
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val documented = Book.schema.reflect.doc("A book in the catalogue")
val text = documented.doc.toString.trim // A book in the catalogue
Attributes
- See also
- Inherited from:
- Reflect
- Source
- Reflect.scala
Converts value into an A, or returns a SchemaError that lists where value does not fit this reflect. The errors of all the fields, elements and map entries are collected, not only the first one.
Converts value into an A, or returns a SchemaError that lists where value does not fit this reflect. The errors of all the fields, elements and map entries are collected, not only the first one.
Each kind of node expects its own kind of DynamicValue:
- a record expects a
DynamicValue.Record. It matches the fields by name, in any order, and ignores fields it does not know. - a variant expects a
DynamicValue.Variantwhose case name it knows. - a sequence expects a
DynamicValue.Sequence, and a map aDynamicValue.Map. - a primitive expects a
DynamicValue.Primitive; numeric types andCharalso accept other numeric orCharvalues that convert to them, without loss except for the cases listed atPrimitiveType#fromDynamicValue. - a wrapper decodes the value of the type it wraps, then wraps it.
- a dynamic node accepts any value as it is.
The errors are ExpectationMismatch for the wrong kind of value, MissingField, DuplicatedField and UnknownCase, each at the path where it happened, and ConversionFailed at a path ending in .wrapped when a wrapper's wrap function throws. A missing field is an error even when the field has a default value, and Validation constraints are not checked (DynamicSchema#check checks them).
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val title = DynamicValue.Primitive(PrimitiveValue.String("Zionomicon"))
val year = DynamicValue.Primitive(PrimitiveValue.Int(2021))
val book = Book.schema.reflect.fromDynamicValue(
DynamicValue.Record("title" -> title, "year" -> year)
) // Right(Book(Zionomicon,2021))
val missing = Book.schema.reflect.fromDynamicValue(
DynamicValue.Record("title" -> title)
) // Left(zio.blocks.schema.SchemaError: Missing field 'year' at: .)
Attributes
- See also
- Inherited from:
- Reflect
- Source
- Reflect.scala
Returns the node at the path dynamic, or None when the path does not lead to a node of this reflect.
Returns the node at the path dynamic, or None when the path does not lead to a node of this reflect.
Each step moves to a child node: a field step to the record field of that name, a case step to the variant case of that name, an index, indices or elements step to the element node of a sequence, a wrapped step to the wrapped node, a map-keys step to the key node of a map, and any other map step to its value node. A type search step moves to the first node, in depth-first order, whose type ID is the searched one, and a schema search step to the first node that matches its pattern; the rest of the path continues from there.
Attributes
- Inherited from:
- Reflect
- Source
- Reflect.scala
Returns the node that optic focuses on, or None when the optic's path does not lead to a node of this reflect.
Returns the node that optic focuses on, or None when the optic's path does not lead to a node of this reflect.
case class Author(name: String)
object Author {
implicit val schema: Schema[Author] = Schema.derived
}
case class Book(title: String, author: Author)
object Book extends CompanionOptics[Book] {
implicit val schema: Schema[Book] = Schema.derived
val authorName: Lens[Book, String] = $(_.author.name)
}
val node = Book.schema.reflect.get(Book.authorName) // Some(String)
Attributes
- See also
- Inherited from:
- Reflect
- Source
- Reflect.scala
Returns true when this is a sequence or map node.
Returns true when this is a sequence or map node.
Attributes
- Inherited from:
- Reflect
- Source
- Reflect.scala
Returns true when this is a variant whose cases carry no data: each case is a record without fields, such as a case object, or is itself such a variant.
Returns true when this is a variant whose cases carry no data: each case is a record without fields, such as a case object, or is itself such a variant.
Attributes
- Inherited from:
- Reflect
- Source
- Reflect.scala
Returns true when this is the variant of a zio.blocks.maybe.Maybe: a variant whose type ID is Maybe, with two cases, the second named Present.
Returns true when this is the variant of a zio.blocks.maybe.Maybe: a variant whose type ID is Maybe, with two cases, the second named Present.
Attributes
- Inherited from:
- Reflect
- Source
- Reflect.scala
Returns true when this is the variant of a scala.Option: a variant whose type ID is Option in package scala, with two cases, the second named Some.
Returns true when this is the variant of a scala.Option: a variant whose type ID is Option in package scala, with two cases, the second named Some.
Attributes
- Inherited from:
- Reflect
- Source
- Reflect.scala
For an Option or Maybe variant, returns the node of the value it holds: the single field of its Some or Present case. Returns None for any other node.
For an Option or Maybe variant, returns the node of the value it holds: the single field of its Some or Present case. Returns None for any other node.
Attributes
- Inherited from:
- Reflect
- Source
- Reflect.scala
An iterator over the names of all the elements of this product.
An iterator over the names of all the elements of this product.
Attributes
- Inherited from:
- Product
- Source
- Product.scala
An iterator over all the elements of this product.
An iterator over all the elements of this product.
Attributes
- Returns
-
in the default implementation, an
Iterator[Any] - Inherited from:
- Product
- Source
- Product.scala
Returns a copy of this reflect in which the node at the path dynamic is replaced by f.update of it, or None when the path does not lead to a node. It follows field, case, sequence, wrapped, map-keys and map-values steps as get does, but it does not run type or schema searches: on a map node a type or schema search step is treated as a map-values step, and on any other node it returns None.
Returns a copy of this reflect in which the node at the path dynamic is replaced by f.update of it, or None when the path does not lead to a node. It follows field, case, sequence, wrapped, map-keys and map-values steps as get does, but it does not run type or schema searches: on a map node a type or schema search step is treated as a map-values step, and on any other node it returns None.
Attributes
- Inherited from:
- Reflect
- Source
- Reflect.scala
Returns a copy of this reflect in which the node that optic focuses on is replaced by f of it, or None when the optic's path does not lead to a node of this reflect.
Returns a copy of this reflect in which the node that optic focuses on is replaced by f of it, or None when the optic's path does not lead to a node of this reflect.
Attributes
- Inherited from:
- Reflect
- Source
- Reflect.scala
Concrete fields
The node that this one stands for, built on first access.
Inherited fields
This reflect without bindings: the same tree, with the metadata of every node replaced by NoBinding. It keeps the structure, documentation, modifiers, default values and examples. Schema#toDynamicSchema wraps it in a DynamicSchema.
This reflect without bindings: the same tree, with the metadata of every node replaced by NoBinding. It keeps the structure, documentation, modifiers, default values and examples. Schema#toDynamicSchema wraps it in a DynamicSchema.
Attributes
- Inherited from:
- Reflect
- Source
- Reflect.scala