in bijection-core/src/main/scala/com/twitter/bijection/Pivot.scala [112:144]
def pivot: Bijection[K, (K1, K2)]
def andThenPivot[K3, K4](after: Bijection[(K1, K2), (K3, K4)]): Pivot[K, K3, K4] =
Pivot(pivot andThen after)
def composePivot[T](before: Bijection[T, K]): Pivot[T, K1, K2] =
Pivot(pivot compose before)
lazy val encoder = Pivot.encoder[K, K1, K2](pivot.apply _)
lazy val decoder = Pivot.decoder[K, K1, K2](pivot.invert _)
override def apply(pairs: Iterable[K]): Map[K1, Iterable[K2]] = encoder(pairs)
override def invert(m: Map[K1, Iterable[K2]]): Iterable[K] = decoder(m)
def split[V](fn: K => V): K1 => K2 => V = decoder.split(fn)
def unsplit[V](fn: K1 => K2 => V): K => V = encoder.unsplit(fn)
/**
* Returns a new Pivot that converts an Iterable of (K, T) to an Iterable of ((K1, T),
* Iterable[K2]). This is useful for applying a new pivoting scheme on top of this one while
* maintaining some outer key component.
*/
def wrapOuter[T]: Pivot[(K, T), (K1, T), K2] =
withValue[T] andThenPivot (new AbstractBijection[(K1, (K2, T)), ((K1, T), K2)] {
def apply(pair: (K1, (K2, T))) = {
val (k1, (k2, t)) = pair
((k1, t), k2)
}
override def invert(pair: ((K1, T), K2)) = {
val ((k1, t), k2) = pair
(k1, (k2, t))
}
})