final case class ValueBinding[T](key: ValueBindingKey)(implicit evidence$3: ValueMapper[T]) extends Binding with Product with Serializable

A binding between a key that is a "JSON-LD value" and a Scala type that can be represented as that value. A ValueMapper is responsible for doing the conversion.

You can define your own ValueMapper for custom types, and primitives (String, Int, etc) are already defined:

val givenName  = schemaOrg("givenName").bindValue[String]
val willPerson = NodeObject(
  givenName    -> "Person"
)

Using a "null" is done by binding to an Option[T] of the type you want:

val givenName  = schemaOrg("givenName").bindValue[Option[String]]
val willPerson = NodeObject(
  givenName  -> None
)

Some JSON-LD values are represented as "value objects", notably strings with languages and typed values.

To represent a string value:

val givenName  = schemaOrg("givenName").bindValue[String]
val willPerson = NodeObject(
  givenName -> Value("Will", StringDirection.LeftToRight, "en"),
)

You can require string values over literals by binding explicitly:

val givenName  = schemaOrg("givenName").bindValue[StringValue]

Likewise typed values are usually converted but can be defined explicitly:

val name        = schemaOrg("name").bindValue[String]
val dateCreated = schemaOrg("dateCreated").bindValue[TypedValue]
val localDate = LocalDate.of(2020, 1, 1)
val abridgedMobyDick = NodeObject(
  `@type`     -> "Book",
  name        -> "Moby Dick",
  dateCreated -> Value(DateTimeFormatter.ISO_DATE.format(localDate), xsdDate)
)

You can map any type to a value using a custom ValueMapper:

val `@type` = Keyword.`@type`.bindIRI
val schemaOrg: Vocab        = IRI("https://schema.org/").vocab
val name: ValueBinding[String] = schemaOrg("name").bindValue[String]
val value: ValueBinding[Int]   = schemaOrg("value").bindValue[Int]

implicit val currencyMapper: ValueMapper[Currency] = ValueMapper { currency =>
  Value(currency.getCurrencyCode)
}
val currency: ValueBinding[Currency] = schemaOrg("currency").bindValue[Currency]
T

the type which has a ValueMapper type class instance

key

the value binding key

Source
Binding.scala
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ValueBinding
  2. Serializable
  3. Product
  4. Equals
  5. Binding
  6. AnyRef
  7. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new ValueBinding(key: ValueBindingKey)(implicit arg0: ValueMapper[T])

    key

    the value binding key

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String
    Implicit
    This member is added by an implicit conversion from ValueBinding[T] toany2stringadd[ValueBinding[T]] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->(value: Value[T]): NodeEntry

    Binds to a value of T.

    Binds to a value of T.

    value

    the value

    returns

    the node entry

  5. def ->(value: T): NodeEntry

    Alias for bind.

    Alias for bind.

    value

    the value

    returns

    the node entry

  6. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  7. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  8. def bind(value: Value[T]): NodeEntry

    Binds to a value of T.

    Binds to a value of T.

    value

    the value

    returns

    the node entry

  9. def bind(value: T): NodeEntry

    Binds to a value of T.

    Binds to a value of T.

    value

    the value

    returns

    the node entry

  10. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  11. def ensuring(cond: (ValueBinding[T]) => Boolean, msg: => Any): ValueBinding[T]
    Implicit
    This member is added by an implicit conversion from ValueBinding[T] toEnsuring[ValueBinding[T]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  12. def ensuring(cond: (ValueBinding[T]) => Boolean): ValueBinding[T]
    Implicit
    This member is added by an implicit conversion from ValueBinding[T] toEnsuring[ValueBinding[T]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  13. def ensuring(cond: Boolean, msg: => Any): ValueBinding[T]
    Implicit
    This member is added by an implicit conversion from ValueBinding[T] toEnsuring[ValueBinding[T]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  14. def ensuring(cond: Boolean): ValueBinding[T]
    Implicit
    This member is added by an implicit conversion from ValueBinding[T] toEnsuring[ValueBinding[T]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  15. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. def formatted(fmtstr: String): String
    Implicit
    This member is added by an implicit conversion from ValueBinding[T] toStringFormat[ValueBinding[T]] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  17. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  18. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  19. val key: ValueBindingKey
    Definition Classes
    ValueBindingBinding
  20. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  21. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  22. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  23. def productElementNames: Iterator[String]
    Definition Classes
    Product
  24. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  25. def toString(): String
    Definition Classes
    ValueBinding → AnyRef → Any
  26. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  27. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  28. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Shadowed Implicit Value Members

  1. def ->[B](y: B): (ValueBinding[T], B)
    Implicit
    This member is added by an implicit conversion from ValueBinding[T] toArrowAssoc[ValueBinding[T]] performed by method ArrowAssoc in scala.Predef.
    Shadowing
    This implicitly inherited member is shadowed by one or more members in this class.
    To access this member you can use a type ascription:
    (valueBinding: ArrowAssoc[ValueBinding[T]]).->(y)
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated
  2. def [B](y: B): (ValueBinding[T], B)
    Implicit
    This member is added by an implicit conversion from ValueBinding[T] toArrowAssoc[ValueBinding[T]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use -> instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from Binding

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd fromValueBinding[T] to any2stringadd[ValueBinding[T]]

Inherited by implicit conversion StringFormat fromValueBinding[T] to StringFormat[ValueBinding[T]]

Inherited by implicit conversion Ensuring fromValueBinding[T] to Ensuring[ValueBinding[T]]

Inherited by implicit conversion ArrowAssoc fromValueBinding[T] to ArrowAssoc[ValueBinding[T]]

Ungrouped