From e7bc681e6ef1ee5d7e2f14fc62849eb785e36a43 Mon Sep 17 00:00:00 2001 From: Otavio Santana Date: Wed, 14 Aug 2024 07:58:44 +0100 Subject: [PATCH] feat: create fieldl analizer and fix for array Signed-off-by: Otavio Santana --- .../jnosql/lite/mapping/entities/Worker.java | 2 -- .../eclipse/jnosql/lite/mapping/FieldAnalyzer.java | 13 +++++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/jnosql-lite/mapping-lite-core-test/src/main/java/org/eclipse/jnosql/lite/mapping/entities/Worker.java b/jnosql-lite/mapping-lite-core-test/src/main/java/org/eclipse/jnosql/lite/mapping/entities/Worker.java index b965e2a1..96217a99 100644 --- a/jnosql-lite/mapping-lite-core-test/src/main/java/org/eclipse/jnosql/lite/mapping/entities/Worker.java +++ b/jnosql-lite/mapping-lite-core-test/src/main/java/org/eclipse/jnosql/lite/mapping/entities/Worker.java @@ -15,10 +15,8 @@ package org.eclipse.jnosql.lite.mapping.entities; import jakarta.nosql.Entity; -import jakarta.nosql.Id; import jakarta.nosql.Column; -import jakarta.nosql.Entity; import jakarta.nosql.Convert; @Entity diff --git a/jnosql-lite/mapping-lite-processor/src/main/java/org/eclipse/jnosql/lite/mapping/FieldAnalyzer.java b/jnosql-lite/mapping-lite-processor/src/main/java/org/eclipse/jnosql/lite/mapping/FieldAnalyzer.java index 7867b54a..57708eb3 100644 --- a/jnosql-lite/mapping-lite-processor/src/main/java/org/eclipse/jnosql/lite/mapping/FieldAnalyzer.java +++ b/jnosql-lite/mapping-lite-processor/src/main/java/org/eclipse/jnosql/lite/mapping/FieldAnalyzer.java @@ -145,18 +145,23 @@ private FieldModel getMetaData() { } else if (typeMirror instanceof ArrayType arrayType) { TypeMirror componentType = arrayType.getComponentType(); + mappingType = MappingType.ARRAY; + className = typeMirror.toString(); + collectionInstance = CollectionUtil.DEFAULT; + if (componentType instanceof DeclaredType declaredType) { var element = declaredType.asElement(); - className = typeMirror.toString(); supplierElement = componentType.toString(); embeddable = element.getAnnotation(Entity.class) != null || element.getAnnotation(Embeddable.class) != null; - collectionInstance = CollectionUtil.DEFAULT; elementType = element + ".class"; arrayElement = element.toString(); - mappingType = MappingType.ARRAY; newArrayInstance = className.replace("[]", "[collection.size()]"); } else { - className = componentType.toString(); + className = typeMirror.toString(); + supplierElement = typeMirror.toString(); + arrayElement = componentType.toString(); + elementType = componentType + ".class"; + newArrayInstance = className.replace("[]", "[collection.size()]"); } } else { className = typeMirror.toString();