    001    package com.hammurapi.eventbus;
    002
    003    /**
    004     * Composite inference filter consists of several inference filters which are invoked one after another.
    005     * @author Pavel Vlasov
    006     */
    007    public class CompositeInferenceFilter<E, P extends Comparable<P>, C, K, H extends EventBus.Handle<E,P,C>, S extends EventStore<E,P,C,H,S>> implements InferenceFilter<E,P,C,K,H,S> {
    008
    009            private InferenceFilter<E, P, C, K, H, S>[] parts;
    010
    011            public CompositeInferenceFilter(InferenceFilter<E,P,C,K,H,S>... parts) {
    012                    this.parts = parts;
    013            }
    014
    015            public boolean accept(InferenceCommand<E,P,C,K,H,S> inferenceCommand, EventBus<E,P,C,K,H,S> bus) {
    016                    for (InferenceFilter<E,P,C,K,H,S> filter: parts) {
    017                            if (!filter.accept(inferenceCommand, bus)) {
    018                                    return false;
    019                            }
    020                    }
    021                    return true;
    022            }
    023    }