Registry

zio.blocks.schema.binding.BindingResolver.Registry
See theRegistry companion object
final class Registry extends BindingResolver

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
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def bind[A](binding: Binding[_, A])(implicit typeId: TypeId[A]): Registry

Binds a type to its binding, automatically dispatching based on binding kind.

Binds a type to its binding, automatically dispatching based on binding kind.

This unified entry point accepts any proper binding type (Record, Variant, Primitive, Wrapper, or Dynamic) and stores it appropriately. It accepts the result of Binding.of[A] on both Scala versions: on Scala 2 its static type is Binding[_, A], and on Scala 3 it is the specific binding type.

Type parameters

A

The type to bind

Value parameters

binding

Any proper binding (Record, Variant, Primitive, Wrapper, or Dynamic)

typeId

The TypeId for type A (usually derived implicitly)

Attributes

Returns

A new Registry with the binding added

Throws
java.lang.IllegalArgumentException

if the binding is a Seq or Map binding (use the appropriate overload instead)

Example
import zio.blocks.schema.binding._
case class Person(name: String, age: Int)
val registry = BindingResolver.empty.bind(Binding.of[Person])
Source
BindingResolver.scala
def bind[C[_]](binding: Seq[C, _])(implicit typeId: TypeId[C[Nothing]]): Registry

Binds a sequence type constructor to its binding.

Binds a sequence type constructor to its binding.

The binding is stored by the unapplied type constructor, so binding List allows lookup for List[Int], List[String], etc.

