Add missing requireNotNull in WorkProcessorUtils
@@ -39,6 +39,7 @@ public final class WorkProcessorUtils
static <T> Iterator<T> iteratorFrom(WorkProcessor<T> processor)
{
+ requireNonNull(processor, "processor is null");
return new AbstractIterator<T>()
{
final Iterator<Optional<T>> yieldingIterator = yieldingIteratorFrom(processor);
@@ -83,6 +84,7 @@ public final class WorkProcessorUtils
static <T> WorkProcessor<T> fromIterator(Iterator<T> iterator)
{
+ requireNonNull(iterator, "iterator is null");
return create(() -> {
if (!iterator.hasNext()) {
return ProcessorState.finished();
@@ -138,6 +140,8 @@ public final class WorkProcessorUtils
static <T, R> WorkProcessor<R> flatMap(WorkProcessor<T> processor, Function<T, WorkProcessor<R>> mapper)
{
+ requireNonNull(processor, "processor is null");
+ requireNonNull(mapper, "mapper is null");
return processor.flatTransform(elementOptional ->
elementOptional
.map(element -> ProcessorState.ofResult(mapper.apply(element)))
@@ -146,6 +150,8 @@ public final class WorkProcessorUtils
static <T, R> WorkProcessor<R> map(WorkProcessor<T> processor, Function<T, R> mapper)
{
+ requireNonNull(processor, "processor is null");
+ requireNonNull(mapper, "mapper is null");
return processor.transform(elementOptional ->
elementOptional
.map(element -> ProcessorState.ofResult(mapper.apply(element)))
@@ -154,6 +160,8 @@ public final class WorkProcessorUtils
static <T, R> WorkProcessor<R> flatTransform(WorkProcessor<T> processor, Transformation<T, WorkProcessor<R>> transformation)
{
+ requireNonNull(processor, "processor is null");
+ requireNonNull(transformation, "transformation is null");
return processor.transform(new Transformation<T, R>()
{
WorkProcessor<R> processor;
@@ -195,6 +203,8 @@ public final class WorkProcessorUtils
static <T, R> WorkProcessor<R> transform(WorkProcessor<T> processor, Transformation<T, R> transformation)
{
+ requireNonNull(processor, "processor is null");
+ requireNonNull(transformation, "transformation is null");
return create(new WorkProcessor.Process<R>()
{
Optional<T> element = Optional.empty();
@@ -236,6 +246,7 @@ public final class WorkProcessorUtils
static <T> WorkProcessor<T> create(WorkProcessor.Process<T> process)
{
+ requireNonNull(process, "process is null");
return new WorkProcessor<T>()
{
ProcessorState<T> state;
