reactor.groovy.ext.ProcessorExtensions.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of reactor-groovy-extensions Show documentation
Show all versions of reactor-groovy-extensions Show documentation
Reactor Groovy Ext components
The newest version!
package reactor.groovy.ext
import groovy.transform.CompileStatic
import reactor.core.processor.spec.ProcessorSpec
import reactor.groovy.support.ClosureConsumer
import reactor.groovy.support.ClosureSupplier
/**
* Groovy extension module for {@link ProcessorSpec}.
*
* @author Jon Brisbin
*/
@CompileStatic
class ProcessorExtensions {
/**
* Provide a {@link Closure} as a {@code dataSupplier}.
*
* @param selfType
* @param closure
* @return
*/
static ProcessorSpec dataSupplier(ProcessorSpec selfType, Closure closure) {
selfType.dataSupplier(new ClosureSupplier(closure))
}
/**
* Provide a {@link Closure} as a {@link reactor.function.Consumer}.
*
* @param selfType
* @param closure
* @return
*/
static ProcessorSpec consume(ProcessorSpec selfType, Closure closure) {
selfType.consume(new ClosureConsumer(closure))
}
/**
* Provide a {@link Closure} as an error {@link reactor.function.Consumer}.
*
* @param selfType
* @param closure
* @return
*/
static ProcessorSpec when(ProcessorSpec selfType, Class type, Closure closure) {
selfType.when(type, new ClosureConsumer(closure))
}
}