The element type A is phantom (not used by the binding's constructor or deconstructor), so any element type can be passed.

Type parameters

C

The sequence type constructor (e.g., List, Vector)

Value parameters

binding

The sequence binding providing constructor and deconstructor

typeId

The TypeId for the applied type C[Nothing] (used to extract the constructor)

Attributes

Returns

A new Registry with the binding added

Source
BindingResolver.scala
def bind[M[_, _]](binding: Map[M, _, _])(implicit typeId: TypeId[M[Nothing, Nothing]]): Registry

Binds a map type constructor to its binding.

Binds a map type constructor to its binding.

The binding is stored by the unapplied type constructor, so binding Map allows lookup for Map[String, Int], Map[Int, String], etc.

The key and value types K and V are phantom (not used by the binding's constructor or deconstructor), so any types can be passed.

Type parameters

M

The map type constructor (e.g., Map)

Value parameters

binding

The map binding providing constructor and deconstructor

typeId

The TypeId for the applied type M[Nothing, Nothing] (used to extract the constructor)

Attributes

Returns

A new Registry with the binding added

Source
BindingResolver.scala
def contains[A](implicit typeId: TypeId[A]): Boolean

Checks if the registry contains a proper binding (record, variant, primitive, wrapper or dynamic) for the given type. It returns false for a sequence or map type whose type constructor is bound, such as List[Int] in BindingResolver.defaults; use containsSeq or containsMap for those.

Checks if the registry contains a proper binding (record, variant, primitive, wrapper or dynamic) for the given type. It returns false for a sequence or map type whose type constructor is bound, such as List[Int] in BindingResolver.defaults; use containsSeq or containsMap for those.

Type parameters

A

The type to check

Value parameters

typeId

The TypeId for type A (usually derived implicitly)

Attributes

Returns

true if a binding exists, false otherwise

Source
BindingResolver.scala
def containsMap[X](implicit typeId: TypeId[X], u: UnapplyMap[X]): Boolean

Checks if the registry contains a map binding for the given type constructor.

Checks if the registry contains a map binding for the given type constructor.

Type parameters

X

The applied map type (e.g., Map[String, Int])

Value parameters

typeId

The TypeId for type X (usually derived implicitly)

u

Evidence that X is an applied map type

Attributes

Returns

true if a binding exists, false otherwise

Source
BindingResolver.scala
def containsSeq[X](implicit typeId: TypeId[X], u: UnapplySeq[X]): Boolean

Checks if the registry contains a sequence binding for the given type constructor.

Checks if the registry contains a sequence binding for the given type constructor.

Type parameters

X

The applied sequence type (e.g., List[Int])

Value parameters

typeId

The TypeId for type X (usually derived implicitly)

u

Evidence that X is an applied sequence type

Attributes

Returns

true if a binding exists, false otherwise

Source
BindingResolver.scala
override def equals(obj: Any): Boolean

Compares the receiver object (this) with the argument object (that) for equivalence.

Compares the receiver object (this) with the argument object (that) for equivalence.

Any implementation of this method should be an equivalence relation:

  • It is reflexive: for any instance x of type Any, x.equals(x) should return true.
  • It is symmetric: for any instances x and y of type Any, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any instances x, y, and z of type Any if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.

If you override this method, you should verify that your implementation remains an equivalence relation. Additionally, when overriding this method it is usually necessary to override hashCode to ensure that objects which are "equal" (o1.equals(o2) returns true) hash to the same scala.Int. (o1.hashCode.equals(o2.hashCode)).

Value parameters

that

the object to compare against this object for equality.

Attributes

Returns

true if the receiver object is equivalent to the argument; false otherwise.

Definition Classes
Any
Source
BindingResolver.scala
override def hashCode(): Int

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
Any
Source
BindingResolver.scala
def isEmpty: Boolean

Checks if the registry is empty.

Checks if the registry is empty.

Attributes

Source
BindingResolver.scala
def nonEmpty: Boolean

Checks if the registry is non-empty.

Checks if the registry is non-empty.

Attributes

Source
BindingResolver.scala
def resolveDynamic(implicit typeId: TypeId[DynamicValue]): Option[Dynamic]

Resolves the dynamic binding.

Resolves the dynamic binding.

Value parameters

typeId

The TypeId for DynamicValue (usually derived implicitly)

Attributes

Returns

The binding if found, None otherwise

Source
BindingResolver.scala
def resolveMap[X](implicit typeId: TypeId[X], u: UnapplyMap[X]): Option[Map[u.M, u.K, u.V]]

Resolves a map binding for an applied map type.

Resolves a map binding for an applied map type.

Uses UnapplyMap to decompose the applied type and resolve the binding by type constructor.

Type parameters

X

The applied map type (e.g., Map[String, Int])

Value parameters

typeId

The TypeId for type X (usually derived implicitly)

u

Evidence that X is an applied map type

Attributes

Returns

The binding if found, None otherwise

Source
BindingResolver.scala
def resolveMapFor[M[_, _], K, V](typeId: TypeId[M[K, V]]): Option[Map[M, K, V]]

Resolves a map binding given an explicit TypeId for the applied type.

Resolves a map binding given an explicit TypeId for the applied type.

This variant is useful when you already have the map type constructor and key/value types as separate type parameters.

Type parameters

K

The key type

M

The map type constructor (e.g., Map)

V

The value type

Value parameters

typeId

The TypeId for the applied type M[K, V]

Attributes

Returns

The binding if found, None otherwise

Source
BindingResolver.scala
def resolvePrimitive[A](implicit typeId: TypeId[A]): Option[Primitive[A]]

Resolves a primitive binding for a type.

Resolves a primitive binding for a type.

Type parameters

A

The type to resolve

Value parameters

typeId

The TypeId for type A (usually derived implicitly)

Attributes

Returns

The binding if found, None otherwise

Source
BindingResolver.scala
def resolveRecord[A](implicit typeId: TypeId[A]): Option[Record[A]]

Resolves a record binding for a type.

Resolves a record binding for a type.

Type parameters

A

The type to resolve

Value parameters

typeId

The TypeId for type A (usually derived implicitly)

Attributes

Returns

The binding if found, None otherwise

Source
BindingResolver.scala
def resolveSeq[X](implicit typeId: TypeId[X], u: UnapplySeq[X]): Option[Seq[u.C, u.A]]

Resolves a sequence binding for an applied sequence type.

Resolves a sequence binding for an applied sequence type.

Uses UnapplySeq to decompose the applied type and resolve the binding by type constructor.

Type parameters

X

The applied sequence type (e.g., List[Int])

Value parameters

typeId

The TypeId for type X (usually derived implicitly)

u

Evidence that X is an applied sequence type

Attributes

Returns

The binding if found, None otherwise

Source
BindingResolver.scala
def resolveSeqFor[C[_], A](typeId: TypeId[C[A]]): Option[Seq[C, A]]

Resolves a sequence binding given an explicit TypeId for the applied type.

Resolves a sequence binding given an explicit TypeId for the applied type.

This variant is useful when you already have the type constructor and element type as separate type parameters.

Type parameters

A

The element type

C

The sequence type constructor (e.g., List)

Value parameters

typeId

The TypeId for the applied type C[A]

Attributes

Returns

The binding if found, None otherwise

Source
BindingResolver.scala
def resolveVariant[A](implicit typeId: TypeId[A]): Option[Variant[A]]

Resolves a variant binding for a type.

Resolves a variant binding for a type.

Type parameters

A

The type to resolve

Value parameters

typeId

The TypeId for type A (usually derived implicitly)

Attributes

Returns

The binding if found, None otherwise

Source
BindingResolver.scala
def resolveWrapper[A](implicit typeId: TypeId[A]): Option[Wrapper[A, _]]

Resolves a wrapper binding for a type.

Resolves a wrapper binding for a type.

Type parameters

A

The wrapper type

Value parameters

typeId

The TypeId for type A (usually derived implicitly)

Attributes

Returns

The binding if found, None otherwise

Source
BindingResolver.scala
def size: Int

Returns the number of bindings in the registry, counting each bound type or type constructor once.

Returns the number of bindings in the registry, counting each bound type or type constructor once.

Attributes

Source
BindingResolver.scala
override def toString: String

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
BindingResolver.scala

Inherited methods

final def ++(that: BindingResolver): BindingResolver

Combines this resolver with another, trying this resolver first.

Combines this resolver with another, trying this resolver first.

When resolving a binding, the combined resolver tries this first. If this returns None, it falls back to that.

Value parameters

that

The fallback resolver

Attributes

Returns

A combined resolver that tries this first, then that

Example
import zio.blocks.schema.binding._
case class Person(name: String, age: Int)
val customRegistry = BindingResolver.empty.bind(Binding.of[Person])
// customRegistry overrides defaults
val resolver = customRegistry ++ BindingResolver.defaults
Inherited from:
BindingResolver
Source
BindingResolver.scala