/** * Format the string with this format. * * @param str The string * @return The formatted string */ public String format(String str) { return StringConvention.format(this, str); }
/** * Default constructor. */ PropertyConvention() { this.lowerCase = name().toLowerCase(Locale.ENGLISH); }
/** * 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()); }
@Override public String resolveUri(Class type) { return '/' + TypeConvention.CONTROLLER.asHyphenatedName(type); }
/** * 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(); } } }
/** * Default constructor. */ TypeConvention() { this.suffix = NameUtils.capitalize(name().toLowerCase(Locale.ENGLISH)); }
/** * Resolve the URI to use for the given type and route id. * * @param type The type * @param id the route id * @return The URI to use */ default String resolveUri(Class type, PropertyConvention id) { return resolveUri(type) + "/{" + id.lowerCaseName() + "}"; }
/** * 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()); }
/** * @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); }
@Override public String resolveUri(Class type) { return '/' + TypeConvention.CONTROLLER.asHyphenatedName(type); }
/** * 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()); }
/** * 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 class. The URI route is built by the configured {@link UriNamingStrategy}.</p> * * @param type The class * @return The route */ default UriRoute DELETE(Class type) { return DELETE(getUriNamingStrategy().resolveUri(type), type, 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()); }
/** * <p>Route to the specified class and ID. The URI route is built by the configured {@link UriNamingStrategy}.</p> * * @param type The class * @param id The route id * @return The route */ default UriRoute GET(Class type, PropertyConvention id) { return GET(getUriNamingStrategy().resolveUri(type, id), type, MethodConvention.SHOW.methodName(), Object.class); }