/** * Obtain the method convention for the given method. * * @param name The method name * @return An optional of the method convention */ public static Optional<MethodConvention> forMethod(String name) { try { return Optional.of(valueOf(name.toUpperCase(Locale.ENGLISH))); } catch (IllegalArgumentException e) { return Optional.empty(); } } }
/** * Route the specified URI to the specified target for an HTTP PATCH. Since the method to execute is not * specified "index" is used by default. * * @param uri The URI * @param target The target object * @return The route */ default UriRoute PATCH(String uri, Object target) { return PATCH(uri, target, MethodConvention.UPDATE.methodName()); }
/** * Route the specified URI to the specified target for an HTTP GET. Since the method to execute is not * specified "index" is used by default. * * @param uri The URI * @param target The target object * @return The route */ default UriRoute HEAD(String uri, Object target) { return HEAD(uri, target, MethodConvention.HEAD.methodName()); }
/** * Route the specified URI to the specified target for an HTTP GET. Since the method to execute is not * specified "index" is used by default. * * @param uri The URI * @param target The target object * @return The route */ default UriRoute TRACE(String uri, Object target) { return TRACE(uri, target, MethodConvention.TRACE.methodName()); }
/** * @param uri The URI * @param httpMethod The Http method */ MethodConvention(String uri, String httpMethod) { this.uri = uri; this.httpMethod = httpMethod; this.lowerCase = name().toLowerCase(Locale.ENGLISH); }
/** * Route the specified URI to the specified target for an HTTP OPTIONS. Since the method to execute is not * specified "index" is used by default. * * @param uri The URI * @param target The target object * @return The route */ default UriRoute OPTIONS(String uri, Object target) { return OPTIONS(uri, target, MethodConvention.OPTIONS.methodName()); }
/** * Route the specified URI to the specified target for an HTTP GET. Since the method to execute is not * specified "index" is used by default. * * @param uri The URI * @param target The target object * @return The route */ default UriRoute GET(String uri, Object target) { return GET(uri, target, MethodConvention.INDEX.methodName()); }
/** * Route the specified URI to the specified target for an HTTP POST. Since the method to execute is not * specified "index" is used by default. * * @param uri The URI * @param target The target object * @param parameterTypes The parameter types for the target method * @return The route */ default UriRoute POST(String uri, Object target, Class... parameterTypes) { return POST(uri, target, MethodConvention.SAVE.methodName(), parameterTypes); }
/** * Route the specified URI to the specified target for an HTTP PUT. Since the method to execute is not * specified "index" is used by default. * * @param uri The URI * @param target The target object * @return The route */ default UriRoute PUT(String uri, Object target) { return PUT(uri, target, MethodConvention.UPDATE.methodName()); }
/** * Route the specified URI to the specified target for an HTTP DELETE. Since the method to execute is not * specified "index" is used by default. * * @param uri The URI * @param target The target object * @return The route */ default UriRoute DELETE(String uri, Object target) { return DELETE(uri, target, MethodConvention.DELETE.methodName(), Object.class); }
/** * <p>Route to the specified object and ID. The URI route is built by the configured {@link UriNamingStrategy}.</p> * * @param target The object * @param id The route id * @return The route */ default UriRoute PATCH(Object target, PropertyConvention id) { Class<?> type = target.getClass(); return PATCH(getUriNamingStrategy().resolveUri(type, id), target, MethodConvention.UPDATE.methodName(), Object.class); }
/** * <p>Route to the specified object and ID. The URI route is built by the configured {@link UriNamingStrategy}.</p> * * @param target The object * @param id The route id * @return The route */ default UriRoute TRACE(Object target, PropertyConvention id) { Class<?> type = target.getClass(); return TRACE(getUriNamingStrategy().resolveUri(type, id), target, MethodConvention.TRACE.methodName()); }
/** * <p>Route to the specified object and ID. The URI route is built by the configured {@link UriNamingStrategy}.</p> * * @param target The object * @param id The route id * @return The route */ default UriRoute PUT(Object target, PropertyConvention id) { Class<?> type = target.getClass(); return PUT(getUriNamingStrategy().resolveUri(type, id), target, MethodConvention.UPDATE.methodName(), Object.class); }
/** * <p>Route to the specified object and ID. The URI route is built by the configured {@link UriNamingStrategy}.</p> * * @param target The object * @param id The route id * @return The route */ default UriRoute OPTIONS(Object target, PropertyConvention id) { Class<?> type = target.getClass(); return OPTIONS(getUriNamingStrategy().resolveUri(type, id), target, MethodConvention.OPTIONS.methodName()); }
/** * <p>Route to the specified object and ID. The URI route is built by the configured {@link UriNamingStrategy}.</p> * * @param target The object * @param id The route id * @return The route */ default UriRoute HEAD(Object target, PropertyConvention id) { Class<?> type = target.getClass(); return HEAD(getUriNamingStrategy().resolveUri(type, id), target, MethodConvention.HEAD.methodName()); }
/** * <p>Route to the specified object and ID. The URI route is built by the configured {@link UriNamingStrategy}.</p> * * @param target The object * @param id The route id * @return The route */ default UriRoute GET(Object target, PropertyConvention id) { Class<?> type = target.getClass(); return GET(getUriNamingStrategy().resolveUri(type, id), target, MethodConvention.SHOW.methodName(), Object.class); }
/** * <p>Route to the specified object and ID. The URI route is built by the configured {@link UriNamingStrategy}.</p> * * @param target The object * @param id The route id * @return The route */ default UriRoute POST(Object target, PropertyConvention id) { Class<?> type = target.getClass(); return POST(getUriNamingStrategy().resolveUri(type, id), target, MethodConvention.UPDATE.methodName()); }
/** * <p>Route to the specified object and ID. The URI route is built by the configured {@link UriNamingStrategy}.</p> * * @param target The object * @param id The route id * @return The route */ default UriRoute DELETE(Object target, PropertyConvention id) { Class<?> type = target.getClass(); return DELETE(getUriNamingStrategy().resolveUri(type, id), target, MethodConvention.DELETE.methodName(), Object.class); }
/** * <p>Route to the specified class. The URI route is built by the configured {@link UriNamingStrategy}.</p> * * @param type The class * @return The route */ default UriRoute GET(Class type) { return GET(getUriNamingStrategy().resolveUri(type), type, MethodConvention.INDEX.methodName()); }