Object/Trait

com.thoughtworks

Extractor

Related Docs: trait Extractor | package thoughtworks

Permalink

object Extractor extends LowPriorityExtractor

Utilities to convert between A => Option[B], scala.PartialFunction and Extractor.

Source
Extractor.scala
Example:
  1. import com.thoughtworks.Extractor._
    // Define a PartialFunction
    val pf: PartialFunction[Int, String] = {
      case 1 => "matched by PartialFunction"
    }
    // Define an optional function
    val f: Int => Option[String] = { i =>
      if (i == 2) {
        Some("matched by optional function")
      } else {
        None
      }
    }
    // Convert an optional function to a PartialFunction
    val pf2: PartialFunction[Int, String] = Function.unlift(f)
    util.Random.nextInt(4) match {
      case pf.extract(m) => // Convert a PartialFunction to a pattern
        println(m)
      case f.extract(m) => // Convert an optional function to a pattern
        println(m)
      case pf2.extract(m) => // Convert a PartialFunction to a pattern
        throw new AssertionError("This case should never occur because it has the same condition as `f.extract`.")
      case _ =>
        println("Not matched")
    }
Linear Supertypes
LowPriorityExtractor, LowLowPriorityExtractor, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Extractor
  2. LowPriorityExtractor
  3. LowLowPriorityExtractor
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. implicit final class FunctionToExtractor[-A, +B] extends AnyRef

    Permalink
    Definition Classes
    LowLowPriorityExtractor
  2. implicit final class OptionFunctionToExtractor[-A, +B] extends AnyRef

    Permalink
    Definition Classes
    LowPriorityExtractor
  3. implicit final class OptionFunctionToSeqExtractor[-A, +B] extends AnyRef

    Permalink
    Definition Classes
    LowPriorityExtractor
  4. implicit final class PartialFunctionToExtractor[-A, +B] extends AnyRef

    Permalink
  5. sealed trait SeqExtractor[-A, +B] extends AnyRef

    Permalink
    Definition Classes
    LowPriorityExtractor

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  10. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  11. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  13. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  14. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  15. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  16. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  17. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  18. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  19. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from LowPriorityExtractor

Inherited from LowLowPriorityExtractor

Inherited from AnyRef

Inherited from Any

Ungrouped