/** * Checks whether the type is a wrapper without unwrapping support. Reactive wrappers don't like to be unwrapped. * * @param parameterType must not be {@literal null}. * @return */ private static boolean isNonUnwrappingWrapper(Class<?> parameterType) { Assert.notNull(parameterType, "Parameter type must not be null!"); return QueryExecutionConverters.supports(parameterType) && !QueryExecutionConverters.supportsUnwrapping(parameterType); }
/** * Returns whether the {@link MethodParameter} is wrapped in a wrapper type. * * @param parameter must not be {@literal null}. * @see QueryExecutionConverters */ private static boolean isWrapped(MethodParameter parameter) { return QueryExecutionConverters.supports(parameter.getParameterType()); }
/** * Checks whether the type is a wrapper without unwrapping support. Reactive wrappers don't like to be unwrapped. * * @param parameterType must not be {@literal null}. * @return */ private static boolean isNonUnwrappingWrapper(Class<?> parameterType) { Assert.notNull(parameterType, "Parameter type must not be null!"); return QueryExecutionConverters.supports(parameterType) && !QueryExecutionConverters.supportsUnwrapping(parameterType); }
/** * Returns whether the {@link MethodParameter} is wrapped in a wrapper type. * * @param parameter must not be {@literal null}. * @return * @see QueryExecutionConverters */ private static boolean isWrapped(MethodParameter parameter) { return QueryExecutionConverters.supports(parameter.getParameterType()); }
/** * Checks whether the type is a wrapper without unwrapping support. Reactive wrappers don't like to be unwrapped. * * @param parameterType must not be {@literal null}. * @return */ private static boolean isNonUnwrappingWrapper(Class<?> parameterType) { Assert.notNull(parameterType, "Parameter type must not be null!"); return QueryExecutionConverters.supports(parameterType) && !QueryExecutionConverters.supportsUnwrapping(parameterType); }
/** * Unwraps the given source value in case it's one of the currently supported wrapper types detected at runtime. * * @param source can be {@literal null}. * @return */ @Nullable public static Object unwrap(@Nullable Object source) { if (source == null || !supports(source.getClass())) { return source; } for (Converter<Object, Object> converter : UNWRAPPERS) { Object result = converter.convert(source); if (result != source) { return result; } } return source; }
/** * Checks whether the type is a wrapper without unwrapping support. Reactive wrappers don't like to be unwrapped. * * @param parameterType must not be {@literal null}. * @return */ private static boolean isNonUnwrappingWrapper(Class<?> parameterType) { Assert.notNull(parameterType, "Parameter type must not be null!"); return QueryExecutionConverters.supports(parameterType) && !QueryExecutionConverters.supportsUnwrapping(parameterType); }
private static Class<? extends Object> potentiallyUnwrapReturnTypeFor(Method method) { if (QueryExecutionConverters.supports(method.getReturnType())) { // unwrap only one level to handle cases like Future<List<Entity>> correctly. TypeInformation<?> componentType = ClassTypeInformation.fromReturnTypeOf(method).getComponentType(); if (componentType == null) { throw new IllegalStateException( String.format("Couldn't find component type for return value of method %s!", method)); } return componentType.getType(); } return method.getReturnType(); }
/** * Checks whether the type is a wrapper without unwrapping support. Reactive wrappers don't like to be unwrapped. * * @param parameterType must not be {@literal null}. * @return */ private static boolean isNonUnwrappingWrapper(Class<?> parameterType) { Assert.notNull(parameterType, "Parameter type must not be null!"); return QueryExecutionConverters.supports(parameterType) && !QueryExecutionConverters.supportsUnwrapping(parameterType); }
/** * Recursively unwraps well known wrapper types from the given {@link TypeInformation}. * * @param type must not be {@literal null}. * @return will never be {@literal null}. */ public static TypeInformation<?> unwrapWrapperTypes(TypeInformation<?> type) { Assert.notNull(type, "type must not be null"); Class<?> rawType = type.getType(); boolean needToUnwrap = type.isCollectionLike() // || Slice.class.isAssignableFrom(rawType) // || GeoResults.class.isAssignableFrom(rawType) // || rawType.isArray() // || supports(rawType) // || Stream.class.isAssignableFrom(rawType); return needToUnwrap ? unwrapWrapperTypes(type.getRequiredComponentType()) : type; }
/** * Checks whether the type is a wrapper without unwrapping support. Reactive wrappers don't like to be unwrapped. * * @param parameterType must not be {@literal null}. * @return */ private static boolean isNonUnwrappingWrapper(Class<?> parameterType) { Assert.notNull(parameterType, "Parameter type must not be null!"); return QueryExecutionConverters.supports(parameterType) && !QueryExecutionConverters.supportsUnwrapping(parameterType); }
private static TypeInformation<?> getEffectivelyReturnedTypeFrom(Method method) { TypeInformation<?> returnType = ClassTypeInformation.fromReturnTypeOf(method); return QueryExecutionConverters.supports(returnType.getType()) ? returnType.getRequiredComponentType() : returnType; } }
/** * Returns whether the finder will actually return a collection of entities or a single one. * * @return */ public boolean isCollectionQuery() { if (isPageQuery() || isSliceQuery()) { return false; } Class<?> returnType = method.getReturnType(); if (QueryExecutionConverters.supports(returnType) && !QueryExecutionConverters.isSingleValue(returnType)) { return true; } if (QueryExecutionConverters.supports(unwrappedReturnType)) { return !QueryExecutionConverters.isSingleValue(unwrappedReturnType); } return ClassTypeInformation.from(unwrappedReturnType).isCollectionLike(); }
if (QueryExecutionConverters.supports(expectedReturnType)) {