DATACMNS-836 - Polishing.

RepositoryMetadata now exposes an ….isReactiveRepository() that's implemented by inspecting the backing repository interface for any reactive wrapper type appearing in method signatures. That allows us to move down the use of a ConversionService down to ReactiveRepositoryInformation.WrapperConversionMatch.

Made a couple of methods static that could be. Simplified some logic using streams. A bit better wording in assertions. Some formatting when using streams.
This commit is contained in:
Oliver Gierke
2016-11-13 14:26:54 +01:00
parent 5bf19d1c2a
commit 5d591db848
17 changed files with 359 additions and 280 deletions

View File

@@ -20,6 +20,7 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.stream.Stream;
import org.springframework.beans.BeanUtils;
@@ -264,6 +265,23 @@ public abstract class ReflectionUtils {
return null;
}
/**
* Returns a {@link Stream} of the return and parameters types of the given {@link Method}.
*
* @param method must not be {@literal null}.
* @return
* @since 2.0
*/
public static Stream<Class<?>> returnTypeAndParameters(Method method) {
Assert.notNull(method, "Method must not be null!");
Stream<Class<?>> returnType = Stream.of(method.getReturnType());
Stream<Class<?>> parameterTypes = Arrays.stream(method.getParameterTypes());
return Stream.concat(returnType, parameterTypes);
}
private static final boolean argumentsMatch(Class<?>[] parameterTypes, Object[] arguments) {
if (parameterTypes.length != arguments.length) {

View File

@@ -51,8 +51,8 @@ public class StreamUtils {
Spliterator<T> spliterator = Spliterators.spliteratorUnknownSize(iterator, Spliterator.NONNULL);
Stream<T> stream = StreamSupport.stream(spliterator, false);
return iterator instanceof CloseableIterator ? stream.onClose(new CloseableIteratorDisposingRunnable(
(CloseableIterator<T>) iterator)) : stream;
return iterator instanceof CloseableIterator
? stream.onClose(new CloseableIteratorDisposingRunnable((CloseableIterator<T>) iterator)) : stream;
}
/**