Class DefaultRouter

java.lang.Object
dev.voidframework.web.routing.impl.DefaultRouter
All Implemented Interfaces:
Router, RouterPostInitialization

public class DefaultRouter extends Object implements Router, RouterPostInitialization
Default implementation of Router.
  • Constructor Details

    • DefaultRouter

      public DefaultRouter()
      Build a new instance.
  • Method Details

    • addRoute

      public void addRoute(HttpMethod httpMethod, String routeUrl, Class<?> controllerClassType, Method method)
      Description copied from interface: Router
      Adds a new route.
      Specified by:
      addRoute in interface Router
      Parameters:
      httpMethod - The HTTP method (ie: GET)
      routeUrl - The route url
      controllerClassType - The controller class type
      method - The method to call
    • addRoute

      public void addRoute(HttpMethod httpMethod, String routeUrl, Class<?> controllerClassType, Method method, String name)
      Description copied from interface: Router
      Adds a new route.
      Specified by:
      addRoute in interface Router
      Parameters:
      httpMethod - The HTTP method (ie: GET)
      routeUrl - The route url
      controllerClassType - The controller class type
      method - The method to call
      name - The route name
    • resolveRoute

      public ResolvedRoute resolveRoute(HttpMethod httpMethod, String uri)
      Description copied from interface: Router
      Resolves a route.
      Specified by:
      resolveRoute in interface Router
      Parameters:
      httpMethod - The HTTP method (ie: GET)
      uri - The URI to parse to resolve route
      Returns:
      The resolved route, otherwise, null
    • reverseRoute

      public String reverseRoute(String name)
      Description copied from interface: Router
      Reverses a route to obtains a URL.
      Specified by:
      reverseRoute in interface Router
      Parameters:
      name - The route name
      Returns:
      A string containing a URL
    • reverseRoute

      public String reverseRoute(String name, List<Object> parameterList)
      Description copied from interface: Router
      Reverses a route to obtains a URL.
      Specified by:
      reverseRoute in interface Router
      Parameters:
      name - The route name
      parameterList - The parameters to use
      Returns:
      A string containing a URL
    • getRoutesAsList

      public List<Route> getRoutesAsList()
      Description copied from interface: Router
      Retrieves all registered routes.
      Specified by:
      getRoutesAsList in interface Router
      Returns:
      All registered routes as List
    • getRoutesAsMap

      public Map<HttpMethod,List<Route>> getRoutesAsMap()
      Description copied from interface: Router
      Retrieves all registered routes.
      Specified by:
      getRoutesAsMap in interface Router
      Returns:
      All registered routes as Map
    • onPostInitialization

      public void onPostInitialization()
      Description copied from interface: RouterPostInitialization
      This method will be called after all routes has been discovered and registered.
      Specified by:
      onPostInitialization in interface RouterPostInitialization