
com.speedment.runtime.field.internal.predicate.ComposedPredicateImpl Maven / Gradle / Ivy
package com.speedment.runtime.field.internal.predicate;
import com.speedment.runtime.field.predicate.ComposedPredicate;
import com.speedment.runtime.field.predicate.SpeedmentPredicate;
import java.util.function.Function;
import static java.util.Objects.requireNonNull;
/**
* Default implementation of the {@link ComposedPredicate}
*
* @author Emil Forslund
* @since 3.1.2
*/
public class ComposedPredicateImpl implements ComposedPredicate {
private final Function super T, ? extends A> firstStep;
private final SpeedmentPredicate secondStep;
public ComposedPredicateImpl(Function super T, ? extends A> firstStep,
SpeedmentPredicate secondStep) {
this.firstStep = requireNonNull(firstStep);
this.secondStep = requireNonNull(secondStep);
}
@Override
public Function firstStep() {
@SuppressWarnings("unchecked")
final Function function = (Function) firstStep;
return function;
}
@Override
public SpeedmentPredicate secondStep() {
return secondStep;
}
@Override
public boolean applyAsBoolean(T object) {
return secondStep.applyAsBoolean(firstStep.apply(object));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy