eu.toolchain.rs.RsMapping Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tiny-rs-api Show documentation
Show all versions of tiny-rs-api Show documentation
A tiny restful framework for Java (API)
package eu.toolchain.rs;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;
public class RsMapping {
private final String method;
private final List path;
private final Function handle;
private final List consumes;
private final List produces;
private RsMapping(final String method, final List path,
final Function handle, final List consumes,
final List produces) {
this.method = Objects.requireNonNull(method);
this.path = Objects.requireNonNull(path);
this.handle = Objects.requireNonNull(handle);
this.consumes = Objects.requireNonNull(consumes);
this.produces = Objects.requireNonNull(produces);
}
public String method() {
return method;
}
public List path() {
return path;
}
public Function handle() {
return handle;
}
public List consumes() {
return consumes;
}
public List produces() {
return produces;
}
public static Builder builder() {
return new Builder();
}
public static class Builder {
private String method;
private List path = Collections.emptyList();
private Function handle;
private List consumes = Collections.emptyList();
private List produces = Collections.emptyList();
public Builder method(final String method) {
this.method = Objects.requireNonNull(method);
return this;
}
public Builder path(final String... path) {
this.path = toList(path);
return this;
}
public Builder handle(final Function handle) {
this.handle = Objects.requireNonNull(handle);
return this;
}
public Builder consumes(final String... consumes) {
this.consumes = toList(consumes);
return this;
}
public Builder produces(final String... produces) {
this.produces = toList(produces);
return this;
}
public RsMapping build() {
return new RsMapping(method, path, handle, consumes, produces);
}
private List toList(final I[] input) {
final List list = new ArrayList<>();
for (final I i : input) {
list.add(i);
}
return Collections.unmodifiableList(list);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy