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

com.github.dreamhead.moco.rest.CompositeRestSetting Maven / Gradle / Ivy

package com.github.dreamhead.moco.rest;

import com.github.dreamhead.moco.HttpRequest;
import com.github.dreamhead.moco.ResponseHandler;
import com.github.dreamhead.moco.RestIdMatcher;
import com.github.dreamhead.moco.RestSetting;
import com.google.common.base.Optional;

public final class CompositeRestSetting implements RestSetting {
    private final Iterable settings;

    public CompositeRestSetting(final Iterable settings) {
        this.settings = settings;
    }

    @Override
    public boolean isSimple() {
        return false;
    }

    @Override
    public Optional getMatched(final RestIdMatcher resourceName, final HttpRequest httpRequest) {
        for (RestSetting setting : settings) {
            Optional responseHandler = setting.getMatched(resourceName, httpRequest);
            if (responseHandler.isPresent()) {
                return responseHandler;
            }
        }

        return Optional.absent();
    }

    public Iterable getSettings() {
        return settings;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy