diff --git a/src/main/java/org/springframework/data/util/TypeDiscoverer.java b/src/main/java/org/springframework/data/util/TypeDiscoverer.java index 1c2566ee4..59865c4b7 100644 --- a/src/main/java/org/springframework/data/util/TypeDiscoverer.java +++ b/src/main/java/org/springframework/data/util/TypeDiscoverer.java @@ -366,7 +366,10 @@ class TypeDiscoverer implements TypeInformation { Class rawType = getType(); - return rawType.isArray() || Iterable.class.equals(rawType) || Collection.class.isAssignableFrom(rawType); + return rawType.isArray() // + || Iterable.class.equals(rawType) // + || Collection.class.isAssignableFrom(rawType) // + || Streamable.class.equals(rawType); } /* diff --git a/src/test/java/org/springframework/data/util/TypeDiscovererUnitTests.java b/src/test/java/org/springframework/data/util/TypeDiscovererUnitTests.java index b7a44b941..6196cbec2 100755 --- a/src/test/java/org/springframework/data/util/TypeDiscovererUnitTests.java +++ b/src/test/java/org/springframework/data/util/TypeDiscovererUnitTests.java @@ -16,13 +16,14 @@ package org.springframework.data.util; import static org.assertj.core.api.Assertions.*; -import static org.springframework.data.util.ClassTypeInformation.*; +import static org.springframework.data.util.ClassTypeInformation.from; import java.lang.reflect.Constructor; import java.lang.reflect.Type; import java.lang.reflect.TypeVariable; import java.util.Collection; import java.util.Collections; +import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; @@ -158,6 +159,15 @@ public class TypeDiscovererUnitTests { }); } + @Test // DATACMNS-1342 + public void considersStreamableToBeCollectionLike() { + + TypeInformation type = from(SomeStreamable.class); + + assertThat(type.isCollectionLike()).isFalse(); + assertThat(type.getRequiredProperty("streamable").isCollectionLike()).isTrue(); + } + class Person { Addresses addresses; @@ -195,4 +205,16 @@ public class TypeDiscovererUnitTests { } } + + // DATACMNS-1342 + + static class SomeStreamable implements Streamable { + + Streamable streamable; + + @Override + public Iterator iterator() { + return Collections.emptyIterator(); + } + } }