case classTransformPickler[A <: AnyRef, B](transformTo: (A) ⇒ B, transformFrom: (B) ⇒ A)(implicit p: Pickler[B], up: Unpickler[B]) extends Product with Serializable
Create a transforming pickler that takes an object of type A and transforms it into B, which is then pickled.
Similarly a B is unpickled and then transformed back into A.
This allows for easy creation of picklers for (relatively) simple classes. For example
// transform Date into Long and backimplicitval datePickler = TransformPickler[java.util.Date, Long](
_.getTime,
t =>new java.util.Date(t))
A
Type of the original object
B
Type for the object used in pickling
transformTo
Function that takes A and transforms it into B
transformFrom
Function that takes B and transforms it into A
Linear Supertypes
Serializable, Serializable, Product, Equals, AnyRef, Any
Create a transforming pickler that takes an object of type
A
and transforms it intoB
, which is then pickled. Similarly aB
is unpickled and then transformed back intoA
.This allows for easy creation of picklers for (relatively) simple classes. For example
Type of the original object
Type for the object used in pickling
Function that takes
A
and transforms it intoB
Function that takes
B
and transforms it intoA