diff --git a/processor/src/main/java/org/ethelred/kiwiproc/processor/CoreTypes.java b/processor/src/main/java/org/ethelred/kiwiproc/processor/CoreTypes.java index 2319c09..2d34354 100644 --- a/processor/src/main/java/org/ethelred/kiwiproc/processor/CoreTypes.java +++ b/processor/src/main/java/org/ethelred/kiwiproc/processor/CoreTypes.java @@ -4,11 +4,7 @@ import java.math.BigDecimal; import java.math.BigInteger; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.OffsetDateTime; -import java.time.OffsetTime; +import java.time.*; import java.util.ArrayList; import java.util.Collection; import java.util.LinkedHashMap; @@ -53,12 +49,18 @@ public class CoreTypes { Primitive type mappings that are NOT in this map require a cast and a "lossy converson" warning. */ private static final Map, Set>> assignableFrom = Map.of( - byte.class, Set.of(short.class, int.class, long.class, float.class, double.class), - char.class, Set.of(int.class, long.class, float.class, double.class), - short.class, Set.of(int.class, long.class, float.class, double.class), - int.class, Set.of(long.class, float.class, double.class), - long.class, Set.of(float.class, double.class), - float.class, Set.of(double.class)); + byte.class, Set.of(byte.class, short.class, int.class, long.class, float.class, double.class), + char.class, Set.of(char.class, int.class, long.class, float.class, double.class), + short.class, Set.of(short.class, int.class, long.class, float.class, double.class), + int.class, Set.of(int.class, long.class, float.class, double.class), + long.class, Set.of(long.class, float.class, double.class), + float.class, Set.of(float.class, double.class)); + + private record ClassEntry(Class first, Class second) {} + + private static final Map, Set>> assignableTo = assignableFrom.entrySet().stream() + .flatMap(e -> e.getValue().stream().map(v -> new ClassEntry(v, e.getKey()))) + .collect(Collectors.groupingBy(ce -> ce.first, Collectors.mapping(ce -> ce.second, Collectors.toSet()))); // boxing a primitive type is also assignable // unboxing is invalid in Kiwiproc, since it would convert a nullable to non-null @@ -68,7 +70,7 @@ private static boolean isAssignable(Class source, Class target) { private final Conversion invalid = new InvalidConversion(); Map, KiwiType> coreTypes; - Map simpleMappings; + Map simpleMappings; public CoreTypes() { coreTypes = defineTypes(); @@ -77,8 +79,8 @@ public CoreTypes() { // coreMappings.entrySet().stream().map(Object::toString).collect(Collectors.joining("\n"))); } - private Map defineMappings() { - List> entries = new ArrayList<>(200); + private Map defineMappings() { + List> entries = new ArrayList<>(200); addPrimitiveMappings(entries); addPrimitiveParseMappings(entries); @@ -89,52 +91,115 @@ private Map defineMappings() { .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (a, b) -> a, LinkedHashMap::new)); } - private void addPrimitiveParseMappings(Collection> entries) { + private void addPrimitiveParseMappings(Collection> entries) { primitiveToBoxed.keySet().forEach(target -> { + if (target.equals(boolean.class)) { + return; // special case below + } String warning = "possible NumberFormatException parsing String to %s".formatted(target.getName()); Class boxed = primitiveToBoxed.get(target); // String -> primitive TypeMapping t = new TypeMapping(STRING_TYPE, coreTypes.get(target)); StringFormatConversion c = new StringFormatConversion( - warning, - "%s.parse%s(%%s)".formatted(boxed.getSimpleName(), Util.capitalizeFirst(target.getSimpleName()))); + warning, "$T.parse$L($N)", boxed, Util.capitalizeFirst(target.getSimpleName())); entries.add(entry(t, c)); // String -> boxed t = new TypeMapping(STRING_TYPE, coreTypes.get(boxed)); - c = new StringFormatConversion(warning, "%s.valueOf(%%s)".formatted(boxed.getSimpleName())); + c = new StringFormatConversion(warning, "$T.valueOf($N)", boxed); entries.add(entry(t, c)); }); + + TypeMapping t = new TypeMapping(STRING_TYPE, coreTypes.get(boolean.class)); + String format = + """ + ($1N.matches("\\d+") && !"0".equals($1N)) || Boolean.parseBoolean($1N) + """; + entries.add(entry(t, new StringFormatConversion(null, format))); } - private void addDateTimeMappings(Collection> entries) {} + private void addDateTimeMappings(Collection> entries) { + String usesSystemDefaultZoneId = "uses system default ZoneId"; + List.of(LocalDate.class, LocalTime.class, OffsetTime.class, LocalDateTime.class, OffsetDateTime.class) + .forEach(dtClass -> { + entries.add(mappingEntry( + String.class, + dtClass, + "possible DateTimeParseException parsing String to %s".formatted(dtClass.getSimpleName()), + "$T.parse($N)", + dtClass)); + + entries.add(mappingEntry( + long.class, + dtClass, + usesSystemDefaultZoneId, + "$1T.ofInstant($2T.ofEpochMilli($4N), $3T.systemDefault())", + dtClass, + Instant.class, + ZoneId.class)); + }); + entries.add(mappingEntry(OffsetDateTime.class, long.class, null, "$N.toInstant().toEpochMilli()")); + entries.add(mappingEntry(OffsetDateTime.class, LocalDateTime.class, null, "$N.toLocalDateTime()")); + entries.add(mappingEntry(OffsetDateTime.class, OffsetTime.class, null, "$N.toOffsetTime()")); + entries.add(mappingEntry(OffsetDateTime.class, LocalDate.class, null, "$N.toLocalDate()")); + entries.add(mappingEntry( + LocalDateTime.class, + long.class, + usesSystemDefaultZoneId, + "$2N.atZone($1T.systemDefault()).toOffsetDateTime().toInstant().toEpochMilli()", + ZoneId.class)); + entries.add(mappingEntry(LocalDateTime.class, LocalDate.class, null, "$N.toLocalDate()")); + entries.add(mappingEntry(LocalDateTime.class, LocalTime.class, null, "$N.toLocalTime()")); + entries.add(mappingEntry( + LocalDate.class, + long.class, + usesSystemDefaultZoneId, + "$2N.atStartOfDay().atZone($1T.systemDefault()).toOffsetDateTime().toInstant().toEpochMilli()", + ZoneId.class)); + entries.add(mappingEntry(LocalDate.class, LocalDateTime.class, null, "$N.atStartOfDay()")); + entries.add(mappingEntry( + LocalDate.class, + OffsetDateTime.class, + null, + "$2N.atStartOfDay().atZone($1T.systemDefault()).toOffsetDateTime()", + ZoneId.class)); + entries.add(mappingEntry(OffsetTime.class, LocalTime.class, null, "$N.toLocalTime()")); + } - private void addBigNumberMappings(Collection> entries) { + private void addBigNumberMappings(Collection> entries) { List.of(BigInteger.class, BigDecimal.class).forEach(big -> { // primitive -> Big Stream.of(byte.class, short.class, int.class, long.class, float.class, double.class) .forEach(source -> { - entries.add(mappingEntry(source, big, null, "%s.valueOf(%%s)".formatted(big.getSimpleName()))); + entries.add(mappingEntry(source, big, null, "$T.valueOf($N)", big)); }); // String -> Big String warning = "possible NumberFormatException parsing String to %s".formatted(big.getSimpleName()); - entries.add(mappingEntry(String.class, big, warning, "new %s(%%s)".formatted(big.getSimpleName()))); + entries.add(mappingEntry(String.class, big, warning, "new $T($N)", big)); // Big -> primitive Stream.of(byte.class, short.class, int.class, long.class, float.class, double.class) .forEach(target -> { String w = "possible lossy conversion from %s to %s".formatted(big.getName(), target.getName()); - entries.add(mappingEntry(big, target, w, "%%s.%sValue()".formatted(target.getName()))); + entries.add(mappingEntry(big, target, w, "$N.%sValue()".formatted(target.getName()))); }); }); + entries.add(mappingEntry(BigInteger.class, boolean.class, null, "!$T.ZERO.equals($N)", BigInteger.class)); + entries.add(mappingEntry(boolean.class, BigInteger.class, null, "$2N ? $1T.ONE : $1T.ZERO", BigInteger.class)); + entries.add(mappingEntry( + BigDecimal.class, + BigInteger.class, + "possible lossy conversion from BigDecimal to BigInteger", + "$N.toBigInteger()")); + entries.add(mappingEntry(BigInteger.class, BigDecimal.class, null, "new $T($N)", BigDecimal.class)); } - private void addPrimitiveMappings(Collection> entries) { + private void addPrimitiveMappings(Collection> entries) { // primitive safe assignments assignableFrom.forEach((source, targets) -> { targets.forEach(target -> { // primitive - entries.add(mappingEntry(source, target, null, "%s")); + entries.add(mappingEntry(source, target, new AssignmentConversion())); }); }); @@ -144,22 +209,35 @@ private void addPrimitiveMappings(Collection { + entries.add(mappingEntry(source, boolean.class, null, "$N != 0")); + entries.add(mappingEntry(boolean.class, source, null, "$2N ? 1 : 0")); + }); + entries.add(mappingEntry(char.class, boolean.class, null, "Character.isDigit($1N) && $1N != '0'")); + entries.add(mappingEntry(boolean.class, char.class, null, "$N ? '1' : '0'")); } - private Map.Entry mappingEntry( - Class source, Class target, @Nullable String warning, String conversionFormat) { + private Map.Entry mappingEntry(Class source, Class target, Conversion lookup) { var fromType = Objects.requireNonNull(coreTypes.get(source)); var toType = Objects.requireNonNull(coreTypes.get(target)); var mapping = new TypeMapping(fromType, toType); - var lookup = new StringFormatConversion(warning, conversionFormat); return entry(mapping, lookup); } + private Map.Entry mappingEntry( + Class source, + Class target, + @Nullable String warning, + String conversionFormat, + Object... defaultArgs) { + return mappingEntry(source, target, new StringFormatConversion(warning, conversionFormat, defaultArgs)); + } + private Map, KiwiType> defineTypes() { Map, KiwiType> builder = new LinkedHashMap<>(32); primitiveToBoxed.forEach((key, value) -> { @@ -194,7 +272,7 @@ public Conversion lookup(KiwiType source, KiwiType target) { // special case String StringFormatConversion stringConversion = null; if (STRING_TYPE.equals(target) || STRING_TYPE.withIsNullable(true).equals(target)) { - stringConversion = new StringFormatConversion(null, "String.valueOf(%s)"); + stringConversion = new StringFormatConversion(null, "String.valueOf($N)"); } var result = firstNonNull( stringConversion, diff --git a/processor/src/main/java/org/ethelred/kiwiproc/processor/StringFormatConversion.java b/processor/src/main/java/org/ethelred/kiwiproc/processor/StringFormatConversion.java index d3f9a6f..d8831a0 100644 --- a/processor/src/main/java/org/ethelred/kiwiproc/processor/StringFormatConversion.java +++ b/processor/src/main/java/org/ethelred/kiwiproc/processor/StringFormatConversion.java @@ -1,8 +1,10 @@ package org.ethelred.kiwiproc.processor; +import java.util.Arrays; import org.jspecify.annotations.Nullable; -public record StringFormatConversion(@Nullable String warning, String conversionFormat) implements Conversion { +public record StringFormatConversion(@Nullable String warning, String conversionFormat, Object... baseArgs) + implements Conversion { public boolean hasWarning() { return warning != null; } @@ -11,4 +13,10 @@ public boolean hasWarning() { public boolean isValid() { return true; } + + public Object[] withAccessor(String accessor) { + var r = Arrays.copyOf(baseArgs, baseArgs.length + 1); + r[baseArgs.length] = accessor; + return r; + } } diff --git a/processor/src/main/java/org/ethelred/kiwiproc/processor/generator/InstanceGenerator.java b/processor/src/main/java/org/ethelred/kiwiproc/processor/generator/InstanceGenerator.java index 6c85227..961f756 100644 --- a/processor/src/main/java/org/ethelred/kiwiproc/processor/generator/InstanceGenerator.java +++ b/processor/src/main/java/org/ethelred/kiwiproc/processor/generator/InstanceGenerator.java @@ -190,84 +190,91 @@ private void buildConversion( String assignee, String accessor, boolean withVar) { - var insertVar = withVar ? "var " : ""; - if (conversion instanceof AssignmentConversion) { - /* e.g. - var param1 = id; - */ - builder.addStatement("$L$L = $L", insertVar, assignee, accessor); - } else if (conversion instanceof StringFormatConversion sfc) { - /* e.g. - var param1 = (int) id; - */ - builder.addStatement( - "$L$L = $L", insertVar, assignee, sfc.conversionFormat().formatted(accessor)); - } else if (conversion instanceof ToSqlArrayConversion sac) { - /* e.g. - Object[] elementObjects = listParam.stream() - .map(x -> (int) x) - .toArray(); - var param1 = connection.createArrayOf("int4", elementObjects); - */ - Conversion elementConversion = sac.elementConversion(); - String elementObjects = patchName("elementObjects"); - String lambdaValue = patchName("value"); - builder.add("Object[] $L = ", elementObjects) - .addNamed(sac.ct().type().toStreamTemplate(), Map.of("containerVariable", accessor)) - .indent() - .add("\n.map($L -> {\n", lambdaValue) - .indent(); - buildConversion(builder, elementConversion, sac.sat().containedType(), "tmp", lambdaValue, true); - builder.addStatement("return tmp") - .unindent() - .add("})\n.toArray();\n") - .unindent(); - builder.addStatement( - "$L$L = connection.createArrayOf($S, $L)", - insertVar, - assignee, - sac.sat().componentDbType(), - elementObjects); - } else if (conversion instanceof FromSqlArrayConversion sac) { - /* e.g. - ResultSet arrayRS = rawValue.getResultSet(); - List arrayList = new ArrayList<>(); - while (arrayRs.next()) { - var rawItemValue = arrayRs.getString(2); - var itemValue = rawItemValue; - arrayList.add(itemValue); - } - var value = List.copyOf(arrayList); - */ - var arrayRS = patchName("arrayRS"); - var arrayList = patchName("arrayList"); - var rawItemValue = patchName("rawItemValue"); - var itemValue = patchName("itemValue"); - TypeName componentClass = kiwiTypeConverter.fromKiwiType(sac.ct().containedType()); - builder.addStatement("$T $L = $L.getResultSet()", ResultSet.class, arrayRS, accessor) - .addStatement("List<$T> $L = new $T<>()", componentClass, arrayList, ArrayList.class) - .beginControlFlow("while ($L.next())", arrayRS) - // Array.getResultSet() returns 2 columns: 1 is the index, 2 is the value - .addStatement( - "var $L = $L.get$L(2)", - rawItemValue, - arrayRS, - sac.sat().componentType().accessorSuffix()); - buildConversion(builder, sac.elementConversion(), sac.ct().containedType(), itemValue, rawItemValue, true); - builder.addStatement("$L.add($L)", arrayList, itemValue) - .endControlFlow() - .add("$L$L = ", insertVar, assignee) - .addNamed( - sac.ct().type().fromListTemplate(), - Map.of("componentClass", componentClass, "listVariable", arrayList)) - .addStatement(""); - } else if (conversion instanceof NullableSourceConversion nsc) { - builder.addStatement("$T $L = null", kiwiTypeConverter.fromKiwiType(targetType), assignee) - .beginControlFlow("if ($L != null)", accessor); - buildConversion(builder, nsc.conversion(), targetType, assignee, accessor, false); - builder.endControlFlow(); - } else { - logger.error(null, "Unsupported Conversion %s".formatted(conversion)); // TODO add Element + try { + var insertVar = + withVar ? CodeBlock.of("$T ", kiwiTypeConverter.fromKiwiType(targetType)) : CodeBlock.of(""); + if (conversion instanceof AssignmentConversion) { + /* e.g. + var param1 = id; + */ + builder.addStatement("$L$L = $L", insertVar, assignee, accessor); + } else if (conversion instanceof StringFormatConversion sfc) { + /* e.g. + var param1 = (int) id; + */ + builder.add("$L$L =", insertVar, assignee) + .addStatement(sfc.conversionFormat(), sfc.withAccessor(accessor)); + } else if (conversion instanceof ToSqlArrayConversion sac) { + /* e.g. + Object[] elementObjects = listParam.stream() + .map(x -> (int) x) + .toArray(); + var param1 = connection.createArrayOf("int4", elementObjects); + */ + Conversion elementConversion = sac.elementConversion(); + String elementObjects = patchName("elementObjects"); + String lambdaValue = patchName("value"); + builder.add("Object[] $L = ", elementObjects) + .addNamed(sac.ct().type().toStreamTemplate(), Map.of("containerVariable", accessor)) + .indent() + .add("\n.map($L -> {\n", lambdaValue) + .indent(); + buildConversion(builder, elementConversion, sac.sat().containedType(), "tmp", lambdaValue, true); + builder.addStatement("return tmp") + .unindent() + .add("})\n.toArray();\n") + .unindent(); + builder.addStatement( + "$L$L = connection.createArrayOf($S, $L)", + insertVar, + assignee, + sac.sat().componentDbType(), + elementObjects); + } else if (conversion instanceof FromSqlArrayConversion sac) { + /* e.g. + ResultSet arrayRS = rawValue.getResultSet(); + List arrayList = new ArrayList<>(); + while (arrayRs.next()) { + var rawItemValue = arrayRs.getString(2); + var itemValue = rawItemValue; + arrayList.add(itemValue); + } + var value = List.copyOf(arrayList); + */ + var arrayRS = patchName("arrayRS"); + var arrayList = patchName("arrayList"); + var rawItemValue = patchName("rawItemValue"); + var itemValue = patchName("itemValue"); + TypeName componentClass = + kiwiTypeConverter.fromKiwiType(sac.ct().containedType()); + builder.addStatement("$T $L = $L.getResultSet()", ResultSet.class, arrayRS, accessor) + .addStatement("List<$T> $L = new $T<>()", componentClass, arrayList, ArrayList.class) + .beginControlFlow("while ($L.next())", arrayRS) + // Array.getResultSet() returns 2 columns: 1 is the index, 2 is the value + .addStatement( + "var $L = $L.get$L(2)", + rawItemValue, + arrayRS, + sac.sat().componentType().accessorSuffix()); + buildConversion( + builder, sac.elementConversion(), sac.ct().containedType(), itemValue, rawItemValue, true); + builder.addStatement("$L.add($L)", arrayList, itemValue) + .endControlFlow() + .add("$L$L = ", insertVar, assignee) + .addNamed( + sac.ct().type().fromListTemplate(), + Map.of("componentClass", componentClass, "listVariable", arrayList)) + .addStatement(""); + } else if (conversion instanceof NullableSourceConversion nsc) { + builder.addStatement("$T $L = null", kiwiTypeConverter.fromKiwiType(targetType), assignee) + .beginControlFlow("if ($L != null)", accessor); + buildConversion(builder, nsc.conversion(), targetType, assignee, accessor, false); + builder.endControlFlow(); + } else { + logger.error(null, "Unsupported Conversion %s".formatted(conversion)); // TODO add Element + } + } catch (RuntimeException e) { + throw new RuntimeException("Error in conversion " + conversion, e); } } diff --git a/processor/src/test/java/org/ethelred/kiwiproc/processor/CoreTypesTest.java b/processor/src/test/java/org/ethelred/kiwiproc/processor/CoreTypesTest.java index ab9e8cf..ce095cd 100644 --- a/processor/src/test/java/org/ethelred/kiwiproc/processor/CoreTypesTest.java +++ b/processor/src/test/java/org/ethelred/kiwiproc/processor/CoreTypesTest.java @@ -9,6 +9,10 @@ import java.math.BigDecimal; import java.sql.JDBCType; import java.time.LocalDate; +import java.util.LinkedHashSet; +import java.util.Set; +import java.util.function.Predicate; +import java.util.stream.Collectors; import java.util.stream.Stream; import org.ethelred.kiwiproc.processor.types.*; import org.junit.jupiter.api.Test; @@ -20,7 +24,7 @@ * Don't exhaustively test every type and mapping, just some examples. */ public class CoreTypesTest { - CoreTypes coreTypes = new CoreTypes(); + static CoreTypes coreTypes = new CoreTypes(); @Test void typeFromClass() { @@ -61,7 +65,7 @@ void testConversions( .isEqualTo(isWarning); if (conversion.isValid()) { if (conversion instanceof StringFormatConversion sfc) { - var formatted = sfc.conversionFormat().formatted("value"); + var formatted = sfc.conversionFormat().replaceAll("\\$\\d*N", "value"); assertThat(formatted).isEqualTo(conversionFormatContains); } } @@ -78,11 +82,11 @@ public static Stream testConversions() { true, false, "value == null ? null : value"), - arguments(ofClass(double.class), ofClass(short.class), true, true, "(short) value"), - arguments(ofClass(double.class), ofClass(Short.class, true), true, true, "(short) value"), - arguments(ofClass(double.class), ofClass(BigDecimal.class), true, false, "BigDecimal.valueOf(value)"), - arguments(ofClass(String.class), ofClass(int.class), true, true, "Integer.parseInt(value)"), - arguments(ofClass(String.class), ofClass(Integer.class, true), true, true, "Integer.valueOf(value)"), + arguments(ofClass(double.class), ofClass(short.class), true, true, "($T) value"), + arguments(ofClass(double.class), ofClass(Short.class, true), true, true, "($T) value"), + arguments(ofClass(double.class), ofClass(BigDecimal.class), true, false, "$T.valueOf(value)"), + arguments(ofClass(String.class), ofClass(int.class), true, true, "$T.parse$L(value)"), + arguments(ofClass(String.class), ofClass(Integer.class, true), true, true, "$T.valueOf(value)"), arguments( new ContainerType(ValidContainerType.LIST, ofClass(Integer.class, true)), new SqlArrayType( @@ -91,4 +95,85 @@ public static Stream testConversions() { false, "fail")); } + + @ParameterizedTest + @MethodSource + public void allSimpleConversions(TypeMapping mapping) { + var conversion = coreTypes.lookup(mapping); + assertThat(conversion).isNotNull(); + assertThat(conversion.isValid()).isTrue(); + } + + @ParameterizedTest + @MethodSource + public void inverseConversions(TypeMapping mapping) { + assertThat(expectedMappings().contains(mapping)); + } + + public static Stream inverseConversions() { + return coreTypes.simpleMappings.keySet().stream().map(Arguments::arguments); + } + + public static Stream allSimpleConversions() { + return expectedMappings().stream().map(Arguments::arguments); + } + + static Set expectedMappings() { + var types = simpleTypes(); + return types.stream() + .flatMap(t1 -> types.stream().map(t2 -> new TypeMapping(t1, t2))) + .filter(INCLUDE) + .collect(Collectors.toSet()); + } + + static Set simpleTypes() { + Set types = new LinkedHashSet<>(); + CoreTypes.primitiveToBoxed.keySet().forEach(c -> types.add(new PrimitiveKiwiType(c.getSimpleName(), false))); + CoreTypes.BASIC_TYPES.forEach(c -> types.add(new BasicType(c.getPackageName(), c.getSimpleName(), false))); + return types; + } + + static boolean exclude(TypeMapping typeMapping) { + var source = typeMapping.source(); + var target = typeMapping.target(); + if (source.className().matches("char")) { + return target.className().matches(".*(Big|Date|Time).*"); + } + if (target.className().matches("char")) { + return source.className().matches(".*(Big|Date|Time).*"); + } + if (source.className().matches("boolean")) { + return target.className().matches(".*(BigDecimal|Date|Time).*"); + } + if (target.className().matches("boolean")) { + return source.className().matches(".*(BigDecimal|Date|Time).*"); + } + if ("long".equals(target.className())) { + return Set.of("OffsetTime", "LocalTime").contains(source.className()); + } + if (target instanceof PrimitiveKiwiType || target.className().startsWith("Big")) { + return source.className().matches(".*(Date|Time).*"); + } + if (source instanceof PrimitiveKiwiType || source.className().startsWith("Big")) { + return target.className().matches(".*(Date|Time).*"); + } + var key = typeMapping.source().className() + "|" + typeMapping.target().className(); + return otherExcludeKeys.contains(key); + } + + static Set otherExcludeKeys = Set.of( + "LocalDate|OffsetTime", + "OffsetTime|LocalDate", + "LocalDateTime|OffsetTime", + "LocalTime|LocalDate", + "OffsetDateTime|LocalTime", + "LocalDateTime|OffsetDateTime", // TODO? + "LocalTime|OffsetDateTime", + "LocalDate|LocalTime", + "OffsetTime|LocalDateTime", + "OffsetTime|OffsetDateTime", + "LocalTime|LocalDateTime", + "LocalTime|OffsetTime"); + + static Predicate INCLUDE = typeMapping -> !exclude(typeMapping); } diff --git a/processor/src/test/java/org/ethelred/kiwiproc/processor/TestMapper.java b/processor/src/test/java/org/ethelred/kiwiproc/processor/TestMapper.java deleted file mode 100644 index 8092a90..0000000 --- a/processor/src/test/java/org/ethelred/kiwiproc/processor/TestMapper.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.ethelred.kiwiproc.processor; - -import java.time.LocalDate; -import org.mapstruct.Mapper; - -@Mapper -public interface TestMapper { - record PrimitiveIntRecord(int value) {} - - record StringRecord(String value) {} - - record LocalDateRecord(LocalDate value) {} - - StringRecord toString(PrimitiveIntRecord x); - - LocalDateRecord toLocalDate(StringRecord x); -} diff --git a/processor/src/test/java/org/ethelred/kiwiproc/processor/TypeValidatorTest.java b/processor/src/test/java/org/ethelred/kiwiproc/processor/TypeValidatorTest.java index 39636f0..0c6567f 100644 --- a/processor/src/test/java/org/ethelred/kiwiproc/processor/TypeValidatorTest.java +++ b/processor/src/test/java/org/ethelred/kiwiproc/processor/TypeValidatorTest.java @@ -66,11 +66,6 @@ public static Stream testQueryParameter() { new MethodParameterInfo(mockVariableElement(), "x", ofClass(int.class), false, null), true, null), - arguments( - col(false, JDBCType.INTEGER), - new MethodParameterInfo(mockVariableElement(), "x", ofClass(Integer.class, true), false, null), - false, - "Parameter type int/nullable is not compatible with SQL type int/non-null for parameter null"), arguments( col(true, JDBCType.INTEGER), new MethodParameterInfo(mockVariableElement(), "x", ofClass(Integer.class, true), false, null),