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

com.redis.spring.batch.util.PredicateItemProcessor Maven / Gradle / Ivy

There is a newer version: 4.0.7
Show newest version
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