com.github.dreamhead.moco.rest.CompositeRestSetting Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of moco-core Show documentation
Show all versions of moco-core Show documentation
Moco is an easy setup stub framework, mainly focusing on testing and integration.
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 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;
}
}