trait Transformer[-In, +Out] extends AnyRef
Primary "spac" abstraction which represents a transformation stage for a stream of data events
Transformers effectively transform a stream of In
events into a stream of Out
events.
The actual stream handling logic is defined by a Transformer.Handler
, which a Transformer
is responsible for constructing.
Handlers may be internally-mutable, and so they are generally only constructed by other handlers.
Transformers themselves are immutable, acting as "handler factories", and so they may be freely reused.
A transformer may choose to abort in response to any input event, as well as emit any number of outputs in response to an input event or the EOF signal.
- In
The incoming event type
- Out
The outgoing event type
- Source
- Transformer.scala
- Grouped
- Alphabetic
- By Inheritance
- Transformer
- AnyRef
- Any
- by TransformerKVParsingOps
- by TransformerParsingOps
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Abstract Value Members
- abstract def newHandler: Handler[In, Out]
Transformer's main abstract method; constructs a new Handler representing this transformer's logic.
Transformer's main abstract method; constructs a new Handler representing this transformer's logic. Transformers are expected to be immutable, but Handlers may be internally-mutable.
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- def +(other: String): String
- Implicit
- This member is added by an implicit conversion from Transformer[In, Out] toany2stringadd[Transformer[In, Out]] performed by method any2stringadd in scala.Predef.
- Definition Classes
- any2stringadd
- def ->[B](y: B): (Transformer[In, Out], B)
- Implicit
- This member is added by an implicit conversion from Transformer[In, Out] toArrowAssoc[Transformer[In, Out]] performed by method ArrowAssoc in scala.Predef.This conversion will take place only if Out is a subclass of (Nothing, Nothing) (Out <: (Nothing, Nothing)).
- Definition Classes
- ArrowAssoc
- Annotations
- @inline()
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def cast[Out2](implicit ev: <:<[Out, Out2]): Transformer[In, Out2]
Returns this transformer, but with a different view of the
Out
type.Returns this transformer, but with a different view of the
Out
type. TheOut <:< Out2
implicit evidence is used to make sure theasInstanceOf
cast is safe. This is mostly useful when you know you have a transformer that yields a tuple or some kind of type constructor. - def clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def collect[Out2](pf: PartialFunction[Out, Out2]): Transformer[In, Out2]
Creates a new transformer which filters and maps the outputs from this transformer
Creates a new transformer which filters and maps the outputs from this transformer
- Out2
Result type of the
pf
- pf
Partial function responsible for the filtering and mapping of outputs from this transformer
- returns
The filteried and mapped transformer
- def drain: Parser[In, Unit]
Convenience for
this into Parser.drain
- def ensuring(cond: (Transformer[In, Out]) => Boolean, msg: => Any): Transformer[In, Out]
- Implicit
- This member is added by an implicit conversion from Transformer[In, Out] toEnsuring[Transformer[In, Out]] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- def ensuring(cond: (Transformer[In, Out]) => Boolean): Transformer[In, Out]
- Implicit
- This member is added by an implicit conversion from Transformer[In, Out] toEnsuring[Transformer[In, Out]] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- def ensuring(cond: Boolean, msg: => Any): Transformer[In, Out]
- Implicit
- This member is added by an implicit conversion from Transformer[In, Out] toEnsuring[Transformer[In, Out]] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- def ensuring(cond: Boolean): Transformer[In, Out]
- Implicit
- This member is added by an implicit conversion from Transformer[In, Out] toEnsuring[Transformer[In, Out]] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def filter(predicate: (Out) => Boolean): Transformer[In, Out]
Creates a new transformer which filters the outputs from this transformer.
Creates a new transformer which filters the outputs from this transformer.
- predicate
A function which decides whether an output from this transformer should be emitted from the returned transformer.
true
means emit,false
means skip.- returns
The filtered transformer
- def finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def formatted(fmtstr: String): String
- Implicit
- This member is added by an implicit conversion from Transformer[In, Out] toStringFormat[Transformer[In, Out]] performed by method StringFormat in scala.Predef.
- Definition Classes
- StringFormat
- Annotations
- @inline()
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def into[Out2](parser: Parser[Out, Out2]): Parser[In, Out2]
Attach this transformer to a
parser
, creating a new parser that encapsulates the pair.Attach this transformer to a
parser
, creating a new parser that encapsulates the pair. Values emitted from this transformer will be passed as inputs to theparser
, and the resulting output from theparser
will be yielded as output by the combined parser. - final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def map[Out2](f: (Out) => Out2): Transformer[In, Out2]
Creates a new transformer which applies the transformation function
f
to each of this transformer's outputs.Creates a new transformer which applies the transformation function
f
to each of this transformer's outputs.- Out2
The transformation output type
- f
A transformation function
- returns
The mapped transformer
- def mapFlatten[Out2](f: (Out) => Iterable[Out2]): Transformer[In, Out2]
Creates a new transformer which transforms the outputs of this transformer via the given function
f
, emitting each individual value from the output of that function in order before continuing.Creates a new transformer which transforms the outputs of this transformer via the given function
f
, emitting each individual value from the output of that function in order before continuing.- Out2
The transformed output type
- f
A function that transforms outputs from this transformer into a collection of other outputs
- returns
A new transformer which emits any number of transformed outputs based on outputs from this transformer
- def merge[In2 <: In, Out2 >: Out](that: Transformer[In2, Out2]): Transformer[In2, Out2]
Like
mergeEither
, but when both sides have a common output type.Like
mergeEither
, but when both sides have a common output type. This is a less-roundabout way of doing.mergeEither(right).map(_.merge)
. The same order-of-operations rules apply as withmergeEither
, where this transformer "goes first" for each input.- In2
Contravariance-friendly version of
In
- Out2
Common output type between
this
andthat
- that
Another transformer
- returns
The merged transformer
- def mergeEither[In2 <: In, Out2](right: Transformer[In2, Out2]): Transformer[In2, Either[Out, Out2]]
Creates a new transformer which sends inputs to both this transformer and the
right
transformer.Creates a new transformer which sends inputs to both this transformer and the
right
transformer. Whenever eitherthis
orright
emit a value, that value will be emitted from the returned transformer, wrapped as aLeft
orRight
depending on which underlying transformer emitted it. For each individual input, the resulting values emitted by this transformer will be emitted before the resulting values emitted by theright
transformer.- In2
Contravariance-friendly version of
In
- Out2
The output type of the
right
transformer- right
Another transformer
- returns
The merged transformer
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def parseAsFold[Out2](init: Out2)(f: (Out2, Out) => Out2): Parser[In, Out2]
Convenience for
this into Parser.fold(init)(f)
- def parseFirst(implicit A: TypeName[Out]): Parser[In, Out]
Convenience for
this into Parser.first
Convenience for
this into Parser.first
- Implicit
- This member is added by an implicit conversion from Transformer[In, Out] toTransformerParsingOps[In, Out] performed by method TransformerParsingOps in io.dylemma.spac.Transformer.
- Definition Classes
- TransformerParsingOps
- def parseFirstOpt: Parser[In, Option[Out]]
Convenience for
this into Parser.firstOpt
- def parseTap(f: (Out) => Unit): Parser[In, Unit]
Convenience for
this into Parser.tap(f)
- def parseToList: Parser[In, List[Out]]
Convenience for
this into Parser.toList
- def parseToMap: Parser[In, Map[K, V]]
Convenience for
this into Parser.toMap[K, V]
Convenience for
this into Parser.toMap[K, V]
- Implicit
- This member is added by an implicit conversion from Transformer[In, Out] toTransformerKVParsingOps[In, K, V] performed by method TransformerKVParsingOps in io.dylemma.spac.Transformer.This conversion will take place only if Out is a subclass of (K, V) (Out <: (K, V)).
- Definition Classes
- TransformerKVParsingOps
- def scan[Out2](init: Out2)(op: (Out2, Out) => Out2): Transformer[In, Out2]
Creates a new transformer which folds outputs from this transformer into a "state" which is emitted each time.
Creates a new transformer which folds outputs from this transformer into a "state" which is emitted each time.
- Out2
The type of the scan "state"
- init
The initial "state"
- op
State update function; this is called for each
Out
emitted by this transformer, and the result is emitted by the combined transformer in addition to becoming the next "state"- returns
The new transformer
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def through[Out2](next: Transformer[Out, Out2]): Transformer[In, Out2]
Attach this transformer to the
next
transformer, creating a single transformer that encapsulates the pair.Attach this transformer to the
next
transformer, creating a single transformer that encapsulates the pair. Values emitted from this transformer will be passed as inputs to thenext
transformer, and the resulting outputs from thenext
transformer are emitted as outputs from the combined transformer. - def toString(): String
- Definition Classes
- AnyRef → Any
- def transform(source: Source[In])(implicit pos: CallerPos): Source[Out]
Applies this transformer's logic to a Source, returning a new Source which yields values emitted by this transformer when run on the underlying iterator.
Applies this transformer's logic to a Source, returning a new Source which yields values emitted by this transformer when run on the underlying iterator.
- source
A Source
- pos
Captures the call site for the top level SpacTraceElement
- returns
A wrapped version of
source
, transformed via this transformer
- def transform(itr: Iterator[In])(implicit pos: CallerPos): Iterator[Out]
Applies this transformer's logic to an iterator, returning a new Iterator which yields values emitted by this transformer when run on the underlying
itr
.Applies this transformer's logic to an iterator, returning a new Iterator which yields values emitted by this transformer when run on the underlying
itr
.- itr
An iterator
- returns
A wrapped version of
itr
, transformed via this transformer
- def upcast[In2 <: In, Out2 >: Out]: Transformer[In2, Out2]
Returns this transformer, but with less restricted
In
/Out
types.Returns this transformer, but with less restricted
In
/Out
types.- In2
A subtype of
In
- Out2
A supertype of
Out
- returns
This transformer (not a copy, it's actually literally
this
)
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- def withFilter(predicate: (Out) => Boolean): Transformer[In, Out]
Alias for
filter
, used under the hood by for-comprehensionsAlias for
filter
, used under the hood by for-comprehensions- predicate
The filtering function
- returns
The filtered transformer
- def withName(name: String): Transformer[In, Out]
Creates a copy of this transformer, but with a different
toString
Creates a copy of this transformer, but with a different
toString
- name
The new "name" (i.e.
toString
for this transformer- returns
A copy of this transformer whose
toString
returns the givenname
Deprecated Value Members
- def >>[Out2](parser: Parser[Out, Out2]): Parser[In, Out2]
- Annotations
- @deprecated
- Deprecated
(Since version v0.9) Due to troubles with operator precedence and type inference, this operator is being phased out in favor of
into
- def >>[Out2](next: Transformer[Out, Out2]): Transformer[In, Out2]
- Annotations
- @deprecated
- Deprecated
(Since version v0.9) Due to troubles with operator precedence and type inference, this operator is being phased out in favor of
through
- def andThen[Out2](next: Transformer[Out, Out2]): Transformer[In, Out2]
- Annotations
- @deprecated
- Deprecated
(Since version v0.9) This method is being renamed to
through
- def parallel[In2 <: In, Out2 >: Out](that: Transformer[In2, Out2]): Transformer[In2, Out2]
- Annotations
- @deprecated
- Deprecated
(Since version v0.9) This method is being renamed to
merge
- def parallelEither[In2 <: In, Out2](right: Transformer[In2, Out2]): Transformer[In2, Either[Out, Out2]]
- Annotations
- @deprecated
- Deprecated
(Since version v0.9) This method is being renamed to
mergeEither
- def parseFirstOption: Parser[In, Option[Out]]
- Annotations
- @deprecated
- Deprecated
(Since version v0.9) This method is being renamed to
parseFirstOpt
- def parseForeach(f: (Out) => Any): Parser[In, Unit]
- Annotations
- @deprecated
- Deprecated
(Since version v0.9) This method is being renamed to
parseTap
- def parseWith[Out2](parser: Parser[Out, Out2], setDebugName: Option[String]): Parser[In, Out2]
- Annotations
- @deprecated
- Deprecated
(Since version v0.9) Use the single-argument version of
into
, then callwithName
on the resulting parser
- def parseWith[Out2](parser: Parser[Out, Out2]): Parser[In, Out2]
- Annotations
- @deprecated
- Deprecated
(Since version v0.9) Use
into
instead
- def sink: Parser[In, Unit]
- Annotations
- @deprecated
- Deprecated
(Since version v0.9) This method is being renamed to
drain
- def →[B](y: B): (Transformer[In, Out], B)
- Implicit
- This member is added by an implicit conversion from Transformer[In, Out] toArrowAssoc[Transformer[In, Out]] performed by method ArrowAssoc in scala.Predef.This conversion will take place only if Out is a subclass of (Nothing, Nothing) (Out <: (Nothing, Nothing)).
- Definition Classes
- ArrowAssoc
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use
->
instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.