/** * Converts class name to property name using JavaBean decapitalization. * * @param name The class name * @param suffixes The suffix to remove * @return The decapitalized name */ public static String decapitalizeWithoutSuffix(String name, String... suffixes) { String decapitalized = decapitalize(name); return trimSuffix(decapitalized, suffixes); }
/** * <p>Returns the hyphenated equivalent for this convention for the given class. Eg. BookShopController -> book-shop</p> * * @param type The type * @return The property name equivalent */ public String asHyphenatedName(Class type) { String shortName = NameUtils.trimSuffix(type.getSimpleName(), suffix); return NameUtils.hyphenate(shortName); }
/** * Register a route to handle the error. * * @param error The error * @param type The type * @return The route */ default ErrorRoute error(Class<? extends Throwable> error, Class type) { return error(error, type, NameUtils.decapitalize(NameUtils.trimSuffix(type.getSimpleName(), "Exception", "Error")), ReflectionUtils.EMPTY_CLASS_ARRAY); }
/** * Register a route to handle the error. * * @param error The error * @param instance The instance * @return The route */ default ErrorRoute error(Class<? extends Throwable> error, Object instance) { return error( error, instance.getClass(), NameUtils.decapitalize(NameUtils.trimSuffix(error.getSimpleName(), "Exception", "Error")), error); }