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

org.joo.libra.sql.functional.AllMatchPredicate Maven / Gradle / Ivy

There is a newer version: 2.1.2
Show newest version
package org.joo.libra.sql.functional;

import java.util.Arrays;
import java.util.Collection;

import org.joo.libra.Predicate;
import org.joo.libra.PredicateContext;
import org.joo.libra.common.HasValue;

public class AllMatchPredicate extends AbstractFunctionalMatchPredicate {

	public AllMatchPredicate(HasValue list, String indexName, Predicate conditionPredicate) {
		super(list, indexName, conditionPredicate);
	}

	@Override
	protected boolean satisfiesAsCollection(Collection listValue, PredicateContext context) {
		return listValue.stream().allMatch(value -> satisfiedBy(value, context));
	}

	@Override
	protected boolean satisfiesAsArray(Object[] listValue, PredicateContext context) {
		return Arrays.stream(listValue).allMatch(value -> satisfiedBy(value, context));
	}
}