Skip to content

Commit 3ba6a75

Browse files
velocigaly
andauthored
Support Java 16+ records in querydsl-apt @cigaly (#374)
* Support Java 16+ records in querydsl-apt * Test record code generation --------- Co-authored-by: Cedomir Igaly <cedomir.igaly@e-dama.net>
1 parent f0d0554 commit 3ba6a75

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/TypeExtractor.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@
1414
package com.querydsl.apt;
1515

1616
import javax.lang.model.element.TypeElement;
17-
import javax.lang.model.type.*;
17+
import javax.lang.model.type.ArrayType;
18+
import javax.lang.model.type.DeclaredType;
19+
import javax.lang.model.type.ErrorType;
20+
import javax.lang.model.type.ExecutableType;
21+
import javax.lang.model.type.NoType;
22+
import javax.lang.model.type.NullType;
23+
import javax.lang.model.type.PrimitiveType;
24+
import javax.lang.model.type.TypeVariable;
25+
import javax.lang.model.type.WildcardType;
1826

1927
/**
2028
* {@code TypeExtractor} is a visitor implementation which extracts a concrete type from a generic
@@ -49,12 +57,13 @@ public TypeElement visitArray(ArrayType t, Void p) {
4957
public TypeElement visitDeclared(DeclaredType t, Void p) {
5058
if (t.asElement() instanceof TypeElement) {
5159
TypeElement typeElement = (TypeElement) t.asElement();
52-
switch (typeElement.getKind()) {
53-
case ENUM:
60+
switch (typeElement.getKind().name()) {
61+
case "ENUM":
5462
return skipEnum ? null : typeElement;
55-
case CLASS:
63+
case "RECORD":
64+
case "CLASS":
5665
return typeElement;
57-
case INTERFACE:
66+
case "INTERFACE":
5867
return visitInterface(t);
5968
default:
6069
throw new IllegalArgumentException("Illegal type: " + typeElement);

querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/domain/p1/SEntity1.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,4 @@
1616
import com.querydsl.core.annotations.QueryEntity;
1717

1818
@QueryEntity
19-
public class SEntity1 {
20-
21-
String entity1Field;
22-
}
19+
public record SEntity1(String entity1Field) {}

0 commit comments

Comments
 (0)