兼容内部类

This commit is contained in:
linpeilie 2023-11-06 19:22:17 +08:00
parent 9e7716d799
commit 1c8c6fd79c
5 changed files with 20 additions and 3 deletions

View File

@ -18,7 +18,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mapstruct.version>1.5.1.Final</mapstruct.version>
<mapstruct-plus.version>1.3.5</mapstruct-plus.version>
<mapstruct-plus.version>1.3.6-SNAPSHOT</mapstruct-plus.version>
<lombok.version>1.18.22</lombok.version>
</properties>

View File

@ -17,4 +17,9 @@ public class Car {
@AutoMapping(target = "wheels", ignore = true)
private Wheels wheels;
@Data
public static class InnerClass {
private String f;
}
}

View File

@ -0,0 +1,12 @@
package io.github.linpeilie.model;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
@Data
@AutoMapper(target = Car.InnerClass.class)
public class InnerClassTarget {
private String f;
}

View File

@ -90,7 +90,7 @@ public class AutoMapperGenerator {
private boolean classIsImmutable(ProcessingEnvironment processingEnv, ClassName className) {
final TypeElement targetElement = processingEnv.getElementUtils()
.getTypeElement(className.packageName() + "." + className.simpleName());
.getTypeElement(className.reflectionName().replaceAll("\\$", "."));
final List<? extends AnnotationMirror> annotationMirrors = targetElement.getAnnotationMirrors();
for (AnnotationMirror annotationMirror : annotationMirrors) {
if (annotationMirror.getAnnotationType().asElement().getSimpleName().contentEquals("Immutable")) {

View File

@ -17,7 +17,7 @@
</modules>
<properties>
<mapstruct-plus.version>1.3.5</mapstruct-plus.version>
<mapstruct-plus.version>1.3.6-SNAPSHOT</mapstruct-plus.version>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>