com.fireflysource.net.http.server.RouterManager Maven / Gradle / Ivy
package com.fireflysource.net.http.server;
import java.util.*;
public interface RouterManager {
class RouterMatchResult implements Comparable {
private final Router router;
private final Map parameters;
private final Set matchTypes;
public RouterMatchResult(Router router, Map parameters, Set matchTypes) {
this.router = router;
this.parameters = Collections.unmodifiableMap(parameters);
this.matchTypes = Collections.unmodifiableSet(matchTypes);
}
public Router getRouter() {
return router;
}
public Map getParameters() {
return parameters;
}
public Set getMatchTypes() {
return matchTypes;
}
@Override
public int compareTo(RouterMatchResult o) {
return router.compareTo(o.getRouter());
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
RouterMatchResult that = (RouterMatchResult) o;
return Objects.equals(router, that.router);
}
@Override
public int hashCode() {
return Objects.hash(router);
}
}
/**
* Register a router using automatic increase id.
*
* @return The new router.
*/
Router register();
/**
* Register a router.
*
* @param id The router id.
* @return The new router.
*/
Router register(Integer id);
/**
* Find routers.
*
* @param context The routing context.
* @return The registered routers.
*/
SortedSet findRouters(RoutingContext context);
}