All Downloads are FREE. Search and download functionalities are using the official Maven repository.

reactor.groovy.ext.ProcessorExtensions.groovy Maven / Gradle / Ivy

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))
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy