BindingResolver

zio.blocks.schema.binding.BindingResolver
See theBindingResolver companion trait

The ready-made resolvers empty, defaults and reflection, and BindingResolver.Registry, the resolver that bind builds.

Attributes

Companion
trait
Source
BindingResolver.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Type members

Classlikes

final class Registry extends BindingResolver

A map-backed binding resolver that stores explicit bindings.

A map-backed binding resolver that stores explicit bindings.

Registry is an immutable data structure. Each bind operation returns a new Registry with the added binding.

Proper bindings (record, variant, primitive, wrapper and dynamic) are stored by the normalized TypeId of the full type. Binding a type that already has a proper binding replaces it, whatever its kind: a type has at most one proper binding.

For sequence and map types, bindings are stored by their unapplied type constructor (e.g., List rather than List[Int]), allowing a single binding to work for all element types.

Attributes

Example
import zio.blocks.schema.binding._
case class Person(name: String, age: Int)
val registry = BindingResolver.empty
 .bind(Binding.of[Person])
Companion
object
Source
BindingResolver.scala
Supertypes
class Object
trait Matchable
class Any
object Registry

The companion of BindingResolver.Registry; its members are internal.

The companion of BindingResolver.Registry; its members are internal.

Attributes

Companion
class
Source
BindingResolver.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Registry.type

Value members

Concrete fields

A resolver with bindings for all primitive types and common collections.

A resolver with bindings for all primitive types and common collections.

This includes:

  • Unit, Boolean, Byte, Short, Int, Long, Float, Double, Char, String
  • BigInt, BigDecimal
  • java.time types (DayOfWeek, Duration, Instant, LocalDate, etc.)
  • java.util.Currency, java.util.UUID
  • DynamicValue
  • Common sequence types (List, Vector, Set, IndexedSeq, Seq, Chunk)
  • Map

It has no binding for ChunkMap, Array, ArraySeq or, on Scala 3, IArray. Add one with a bind overload when a schema uses them, such as bind[ChunkMap](Binding.of[ChunkMap]).

Attributes

Source
BindingResolver.scala

An empty registry with no bindings.

An empty registry with no bindings.

Attributes

Source
BindingResolver.scala

Inherited fields

A resolver that derives Binding.Records for case classes at run time, with Java reflection. On the JVM, resolveRecord builds the binding from the class's public constructor and its fields, and caches the result, found or not, per normalized TypeId; every other resolve method returns None. On Scala.js there is no reflection, so every method returns None. Combine it with BindingResolver.defaults for primitives and collections.

A resolver that derives Binding.Records for case classes at run time, with Java reflection. On the JVM, resolveRecord builds the binding from the class's public constructor and its fields, and caches the result, found or not, per normalized TypeId; every other resolve method returns None. On Scala.js there is no reflection, so every method returns None. Combine it with BindingResolver.defaults for primitives and collections.

The constructor used is the first that getConstructors returns, and the fields are the first of getDeclaredFields, as many as the constructor has parameters. On Scala 3, when a case class extends a trait that has a val, that val's field comes first, so the binding reads the wrong fields.

Attributes

Inherited from:
BindingResolverPlatformSpecific (hidden)
Source
BindingResolverPlatformSpecific.scala