org.baswell.routes
Class RouteByHttpMethodNameConvention

java.lang.Object
  extended by org.baswell.routes.RouteByHttpMethodNameConvention
All Implemented Interfaces:
RouteByConvention
Direct Known Subclasses:
RouteByCamelCaseConvention, RouteByLowercaseConvention

public abstract class RouteByHttpMethodNameConvention
extends java.lang.Object
implements RouteByConvention

Base class RouteByConvention that provides an implementation for respondsToMethods. The HTTP method names are taken from the beginning of the method name (case insensitive). If the method name doesn't start with any HTTP methods then the methods [GET, POST, PUT, DELETE] are used.

For example:

Method Name Route HTTP Methods
getMyResource GET
getPostMyResource GET, POST
getPostDeleteAnotherThing GET, POST, DELETE
doSomething GET, POST, PUT, DELETE


Constructor Summary
RouteByHttpMethodNameConvention()
           
 
Method Summary
protected  java.lang.String removeHttpMethodsFromName(java.lang.reflect.Method method)
          Removes any of the HTTP method names GET, POST, PUT, DELETE, HEAD (case insensitive) from the beginning of this method name if the given method does not have a Route.respondsToMethods() specified.
 java.lang.String removeRoutesControllerHandlerFromName(java.lang.Class clazz)
          Removes any of the following words from the very end of the given class name.
 java.util.List<HttpMethod> respondsToMethods(java.lang.reflect.Method routeMethod)
          The HTTP method names are taken from the beginning of the method name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.baswell.routes.RouteByConvention
routePath, routesPathPrefix
 

Constructor Detail

RouteByHttpMethodNameConvention

public RouteByHttpMethodNameConvention()
Method Detail

respondsToMethods

public java.util.List<HttpMethod> respondsToMethods(java.lang.reflect.Method routeMethod)
The HTTP method names are taken from the beginning of the method name. If the method name doesn't start with any HTTP methods then the methods [GET, POST, PUT, DELETE] are used.

Specified by:
respondsToMethods in interface RouteByConvention
Parameters:
routeMethod -
Returns:
The HTTP methods this method specifies from its name.

removeRoutesControllerHandlerFromName

public java.lang.String removeRoutesControllerHandlerFromName(java.lang.Class clazz)
Removes any of the following words from the very end of the given class name.

Parameters:
clazz -
Returns:
The class name with the above words removed from the end.
See Also:
RouteByConvention.routesPathPrefix(Class)

removeHttpMethodsFromName

protected java.lang.String removeHttpMethodsFromName(java.lang.reflect.Method method)
Removes any of the HTTP method names GET, POST, PUT, DELETE, HEAD (case insensitive) from the beginning of this method name if the given method does not have a Route.respondsToMethods() specified. If respondsToMethods is specified the method name is returned unaltered.

Parameters:
method -
Returns:
The method name minus the HTTP method names at the beginning.
See Also:
RouteByConvention.routePath(java.lang.reflect.Method)