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
Members list
Value members
Concrete methods
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
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
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
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
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
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
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
xof typeAny,x.equals(x)should returntrue. - It is symmetric: for any instances
xandyof typeAny,x.equals(y)should returntrueif and only ify.equals(x)returnstrue. - It is transitive: for any instances
x,y, andzof typeAnyifx.equals(y)returnstrueandy.equals(z)returnstrue, thenx.equals(z)should returntrue.
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
-
trueif the receiver object is equivalent to the argument;falseotherwise. - Definition Classes
-
Any
- Source
- BindingResolver.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
-
Any
- Source
- BindingResolver.scala
Checks if the registry is empty.
Checks if the registry is non-empty.
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
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
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
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
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
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
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
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
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
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
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
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
thisfirst, thenthat - 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