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

com.fireflysource.net.http.server.RouterManager Maven / Gradle / Ivy

There is a newer version: 5.0.2
Show newest version
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);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy