From 290189652c062c18931b6c510a9e9c129e019942 Mon Sep 17 00:00:00 2001 From: Filip Hrisafov Date: Fri, 26 Aug 2022 19:35:54 +0200 Subject: [PATCH] #2990 Stabilise top level imports --- .../mapstruct/ap/internal/model/common/Type.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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 ce82fff62..fd7f3d690 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 @@ -181,9 +181,16 @@ public class Type extends ModelElement implements Comparable { this.loggingVerbose = loggingVerbose; - // The top level type for an array type is the top level type of the component type - TypeElement typeElementForTopLevel = - this.componentType == null ? this.typeElement : this.componentType.getTypeElement(); + TypeElement typeElementForTopLevel; + if ( Boolean.TRUE.equals( isToBeImported ) ) { + // If the is to be imported is explicitly set to true then we shouldn't look for the top level type + typeElementForTopLevel = null; + } + else { + // The top level type for an array type is the top level type of the component type + typeElementForTopLevel = + this.componentType == null ? this.typeElement : this.componentType.getTypeElement(); + } this.topLevelType = topLevelType( typeElementForTopLevel, this.typeFactory ); this.nameWithTopLevelTypeName = nameWithTopLevelTypeName( typeElementForTopLevel, this.name ); }