a custom visitor for elements of type A. the apply method takes a type parameter that is tighter than
A, and acquires a TypeKey for that type, so it can customize its behavior based on the type requested.
the apply method also takes a Visitor as argument, so that it can call back into to the calling
Visitor to visit complex values.
example usage:
// only visit the first five elements of a listval listCustomVisitor = new CustomVisitor[List[Any]] {
def apply[B <:List[_] : TypeKey](visitor: Visitor, list: B): Unit = {
val elementTypeKey = typeKey[B].typeArgs.head
def visitFive[C : TypeKey]: Unit =
list.asInstanceOf[List[C]].take(5).foreach { element => visitor.visit(element) }
visitFive(elementTypeKey)
}
}
val visitor = new Visitor {
overrideprotectedval customVisitors: CustomVisitorPool = CustomVisitorPool.empty + listCustomVisitor
}
This member is added by an implicit conversion from CustomVisitor[A] to
any2stringadd[CustomVisitor[A]] performed by method any2stringadd in scala.Predef.
This member is added by an implicit conversion from CustomVisitor[A] to
StringFormat[CustomVisitor[A]] performed by method StringFormat in scala.Predef.
a custom visitor for elements of type
A
. theapply
method takes a type parameter that is tighter thanA
, and acquires a TypeKey for that type, so it can customize its behavior based on the type requested.the apply method also takes a Visitor as argument, so that it can call back into to the calling
Visitor
to visit complex values.example usage: