com.redis.spring.batch.util.PredicateItemProcessor Maven / Gradle / Ivy
package com.redis.spring.batch.util;
import java.util.function.Predicate;
import org.springframework.batch.item.ItemProcessor;
/**
* ItemProcessor that only keeps items that match the given predicate., i.e. a given item is kept only if predicate.test(item)
* == true.
*
* @param
*/
public class PredicateItemProcessor implements ItemProcessor {
private final Predicate predicate;
public PredicateItemProcessor(Predicate predicate) {
this.predicate = predicate;
}
@Override
public T process(T item) throws Exception {
return predicate.test(item) ? item : null;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy