org.zalando.riptide.PartialBinding Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of riptide-core Show documentation
Show all versions of riptide-core Show documentation
Client side response routing
The newest version!
package org.zalando.riptide;
import com.google.common.reflect.TypeToken;
import org.apiguardian.api.API;
import org.springframework.http.client.ClientHttpResponse;
import org.zalando.fauxpas.ThrowingConsumer;
import org.zalando.fauxpas.ThrowingRunnable;
import javax.annotation.Nullable;
import static org.apiguardian.api.API.Status.STABLE;
/**
* A partial {@link Binding binding} that already has an attribute associated but is missing a {@link Route route}.
* The functionality provided by this class is just syntactic sugar. Clients could use
* {@link Binding#create(Object, Route)} directly.
*
* @see Binding#create(Object, Route)
* @param generic attribute.
*/
@API(status = STABLE)
public final class PartialBinding {
private final A attribute;
PartialBinding(@Nullable final A attribute) {
this.attribute = attribute;
}
public Binding call(final ThrowingRunnable extends Exception> consumer) {
return call(Route.call(consumer));
}
public Binding call(final ThrowingConsumer consumer) {
return call(Route.call(consumer));
}
public Binding call(final Class type, final ThrowingConsumer consumer) {
return call(Route.call(type, consumer));
}
public Binding call(final TypeToken type, final ThrowingConsumer consumer) {
return call(Route.call(type, consumer));
}
@SafeVarargs
public final Binding dispatch(final Navigator navigator, final Binding... bindings) {
return call(RoutingTree.dispatch(navigator, bindings));
}
public Binding call(final Route route) {
return Binding.create(attribute, route);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy