diff --git a/processor/src/main/java/org/mapstruct/ap/internal/model/common/Type.java b/processor/src/main/java/org/mapstruct/ap/internal/model/common/Type.java index f742e1ba..d29e545f 100644 --- a/processor/src/main/java/org/mapstruct/ap/internal/model/common/Type.java +++ b/processor/src/main/java/org/mapstruct/ap/internal/model/common/Type.java @@ -44,7 +44,6 @@ import org.mapstruct.ap.internal.util.ElementUtils; import org.mapstruct.ap.internal.util.Executables; import org.mapstruct.ap.internal.util.Filters; -import org.mapstruct.ap.internal.util.JavaStreamConstants; import org.mapstruct.ap.internal.util.NativeTypes; import org.mapstruct.ap.internal.util.Nouns; import org.mapstruct.ap.internal.util.TypeUtils; @@ -1084,23 +1083,16 @@ private boolean isCollectionOrMapOrStream(Accessor getterMethod) { } private boolean isCollection(TypeMirror candidate) { - return isSubType( candidate, Collection.class ); + return typeUtils.isSubtypeErased( candidate, typeFactory.getCollectionType() ); } private boolean isStream(TypeMirror candidate) { - TypeElement streamTypeElement = elementUtils.getTypeElement( JavaStreamConstants.STREAM_FQN ); - TypeMirror streamType = streamTypeElement == null ? null : typeUtils.erasure( streamTypeElement.asType() ); + TypeMirror streamType = typeFactory.getStreamType(); return streamType != null && typeUtils.isSubtypeErased( candidate, streamType ); } private boolean isMap(TypeMirror candidate) { - return isSubType( candidate, Map.class ); - } - - private boolean isSubType(TypeMirror candidate, Class clazz) { - String className = clazz.getCanonicalName(); - TypeMirror classType = typeUtils.erasure( elementUtils.getTypeElement( className ).asType() ); - return typeUtils.isSubtypeErased( candidate, classType ); + return typeUtils.isSubtypeErased( candidate, typeFactory.getMapType() ); } /** diff --git a/processor/src/main/java/org/mapstruct/ap/internal/model/common/TypeFactory.java b/processor/src/main/java/org/mapstruct/ap/internal/model/common/TypeFactory.java index f28e0c68..6eeddaaa 100644 --- a/processor/src/main/java/org/mapstruct/ap/internal/model/common/TypeFactory.java +++ b/processor/src/main/java/org/mapstruct/ap/internal/model/common/TypeFactory.java @@ -693,6 +693,18 @@ public BuilderType builderTypeFor( Type type, BuilderGem builder ) { return null; } + TypeMirror getCollectionType() { + return collectionType; + } + + TypeMirror getMapType() { + return mapType; + } + + TypeMirror getStreamType() { + return streamType; + } + public Type effectiveResultTypeFor( Type type, BuilderGem builder ) { if ( type != null ) { BuilderInfo builderInfo = findBuilder( type.getTypeMirror(), builder, false );