All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.fintrospect.parameters.Rebindable.scala Maven / Gradle / Ivy

package io.fintrospect.parameters

/**
  * Used to transparently copy the value out of an incoming request (or form etc..) and into an outgoing one. Useful when chaining
  * requests together.
  */
trait Rebindable[From, T, B <: Binding] {
  def <->(from: From): Iterable[B]

  /**
    * User-friendly synonym for <->(), which is why the method is final.
    */
  final def rebind(from: From): Iterable[B] = <->(from)
}

trait MandatoryRebind[From, T, B <: Binding] extends Rebindable[From, T, B] {
  self: Retrieval[From, T] with Bindable[T, B] =>
  override def <->(from: From): Iterable[B] = this --> (this <-- from)
}

trait OptionalRebind[From, T, B <: Binding] extends Rebindable[From, T, B] {
  self: Retrieval[From, Option[T]] with Bindable[T, B] =>
  override def <->(from: From): Iterable[B] = (this <-- from).map(this.-->).getOrElse(Nil)
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy