blob: 9d51d7c6d6d6774df82e8d3f0f945a2bcf476c36 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.plugin.util
/**
* @author tonytv
*/
object Extractors {
class ListOf[C](val c : Class[C]) {
def unapply[X](xs : X) : Option[List[C]] = {
xs match {
case x :: xr if c.isInstance(x) => unapply(xr) map ( c.cast(x) :: _)
case Nil => Some(Nil)
case _ => None
}
}
}
}
|