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

io.github.mike10004.harreplay.vhsimpl.CompositeEntryMatcher Maven / Gradle / Ivy

The newest version!
package io.github.mike10004.harreplay.vhsimpl;

import com.google.common.collect.ImmutableList;
import io.github.mike10004.vhs.EntryMatcher;
import io.github.mike10004.vhs.HttpRespondable;
import io.github.mike10004.vhs.harbridge.ParsedRequest;

import javax.annotation.Nullable;

public class CompositeEntryMatcher implements EntryMatcher {

    private final ImmutableList> components;

    public CompositeEntryMatcher(Iterable> components) {
        this.components = ImmutableList.copyOf(components);
    }

    @Nullable
    @Override
    public HttpRespondable findTopEntry(S state, ParsedRequest request) {
        for (EntryMatcher component : components) {
            HttpRespondable respondable = component.findTopEntry(state, request);
            if (respondable != null) {
                return respondable;
            }
        }
        return null;
    }

}