Вы можете использовать параметр по умолчанию
object StuffingSystem {
trait Stuffer[V, M, P] {
def stuff(v: V, m: M, additionalparameters: List[P]): Unit
}
object Stuffer {
implicit def mkStuffer: Stuffer[Input, Material, String] = new Stuffer[Input, Material, String] {
override def stuff(v: Input, m: Material, additionalparameters: List[String]): Unit = ???
}
}
case class Input(v: BigDecimal) {
def stuff[M, P](m: M, additionalparameters: List[P] = List())(implicit stuffer: Stuffer[Input, M, P]) =
stuffer.stuff(Input(v), m, additionalparameters)
}
case class Material(o: String)
}
object Stuffers {
import StuffingSystem._
implicit object InputStuffer extends Stuffer[Input, Material, Int] {
def stuff(v: Input, m: Material, p: List[Int]) = ???
}
val stuffed = Input(BigDecimal(101.0)).stuff(Material("o"), List())
val stuffed1 = Input(BigDecimal(101.0)).stuff(Material(""))
val stuffedWithSomething = Input(BigDecimal(101.0)).stuff(Material(""), List("a", "b"))
}
или varargs
object StuffingSystem {
trait Stuffer[V, M, P] {
def stuff(v: V, m: M, additionalparameters: P*): Unit
}
object Stuffer {
implicit def mkStuffer: Stuffer[Input, Material, String] = new Stuffer[Input, Material, String] {
override def stuff(v: Input, m: Material, additionalparameters: String*): Unit = ???
}
}
case class Input(v: BigDecimal) {
def stuff[M, P](m: M, additionalparameters: P*)(implicit stuffer: Stuffer[Input, M, P]) =
stuffer.stuff(Input(v), m, additionalparameters:_*)
}
case class Material(o: String)
}
object Stuffers {
import StuffingSystem._
implicit object InputStuffer extends Stuffer[Input, Material, Int] {
def stuff(v: Input, m: Material, additionalparameters: Int*): Unit = ???
}
val stuffed = Input(BigDecimal(101.0)).stuff(Material("o"), Seq():_*)
val stuffed1 = Input(BigDecimal(101.0)).stuff(Material(""))
val stuffedWithSomething = Input(BigDecimal(101.0)).stuff(Material(""), Seq("a", "b"):_*)
val stuffedWithSomething1 = Input(BigDecimal(101.0)).stuff(Material(""), "a", "b")
}