/** * . * The camel case version of the string with the first letter in lower case * * @param str The string * @param lowerCaseFirstLetter Whether the first letter is in upper case or lower case * @return The new string in camel case */ public static String camelCase(String str, boolean lowerCaseFirstLetter) { String result = Arrays.stream(str.split("[\\s_-]")).map(NameUtils::capitalize).collect(Collectors.joining("")); if (lowerCaseFirstLetter) { return decapitalize(result); } return result; }
/** * 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); }
/** * Get the equivalent property name for the given setter. * * @param setterName The setter * @return The property name */ public static String getPropertyNameForSetter(String setterName) { if (isSetterName(setterName)) { return decapitalize(setterName.substring(PREFIX_LENTGH)); } return setterName; }
/** * Get the equivalent property name for the given getter. * * @param getterName The getter * @return The property name */ public static String getPropertyNameForGetter(String getterName) { if (isGetterName(getterName)) { int prefixLength = 0; if (getterName.startsWith("get")) { prefixLength = PREFIX_LENTGH; } if (getterName.startsWith("is")) { prefixLength = IS_LENTGH; } return decapitalize(getterName.substring(prefixLength)); } return getterName; }
/** * Creates a new argument for the given type and name. * * @param type The type * @param typeParameters The parameters type * @param <T> The generic type * @return The argument instance */ @UsedByGeneratedCode static <T> Argument<T> of( Class<T> type, @Nullable Argument... typeParameters) { return new DefaultArgument<>(type, NameUtils.decapitalize(type.getSimpleName()), AnnotationMetadata.EMPTY_METADATA, typeParameters); }
/** * Creates a new argument for the given type and name. * * @param type The type * @param <T> The generic type * @return The argument instance */ @UsedByGeneratedCode static <T> Argument<T> of( Class<T> type) { return new DefaultArgument<>(type, NameUtils.decapitalize(type.getSimpleName()), AnnotationMetadata.EMPTY_METADATA, Argument.ZERO_ARGUMENTS); }
name = NameUtils.decapitalize(this.type.getSimpleName());
propertyName = decapitalize(methodName.substring(PREFIX_SET.length()));
propertyName = decapitalize(methodName.substring(prefixLength));
/** * Creates a new argument for the given type and name. * * @param type The type * @param typeParameters the parameters type * @param <T> The generic type * @return The argument instance */ @UsedByGeneratedCode static <T> Argument<T> of(Class<T> type, @Nullable Class<?>... typeParameters) { if (typeParameters == null) { return of(type); } TypeVariable<Class<T>>[] parameters = type.getTypeParameters(); int len = typeParameters.length; if (parameters.length != len) { throw new IllegalArgumentException("Type parameter length does not match. Required: " + parameters.length + ", Specified: " + len); } Argument[] typeArguments = new Argument[len]; for (int i = 0; i < parameters.length; i++) { TypeVariable<Class<T>> parameter = parameters[i]; typeArguments[i] = Argument.of(typeParameters[i], parameter.getName()); } return new DefaultArgument<>(type, NameUtils.decapitalize(type.getSimpleName()), AnnotationMetadata.EMPTY_METADATA, typeArguments); }
/** * Resolve the URI to use for the given type. * * @param property The property * @return The URI to use */ default String resolveUri(String property) { if (StringUtils.isEmpty(property)) { return "/"; } if (property.charAt(0) != '/') { return '/' + NameUtils.decapitalize(property); } return property; }
/** * 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); }
@Override public Optional<Object> convert(Map map, Class<Object> targetType, ConversionContext context) { return InstantiationUtils .tryInstantiate(targetType) .map(object -> { Map<?, ?> theMap = map; Map bindMap = new LinkedHashMap(map.size()); for (Map.Entry<?, ?> entry : theMap.entrySet()) { Object key = entry.getKey(); bindMap.put(NameUtils.decapitalize(NameUtils.dehyphenate(key.toString())), entry.getValue()); } return beanPropertyBinder.bind(object, bindMap); } ); } }
name = path.get(path.size() - 1).getFieldName(); } else { name = NameUtils.decapitalize(type.getSimpleName());
GeneratorAdapter injectMethodVisitor = this.injectMethodVisitor; String propertyName = NameUtils.hyphenate(NameUtils.decapitalize(methodName.substring(prefix.length())), true);
GeneratorAdapter injectMethodVisitor = this.injectMethodVisitor; String propertyName = NameUtils.hyphenate(NameUtils.decapitalize(methodName.substring(prefix.length())), true);