diff --git a/src/main/java/it/aboutbits/springboot/toolbox/autoconfiguration/web/CustomTypeScanner.java b/src/main/java/it/aboutbits/springboot/toolbox/autoconfiguration/web/CustomTypeScanner.java index d677d4b..f374c31 100644 --- a/src/main/java/it/aboutbits/springboot/toolbox/autoconfiguration/web/CustomTypeScanner.java +++ b/src/main/java/it/aboutbits/springboot/toolbox/autoconfiguration/web/CustomTypeScanner.java @@ -5,6 +5,11 @@ import lombok.Getter; import lombok.extern.slf4j.Slf4j; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; @@ -31,13 +36,24 @@ public void setAdditionalTypePackages(String[] additionalTypePackages) { log.info("CustomTypeConfiguration enabled. Scanning: {}", Arrays.toString(packageNamesToScan)); var classScanner = ClassScannerUtil.getScannerForPackages(packageNamesToScan); - this.relevantTypes = findAllCustomTypeRecords(classScanner); + this.relevantTypes = findAllCustomTypes(classScanner); } @SuppressWarnings("rawtypes") - public static Set> findAllCustomTypeRecords(ClassScannerUtil.ClassScanner classScanner) { + public static Set> findAllCustomTypes(ClassScannerUtil.ClassScanner classScanner) { return classScanner.getSubTypesOf(CustomType.class).stream() - .filter(Record.class::isAssignableFrom) + .filter(item -> + !item.isInterface() + && !item.isAnonymousClass() + && !Modifier.isAbstract(item.getModifiers()) + && !item.isAnnotationPresent(DisableCustomTypeConfiguration.class) + ) .collect(Collectors.toSet()); } + + @Target({ElementType.TYPE}) + @Retention(RetentionPolicy.RUNTIME) + public @interface DisableCustomTypeConfiguration { + + } } diff --git a/src/main/java/it/aboutbits/springboot/toolbox/jackson/CustomTypeDeserializer.java b/src/main/java/it/aboutbits/springboot/toolbox/jackson/CustomTypeDeserializer.java index 7d39bc0..a21106a 100644 --- a/src/main/java/it/aboutbits/springboot/toolbox/jackson/CustomTypeDeserializer.java +++ b/src/main/java/it/aboutbits/springboot/toolbox/jackson/CustomTypeDeserializer.java @@ -3,7 +3,7 @@ import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonDeserializer; -import it.aboutbits.springboot.toolbox.reflection.util.RecordReflectionUtil; +import it.aboutbits.springboot.toolbox.reflection.util.CustomTypeReflectionUtil; import it.aboutbits.springboot.toolbox.type.CustomType; import it.aboutbits.springboot.toolbox.type.ScaledBigDecimal; @@ -22,7 +22,14 @@ public class CustomTypeDeserializer> extends JsonDeseria public CustomTypeDeserializer(Class customType) { this.customType = customType; - this.constructor = RecordReflectionUtil.getCanonicalConstructor(customType); + try { + this.constructor = CustomTypeReflectionUtil.getCustomTypeConstructor(customType); + } catch (NoSuchMethodException e) { + throw new CustomTypeDeserializerException( + "Unable to find constructor for type: " + customType.getName(), + e + ); + } this.typeConverter = getTypeConverter( constructor.getParameterTypes()[0] @@ -49,9 +56,18 @@ public T deserialize(JsonParser jsonParser, DeserializationContext deserializati } private static Function getTypeConverter(Class wrappedType) { + if (Byte.class.isAssignableFrom(wrappedType)) { + return getByteConverter(); + } + if (Boolean.class.isAssignableFrom(wrappedType)) { + return getBooleanConverter(); + } if (String.class.isAssignableFrom(wrappedType)) { return getStringConverter(); } + if (Character.class.isAssignableFrom(wrappedType)) { + return getCharConverter(); + } if (Short.class.isAssignableFrom(wrappedType)) { return getShortConverter(); } @@ -79,6 +95,26 @@ private static Function getTypeConverter(Class wrappedTyp throw new CustomTypeDeserializerException("Value type not supported: " + wrappedType.getName()); } + private static Function getByteConverter() { + return jsonParser -> { + try { + return jsonParser.getByteValue(); + } catch (IOException e) { + throw new CustomTypeDeserializerException("Failed to read value as Byte.", e); + } + }; + } + + private static Function getBooleanConverter() { + return jsonParser -> { + try { + return jsonParser.getBooleanValue(); + } catch (IOException e) { + throw new CustomTypeDeserializerException("Failed to read value as Boolean.", e); + } + }; + } + private static Function getScaledBigDecimalConverter() { return jsonParser -> { try { @@ -169,6 +205,20 @@ private static Function getStringConverter() { }; } + private static Function getCharConverter() { + return jsonParser -> { + try { + var value = jsonParser.getValueAsString(); + if (value == null || value.length() != 1) { + throw new IOException(); + } + return value.charAt(0); + } catch (IOException e) { + throw new CustomTypeDeserializerException("Failed to read value as Char.", e); + } + }; + } + public static final class CustomTypeDeserializerException extends RuntimeException { public CustomTypeDeserializerException(String message) { super(message); diff --git a/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedBigDecimalJavaType.java b/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedBigDecimalJavaType.java index d9b2382..01e5415 100644 --- a/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedBigDecimalJavaType.java +++ b/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedBigDecimalJavaType.java @@ -1,6 +1,5 @@ package it.aboutbits.springboot.toolbox.persistence.javatype.base; -import it.aboutbits.springboot.toolbox.reflection.util.RecordReflectionUtil; import it.aboutbits.springboot.toolbox.type.CustomType; import lombok.SneakyThrows; import org.hibernate.type.descriptor.WrapperOptions; @@ -14,12 +13,16 @@ import java.sql.Types; public abstract class WrappedBigDecimalJavaType> extends AbstractClassJavaType { - private final transient Constructor canonicalConstructor; + private final transient Constructor constructor; protected WrappedBigDecimalJavaType(Class type) { super(type); - this.canonicalConstructor = RecordReflectionUtil.getCanonicalConstructor(type); + try { + this.constructor = type.getConstructor(BigDecimal.class); + } catch (NoSuchMethodException e) { + throw new IllegalStateException("No constructor found for " + type.getName(), e); + } } @Override @@ -60,7 +63,7 @@ public T wrap(X value, WrapperOptions wrapperOptions) { return (T) value; } if (value instanceof Double doubleValue) { - return canonicalConstructor.newInstance(BigDecimal.valueOf(doubleValue)); + return constructor.newInstance(BigDecimal.valueOf(doubleValue)); } throw unknownWrap(value.getClass()); diff --git a/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedBigIntegerJavaType.java b/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedBigIntegerJavaType.java index ef2094c..e22a8fb 100644 --- a/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedBigIntegerJavaType.java +++ b/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedBigIntegerJavaType.java @@ -1,6 +1,5 @@ package it.aboutbits.springboot.toolbox.persistence.javatype.base; -import it.aboutbits.springboot.toolbox.reflection.util.RecordReflectionUtil; import it.aboutbits.springboot.toolbox.type.CustomType; import lombok.SneakyThrows; import org.hibernate.type.descriptor.WrapperOptions; @@ -14,12 +13,16 @@ import java.sql.Types; public abstract class WrappedBigIntegerJavaType> extends AbstractClassJavaType { - private final transient Constructor canonicalConstructor; + private final transient Constructor constructor; protected WrappedBigIntegerJavaType(Class type) { super(type); - this.canonicalConstructor = RecordReflectionUtil.getCanonicalConstructor(type); + try { + this.constructor = type.getConstructor(BigInteger.class); + } catch (NoSuchMethodException e) { + throw new IllegalStateException("No constructor found for " + type.getName(), e); + } } @Override @@ -60,7 +63,7 @@ public T wrap(X value, WrapperOptions wrapperOptions) { return (T) value; } if (value instanceof Long longValue) { - return canonicalConstructor.newInstance(BigInteger.valueOf(longValue)); + return constructor.newInstance(BigInteger.valueOf(longValue)); } throw unknownWrap(value.getClass()); diff --git a/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedBooleanJavaType.java b/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedBooleanJavaType.java new file mode 100644 index 0000000..8ccc5c8 --- /dev/null +++ b/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedBooleanJavaType.java @@ -0,0 +1,70 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.base; + +import it.aboutbits.springboot.toolbox.type.CustomType; +import lombok.SneakyThrows; +import org.hibernate.type.descriptor.WrapperOptions; +import org.hibernate.type.descriptor.java.AbstractClassJavaType; +import org.hibernate.type.descriptor.jdbc.JdbcType; +import org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.sql.Types; + +public abstract class WrappedBooleanJavaType> extends AbstractClassJavaType { + private final transient Constructor constructor; + + protected WrappedBooleanJavaType(Class type) { + super(type); + + try { + this.constructor = type.getConstructor(Boolean.class); + } catch (NoSuchMethodException e) { + throw new IllegalStateException("No constructor found for " + type.getName(), e); + } + } + + @Override + public JdbcType getRecommendedJdbcType(JdbcTypeIndicators indicators) { + return indicators.getTypeConfiguration() + .getJdbcTypeRegistry() + .getDescriptor(Types.BOOLEAN); + } + + @SuppressWarnings("unchecked") + @Override + public X unwrap(T id, Class aClass, WrapperOptions wrapperOptions) { + var javaTypeClass = getJavaTypeClass(); + + if (id == null) { + return null; + } + if (javaTypeClass.isAssignableFrom(aClass)) { + return (X) id; + } + if (Boolean.class.isAssignableFrom(aClass)) { + return (X) id.value(); + } + + throw unknownUnwrap(aClass); + } + + @SuppressWarnings("unchecked") + @SneakyThrows({InstantiationException.class, IllegalAccessException.class, InvocationTargetException.class}) + @Override + public T wrap(X value, WrapperOptions wrapperOptions) { + var clazz = getJavaTypeClass(); + + if (value == null) { + return null; + } + if (clazz.isInstance(value)) { + return (T) value; + } + if (value instanceof Boolean booleanValue) { + return constructor.newInstance(booleanValue); + } + + throw unknownWrap(value.getClass()); + } +} diff --git a/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedByteJavaType.java b/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedByteJavaType.java new file mode 100644 index 0000000..300c4ed --- /dev/null +++ b/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedByteJavaType.java @@ -0,0 +1,70 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.base; + +import it.aboutbits.springboot.toolbox.type.CustomType; +import lombok.SneakyThrows; +import org.hibernate.type.descriptor.WrapperOptions; +import org.hibernate.type.descriptor.java.AbstractClassJavaType; +import org.hibernate.type.descriptor.jdbc.JdbcType; +import org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.sql.Types; + +public abstract class WrappedByteJavaType> extends AbstractClassJavaType { + private final transient Constructor constructor; + + protected WrappedByteJavaType(Class type) { + super(type); + + try { + this.constructor = type.getConstructor(Byte.class); + } catch (NoSuchMethodException e) { + throw new IllegalStateException("No constructor found for " + type.getName(), e); + } + } + + @Override + public JdbcType getRecommendedJdbcType(JdbcTypeIndicators indicators) { + return indicators.getTypeConfiguration() + .getJdbcTypeRegistry() + .getDescriptor(Types.TINYINT); + } + + @SuppressWarnings("unchecked") + @Override + public X unwrap(T id, Class aClass, WrapperOptions wrapperOptions) { + var javaTypeClass = getJavaTypeClass(); + + if (id == null) { + return null; + } + if (javaTypeClass.isAssignableFrom(aClass)) { + return (X) id; + } + if (Byte.class.isAssignableFrom(aClass)) { + return (X) id.value(); + } + + throw unknownUnwrap(aClass); + } + + @SuppressWarnings("unchecked") + @SneakyThrows({InstantiationException.class, IllegalAccessException.class, InvocationTargetException.class}) + @Override + public T wrap(X value, WrapperOptions wrapperOptions) { + var clazz = getJavaTypeClass(); + + if (value == null) { + return null; + } + if (clazz.isInstance(value)) { + return (T) value; + } + if (value instanceof Byte byteValue) { + return constructor.newInstance(byteValue); + } + + throw unknownWrap(value.getClass()); + } +} diff --git a/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedCharacterJavaType.java b/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedCharacterJavaType.java new file mode 100644 index 0000000..7400993 --- /dev/null +++ b/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedCharacterJavaType.java @@ -0,0 +1,76 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.base; + +import it.aboutbits.springboot.toolbox.type.CustomType; +import lombok.SneakyThrows; +import org.hibernate.type.descriptor.WrapperOptions; +import org.hibernate.type.descriptor.java.AbstractClassJavaType; +import org.hibernate.type.descriptor.jdbc.JdbcType; +import org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.sql.Types; + +public abstract class WrappedCharacterJavaType> extends AbstractClassJavaType { + private final transient Constructor constructor; + + protected WrappedCharacterJavaType(Class type) { + super(type); + + try { + this.constructor = type.getConstructor(Character.class); + } catch (NoSuchMethodException e) { + throw new IllegalStateException("No constructor found for " + type.getName(), e); + } + } + + @Override + public JdbcType getRecommendedJdbcType(JdbcTypeIndicators indicators) { + return indicators.getTypeConfiguration() + .getJdbcTypeRegistry() + .getDescriptor(Types.CHAR); + } + + @SuppressWarnings("unchecked") + @Override + public X unwrap(T id, Class aClass, WrapperOptions wrapperOptions) { + var javaTypeClass = getJavaTypeClass(); + + if (id == null) { + return null; + } + if (javaTypeClass.isAssignableFrom(aClass)) { + return (X) id; + } + if (Character.class.isAssignableFrom(aClass)) { + return (X) id.value(); + } + if (String.class.isAssignableFrom(aClass)) { + return (X) String.valueOf(id.value()); + } + + throw unknownUnwrap(aClass); + } + + @SuppressWarnings("unchecked") + @SneakyThrows({InstantiationException.class, IllegalAccessException.class, InvocationTargetException.class}) + @Override + public T wrap(X value, WrapperOptions wrapperOptions) { + var clazz = getJavaTypeClass(); + + if (value == null) { + return null; + } + if (clazz.isInstance(value)) { + return (T) value; + } + if (value instanceof Character charValue) { + return constructor.newInstance(charValue); + } + if (value instanceof String stringValue && stringValue.length() == 1) { + return constructor.newInstance(stringValue.charAt(0)); + } + + throw unknownWrap(value.getClass()); + } +} diff --git a/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedDoubleJavaType.java b/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedDoubleJavaType.java index 37a6b36..de8becf 100644 --- a/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedDoubleJavaType.java +++ b/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedDoubleJavaType.java @@ -1,6 +1,5 @@ package it.aboutbits.springboot.toolbox.persistence.javatype.base; -import it.aboutbits.springboot.toolbox.reflection.util.RecordReflectionUtil; import it.aboutbits.springboot.toolbox.type.CustomType; import lombok.SneakyThrows; import org.hibernate.type.descriptor.WrapperOptions; @@ -13,12 +12,16 @@ import java.sql.Types; public abstract class WrappedDoubleJavaType> extends AbstractClassJavaType { - private final transient Constructor canonicalConstructor; + private final transient Constructor constructor; protected WrappedDoubleJavaType(Class type) { super(type); - this.canonicalConstructor = RecordReflectionUtil.getCanonicalConstructor(type); + try { + this.constructor = type.getConstructor(Double.class); + } catch (NoSuchMethodException e) { + throw new IllegalStateException("No constructor found for " + type.getName(), e); + } } @Override @@ -59,7 +62,7 @@ public T wrap(X value, WrapperOptions wrapperOptions) { return (T) value; } if (value instanceof Double doubleValue) { - return canonicalConstructor.newInstance(doubleValue); + return constructor.newInstance(doubleValue); } throw unknownWrap(value.getClass()); diff --git a/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedFloatJavaType.java b/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedFloatJavaType.java index c862e39..271daae 100644 --- a/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedFloatJavaType.java +++ b/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedFloatJavaType.java @@ -1,6 +1,5 @@ package it.aboutbits.springboot.toolbox.persistence.javatype.base; -import it.aboutbits.springboot.toolbox.reflection.util.RecordReflectionUtil; import it.aboutbits.springboot.toolbox.type.CustomType; import lombok.SneakyThrows; import org.hibernate.type.descriptor.WrapperOptions; @@ -13,12 +12,16 @@ import java.sql.Types; public abstract class WrappedFloatJavaType> extends AbstractClassJavaType { - private final transient Constructor canonicalConstructor; + private final transient Constructor constructor; protected WrappedFloatJavaType(Class type) { super(type); - this.canonicalConstructor = RecordReflectionUtil.getCanonicalConstructor(type); + try { + this.constructor = type.getConstructor(Float.class); + } catch (NoSuchMethodException e) { + throw new IllegalStateException("No constructor found for " + type.getName(), e); + } } @Override @@ -59,7 +62,7 @@ public T wrap(X value, WrapperOptions wrapperOptions) { return (T) value; } if (value instanceof Float floatValue) { - return canonicalConstructor.newInstance(floatValue); + return constructor.newInstance(floatValue); } throw unknownWrap(value.getClass()); diff --git a/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedIntegerJavaType.java b/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedIntegerJavaType.java index 8c4d933..8a97853 100644 --- a/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedIntegerJavaType.java +++ b/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedIntegerJavaType.java @@ -1,6 +1,5 @@ package it.aboutbits.springboot.toolbox.persistence.javatype.base; -import it.aboutbits.springboot.toolbox.reflection.util.RecordReflectionUtil; import it.aboutbits.springboot.toolbox.type.CustomType; import lombok.SneakyThrows; import org.hibernate.type.descriptor.WrapperOptions; @@ -13,12 +12,16 @@ import java.sql.Types; public abstract class WrappedIntegerJavaType> extends AbstractClassJavaType { - private final transient Constructor canonicalConstructor; + private final transient Constructor constructor; protected WrappedIntegerJavaType(Class type) { super(type); - this.canonicalConstructor = RecordReflectionUtil.getCanonicalConstructor(type); + try { + this.constructor = type.getConstructor(Integer.class); + } catch (NoSuchMethodException e) { + throw new IllegalStateException("No constructor found for " + type.getName(), e); + } } @Override @@ -59,7 +62,7 @@ public T wrap(X value, WrapperOptions wrapperOptions) { return (T) value; } if (value instanceof Integer integerValue) { - return canonicalConstructor.newInstance(integerValue); + return constructor.newInstance(integerValue); } throw unknownWrap(value.getClass()); diff --git a/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedLongJavaType.java b/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedLongJavaType.java index 4949394..eadaddb 100644 --- a/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedLongJavaType.java +++ b/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedLongJavaType.java @@ -1,6 +1,5 @@ package it.aboutbits.springboot.toolbox.persistence.javatype.base; -import it.aboutbits.springboot.toolbox.reflection.util.RecordReflectionUtil; import it.aboutbits.springboot.toolbox.type.CustomType; import lombok.SneakyThrows; import org.hibernate.type.descriptor.WrapperOptions; @@ -13,12 +12,16 @@ import java.sql.Types; public abstract class WrappedLongJavaType> extends AbstractClassJavaType { - private final transient Constructor canonicalConstructor; + private final transient Constructor constructor; protected WrappedLongJavaType(Class type) { super(type); - this.canonicalConstructor = RecordReflectionUtil.getCanonicalConstructor(type); + try { + this.constructor = type.getConstructor(Long.class); + } catch (NoSuchMethodException e) { + throw new IllegalStateException("No constructor found for " + type.getName(), e); + } } @Override @@ -59,7 +62,7 @@ public T wrap(X value, WrapperOptions wrapperOptions) { return (T) value; } if (value instanceof Long longValue) { - return canonicalConstructor.newInstance(longValue); + return constructor.newInstance(longValue); } throw unknownWrap(value.getClass()); diff --git a/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedScaledBigDecimalJavaType.java b/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedScaledBigDecimalJavaType.java index 3450c14..db7cd1a 100644 --- a/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedScaledBigDecimalJavaType.java +++ b/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedScaledBigDecimalJavaType.java @@ -1,6 +1,5 @@ package it.aboutbits.springboot.toolbox.persistence.javatype.base; -import it.aboutbits.springboot.toolbox.reflection.util.RecordReflectionUtil; import it.aboutbits.springboot.toolbox.type.CustomType; import it.aboutbits.springboot.toolbox.type.ScaledBigDecimal; import lombok.SneakyThrows; @@ -14,12 +13,16 @@ import java.sql.Types; public abstract class WrappedScaledBigDecimalJavaType> extends AbstractClassJavaType { - private final transient Constructor canonicalConstructor; + private final transient Constructor constructor; protected WrappedScaledBigDecimalJavaType(Class type) { super(type); - this.canonicalConstructor = RecordReflectionUtil.getCanonicalConstructor(type); + try { + this.constructor = type.getConstructor(ScaledBigDecimal.class); + } catch (NoSuchMethodException e) { + throw new IllegalStateException("No constructor found for " + type.getName(), e); + } } @Override @@ -60,7 +63,7 @@ public T wrap(X value, WrapperOptions wrapperOptions) { return (T) value; } if (value instanceof Double doubleValue) { - return canonicalConstructor.newInstance(new ScaledBigDecimal(doubleValue)); + return constructor.newInstance(new ScaledBigDecimal(doubleValue)); } throw unknownWrap(value.getClass()); diff --git a/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedShortJavaType.java b/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedShortJavaType.java index b5782fa..3dac3f0 100644 --- a/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedShortJavaType.java +++ b/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedShortJavaType.java @@ -1,6 +1,5 @@ package it.aboutbits.springboot.toolbox.persistence.javatype.base; -import it.aboutbits.springboot.toolbox.reflection.util.RecordReflectionUtil; import it.aboutbits.springboot.toolbox.type.CustomType; import lombok.SneakyThrows; import org.hibernate.type.descriptor.WrapperOptions; @@ -13,12 +12,16 @@ import java.sql.Types; public abstract class WrappedShortJavaType> extends AbstractClassJavaType { - private final transient Constructor canonicalConstructor; + private final transient Constructor constructor; protected WrappedShortJavaType(Class type) { super(type); - this.canonicalConstructor = RecordReflectionUtil.getCanonicalConstructor(type); + try { + this.constructor = type.getConstructor(Short.class); + } catch (NoSuchMethodException e) { + throw new IllegalStateException("No constructor found for " + type.getName(), e); + } } @Override @@ -59,7 +62,7 @@ public T wrap(X value, WrapperOptions wrapperOptions) { return (T) value; } if (value instanceof Short shortValue) { - return canonicalConstructor.newInstance(shortValue); + return constructor.newInstance(shortValue); } throw unknownWrap(value.getClass()); diff --git a/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedStringJavaType.java b/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedStringJavaType.java index 35b9fd6..fcd7a46 100644 --- a/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedStringJavaType.java +++ b/src/main/java/it/aboutbits/springboot/toolbox/persistence/javatype/base/WrappedStringJavaType.java @@ -1,6 +1,5 @@ package it.aboutbits.springboot.toolbox.persistence.javatype.base; -import it.aboutbits.springboot.toolbox.reflection.util.RecordReflectionUtil; import it.aboutbits.springboot.toolbox.type.CustomType; import lombok.SneakyThrows; import org.hibernate.type.descriptor.WrapperOptions; @@ -13,12 +12,16 @@ import java.sql.Types; public abstract class WrappedStringJavaType> extends AbstractClassJavaType { - private final transient Constructor canonicalConstructor; + private final transient Constructor constructor; protected WrappedStringJavaType(Class type) { super(type); - this.canonicalConstructor = RecordReflectionUtil.getCanonicalConstructor(type); + try { + this.constructor = type.getConstructor(String.class); + } catch (NoSuchMethodException e) { + throw new IllegalStateException("No constructor found for " + type.getName(), e); + } } @Override @@ -59,7 +62,7 @@ public T wrap(X value, WrapperOptions wrapperOptions) { return (T) value; } if (value instanceof String stringValue) { - return canonicalConstructor.newInstance(stringValue); + return constructor.newInstance(stringValue); } throw unknownWrap(value.getClass()); diff --git a/src/main/java/it/aboutbits/springboot/toolbox/reflection/util/CustomTypeReflectionUtil.java b/src/main/java/it/aboutbits/springboot/toolbox/reflection/util/CustomTypeReflectionUtil.java new file mode 100644 index 0000000..a8700a6 --- /dev/null +++ b/src/main/java/it/aboutbits/springboot/toolbox/reflection/util/CustomTypeReflectionUtil.java @@ -0,0 +1,44 @@ +package it.aboutbits.springboot.toolbox.reflection.util; + +import it.aboutbits.springboot.toolbox.type.CustomType; + +import java.lang.reflect.Constructor; +import java.lang.reflect.ParameterizedType; +import java.util.Arrays; + +public final class CustomTypeReflectionUtil { + private CustomTypeReflectionUtil() { + } + + public static > Constructor getCustomTypeConstructor(Class customType) throws NoSuchMethodException { + try { + return customType.getConstructor( + getWrappedType(customType) + ); + } catch (NoSuchMethodException | SecurityException e) { + throw new NoSuchMethodException(); + } + } + + public static Class getWrappedType(Class> customType) throws NoSuchMethodException { + Class currentClass = customType; + while (currentClass != null) { + // Check interfaces of the current class + var customTypeInterface = Arrays.stream(currentClass.getGenericInterfaces()) + .filter(i -> + i instanceof ParameterizedType + && CustomType.class.isAssignableFrom((Class) ((ParameterizedType) i).getRawType()) + ).findFirst() + .map(i -> (ParameterizedType) i); + + if (customTypeInterface.isPresent()) { + return (Class) customTypeInterface.get().getActualTypeArguments()[0]; + } + + // Move to the parent class + currentClass = currentClass.getSuperclass(); + } + + throw new NoSuchMethodException(); + } +} diff --git a/src/main/java/it/aboutbits/springboot/toolbox/swagger/type/CustomTypeModelConverter.java b/src/main/java/it/aboutbits/springboot/toolbox/swagger/type/CustomTypeModelConverter.java index 4f66df2..66e1e77 100644 --- a/src/main/java/it/aboutbits/springboot/toolbox/swagger/type/CustomTypeModelConverter.java +++ b/src/main/java/it/aboutbits/springboot/toolbox/swagger/type/CustomTypeModelConverter.java @@ -4,11 +4,12 @@ import io.swagger.v3.core.converter.ModelConverter; import io.swagger.v3.core.converter.ModelConverterContext; import io.swagger.v3.oas.models.media.Schema; -import it.aboutbits.springboot.toolbox.reflection.util.RecordReflectionUtil; +import it.aboutbits.springboot.toolbox.reflection.util.CustomTypeReflectionUtil; import it.aboutbits.springboot.toolbox.swagger.SwaggerMetaUtil; import it.aboutbits.springboot.toolbox.type.CustomType; import it.aboutbits.springboot.toolbox.type.ScaledBigDecimal; import it.aboutbits.springboot.toolbox.type.identity.EntityId; +import lombok.SneakyThrows; import java.math.BigDecimal; import java.math.BigInteger; @@ -17,6 +18,7 @@ public class CustomTypeModelConverter implements ModelConverter { @Override + @SneakyThrows(NoSuchMethodException.class) public Schema resolve( AnnotatedType annotatedType, ModelConverterContext context, @@ -28,9 +30,17 @@ public Schema resolve( if (type instanceof Class clazz) { Schema result = null; if (CustomType.class.isAssignableFrom(clazz)) { - var constructor = RecordReflectionUtil.getCanonicalConstructor(clazz); - var wrappedType = constructor.getParameters()[0].getType(); + @SuppressWarnings("unchecked") + var wrappedType = CustomTypeReflectionUtil.getWrappedType( + (Class>) clazz + ); + if (Boolean.class.isAssignableFrom(wrappedType)) { + result = context.resolve(new AnnotatedType(Boolean.TYPE)); + } + if (Byte.class.isAssignableFrom(wrappedType)) { + result = context.resolve(new AnnotatedType(Byte.TYPE)); + } if (Short.class.isAssignableFrom(wrappedType)) { result = context.resolve(new AnnotatedType(Short.TYPE)); } @@ -58,6 +68,9 @@ public Schema resolve( if (String.class.isAssignableFrom(wrappedType)) { result = context.resolve(new AnnotatedType(String.class)); } + if (Character.class.isAssignableFrom(wrappedType)) { + result = context.resolve(new AnnotatedType(Character.TYPE)); + } if (result != null) { var isIdentity = EntityId.class.isAssignableFrom(clazz); diff --git a/src/main/java/it/aboutbits/springboot/toolbox/swagger/type/CustomTypePropertyCustomizer.java b/src/main/java/it/aboutbits/springboot/toolbox/swagger/type/CustomTypePropertyCustomizer.java index bd58893..169e024 100644 --- a/src/main/java/it/aboutbits/springboot/toolbox/swagger/type/CustomTypePropertyCustomizer.java +++ b/src/main/java/it/aboutbits/springboot/toolbox/swagger/type/CustomTypePropertyCustomizer.java @@ -3,11 +3,12 @@ import com.fasterxml.jackson.databind.type.SimpleType; import io.swagger.v3.core.converter.AnnotatedType; import io.swagger.v3.oas.models.media.Schema; -import it.aboutbits.springboot.toolbox.reflection.util.RecordReflectionUtil; +import it.aboutbits.springboot.toolbox.reflection.util.CustomTypeReflectionUtil; import it.aboutbits.springboot.toolbox.swagger.SwaggerMetaUtil; import it.aboutbits.springboot.toolbox.type.CustomType; import it.aboutbits.springboot.toolbox.type.ScaledBigDecimal; import it.aboutbits.springboot.toolbox.type.identity.EntityId; +import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.springdoc.core.customizers.PropertyCustomizer; @@ -17,6 +18,7 @@ @Slf4j public class CustomTypePropertyCustomizer implements PropertyCustomizer { @Override + @SneakyThrows(NoSuchMethodException.class) public Schema customize(Schema property, AnnotatedType annotatedType) { var type = annotatedType.getType(); @@ -30,19 +32,32 @@ public Schema customize(Schema property, AnnotatedType annotatedType) { )); } - if (CustomType.class.isAssignableFrom(simpleType.getRawClass())) { - Class wrappedType; - if (rawClass.equals(EntityId.class)) { - wrappedType = simpleType.getBindings().getBoundType(0).getRawClass(); - } else { - var constructor = RecordReflectionUtil.getCanonicalConstructor(rawClass); - wrappedType = constructor.getParameters()[0].getType(); - } + if (CustomType.class.isAssignableFrom(rawClass)) { + @SuppressWarnings("unchecked") + var wrappedType = CustomTypeReflectionUtil.getWrappedType( + (Class>) rawClass + ); var isIdentity = EntityId.class.isAssignableFrom(rawClass); var description = SwaggerMetaUtil.setIsIdentity(property.getDescription(), isIdentity); + if (Boolean.class.isAssignableFrom(wrappedType)) { + property.type("boolean"); + property.format(null); + property.setDescription(description); + property.setProperties(null); + property.set$ref(null); + return property; + } + if (Byte.class.isAssignableFrom(wrappedType)) { + property.type("integer"); + property.format(""); + property.setDescription(description); + property.setProperties(null); + property.set$ref(null); + return property; + } if (Short.class.isAssignableFrom(wrappedType)) { property.type("integer"); property.format(""); @@ -99,7 +114,6 @@ public Schema customize(Schema property, AnnotatedType annotatedType) { property.set$ref(null); return property; } - if (ScaledBigDecimal.class.isAssignableFrom(wrappedType)) { property.type("number"); property.format(""); @@ -116,6 +130,17 @@ public Schema customize(Schema property, AnnotatedType annotatedType) { property.set$ref(null); return property; } + if (Character.class.isAssignableFrom(wrappedType)) { + property.type("string"); + property.format(null); + property.minLength(1); + property.maxLength(1); + property.setDescription(description); + property.setProperties(null); + property.set$ref(null); + return property; + } + log.warn("Property {} of type WrappedValue: Can not resolve parameter type!", property.getName()); } } diff --git a/src/main/java/it/aboutbits/springboot/toolbox/web/CustomTypePropertyEditor.java b/src/main/java/it/aboutbits/springboot/toolbox/web/CustomTypePropertyEditor.java index f8e57de..e76a007 100644 --- a/src/main/java/it/aboutbits/springboot/toolbox/web/CustomTypePropertyEditor.java +++ b/src/main/java/it/aboutbits/springboot/toolbox/web/CustomTypePropertyEditor.java @@ -1,10 +1,10 @@ package it.aboutbits.springboot.toolbox.web; -import it.aboutbits.springboot.toolbox.reflection.util.RecordReflectionUtil; +import it.aboutbits.springboot.toolbox.jackson.CustomTypeDeserializer; +import it.aboutbits.springboot.toolbox.reflection.util.CustomTypeReflectionUtil; import it.aboutbits.springboot.toolbox.type.CustomType; import it.aboutbits.springboot.toolbox.type.ScaledBigDecimal; import lombok.NonNull; -import lombok.SneakyThrows; import org.springframework.lang.Nullable; import java.beans.PropertyEditorSupport; @@ -18,9 +18,16 @@ public final class CustomTypePropertyEditor> extends Pro private final Constructor constructor; private final Function typeConverter; - @SneakyThrows public CustomTypePropertyEditor(@NonNull Class customType) { - this.constructor = RecordReflectionUtil.getCanonicalConstructor(customType); + try { + this.constructor = CustomTypeReflectionUtil.getCustomTypeConstructor(customType); + } catch (NoSuchMethodException e) { + throw new CustomTypeDeserializer.CustomTypeDeserializerException( + "Unable to find constructor for type: " + customType.getName(), + e + ); + } + this.typeConverter = getTextToTypeConverter( constructor.getParameters()[0].getType() ); @@ -52,9 +59,23 @@ public void setAsText(String text) throws IllegalArgumentException { } private static Function getTextToTypeConverter(Class wrappedType) { + if (Boolean.class.isAssignableFrom(wrappedType)) { + return Boolean::parseBoolean; + } if (String.class.isAssignableFrom(wrappedType)) { return text -> text; } + if (Character.class.isAssignableFrom(wrappedType)) { + return text -> { + if (text == null || text.length() != 1) { + throw new IllegalArgumentException("Unable to convert text to type: " + wrappedType.getName()); + } + return text.charAt(0); + }; + } + if (Byte.class.isAssignableFrom(wrappedType)) { + return Byte::parseByte; + } if (Short.class.isAssignableFrom(wrappedType)) { return Short::parseShort; } diff --git a/src/test/java/it/aboutbits/springboot/toolbox/autoconfiguration/persistence/impl/jpa/CustomTypeTestModel.java b/src/test/java/it/aboutbits/springboot/toolbox/autoconfiguration/persistence/impl/jpa/CustomTypeTestModel.java index 73e2d15..08db44d 100644 --- a/src/test/java/it/aboutbits/springboot/toolbox/autoconfiguration/persistence/impl/jpa/CustomTypeTestModel.java +++ b/src/test/java/it/aboutbits/springboot/toolbox/autoconfiguration/persistence/impl/jpa/CustomTypeTestModel.java @@ -1,8 +1,6 @@ package it.aboutbits.springboot.toolbox.autoconfiguration.persistence.impl.jpa; import it.aboutbits.springboot.toolbox.autoconfiguration.persistence.AutoRegisteredJavaType; -import it.aboutbits.springboot.toolbox.type.identity.EntityId; -import it.aboutbits.springboot.toolbox.type.identity.Identified; import it.aboutbits.springboot.toolbox.persistence.javatype.EmailAddressJavaType; import it.aboutbits.springboot.toolbox.persistence.javatype.IbanJavaType; import it.aboutbits.springboot.toolbox.persistence.javatype.ScaledBigDecimalJavaType; @@ -10,6 +8,8 @@ import it.aboutbits.springboot.toolbox.type.EmailAddress; import it.aboutbits.springboot.toolbox.type.Iban; import it.aboutbits.springboot.toolbox.type.ScaledBigDecimal; +import it.aboutbits.springboot.toolbox.type.identity.EntityId; +import it.aboutbits.springboot.toolbox.type.identity.Identified; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; diff --git a/src/test/java/it/aboutbits/springboot/toolbox/autoconfiguration/persistence/impl/jpa/ReferencedTestModel.java b/src/test/java/it/aboutbits/springboot/toolbox/autoconfiguration/persistence/impl/jpa/ReferencedTestModel.java index 38ca9a7..9c646bc 100644 --- a/src/test/java/it/aboutbits/springboot/toolbox/autoconfiguration/persistence/impl/jpa/ReferencedTestModel.java +++ b/src/test/java/it/aboutbits/springboot/toolbox/autoconfiguration/persistence/impl/jpa/ReferencedTestModel.java @@ -1,8 +1,8 @@ package it.aboutbits.springboot.toolbox.autoconfiguration.persistence.impl.jpa; import it.aboutbits.springboot.toolbox.autoconfiguration.persistence.AutoRegisteredJavaType; -import it.aboutbits.springboot.toolbox.type.identity.EntityId; import it.aboutbits.springboot.toolbox.persistence.javatype.base.WrappedLongJavaType; +import it.aboutbits.springboot.toolbox.type.identity.EntityId; public class ReferencedTestModel { // we just use this to have and ID we can actually reference diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/WrapperTypesJpaTest.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/WrapperTypesJpaTest.java index c54b8b3..54a8779 100644 --- a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/WrapperTypesJpaTest.java +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/WrapperTypesJpaTest.java @@ -2,15 +2,30 @@ import it.aboutbits.springboot.toolbox.persistence.javatype.impl.jpa.WrapperTypesModel; import it.aboutbits.springboot.toolbox.persistence.javatype.impl.jpa.WrapperTypesModelRepository; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBigDecimal; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBigInteger; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapDouble; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapFloat; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapInteger; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapLong; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapScaledBigDecimal; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapShort; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapString; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBigDecimalClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBigDecimalRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBigIntegerClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBigIntegerRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBooleanClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBooleanRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapByteClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapByteRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapCharacterClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapCharacterRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapDoubleClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapDoubleRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapFloatClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapFloatRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapIntegerClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapIntegerRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapLongClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapLongRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapScaledBigDecimalClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapScaledBigDecimalRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapShortClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapShortRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapStringClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapStringRecord; import it.aboutbits.springboot.toolbox.support.ApplicationTest; import it.aboutbits.springboot.toolbox.type.ScaledBigDecimal; import org.junit.jupiter.api.Nested; @@ -30,308 +45,824 @@ public class WrapperTypesJpaTest { WrapperTypesModelRepository repository; @Nested - class WrapBigDecimalType { - @Test - void givenNull_inAndOut_shouldSucceed() { - var item = new WrapperTypesModel(); - item.setBigDecimalValue(null); + class RecordTypes { + @Nested + class WrapBigDecimalRecordType { + @Test + void givenNull_inAndOut_shouldSucceed() { + var item = new WrapperTypesModel(); + item.setBigDecimalValue(null); + + var savedItem = repository.save(item); + + var retrievedItem = repository.findByBigDecimalValue(null); + + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } + + @ParameterizedTest + @ValueSource(doubles = {-1, 0, 1, -0.001d, 0.001d, -100_000_000, 100_000_000}) + void givenValues_inAndOut_shouldSucceed(double doubleValue) { + var item = new WrapperTypesModel(); + item.setBigDecimalValue(new WrapBigDecimalRecord(BigDecimal.valueOf(doubleValue))); + + var savedItem = repository.save(item); + + var retrievedItem = repository.findByBigDecimalValue(savedItem.getBigDecimalValue()); + + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } + } + + @Nested + class WrapBigIntegerRecordType { + @Test + void givenNull_inAndOut_shouldSucceed() { + var item = new WrapperTypesModel(); + item.setBigIntegerValue(null); + + var savedItem = repository.save(item); + + var retrievedItem = repository.findByBigIntegerValue(null); - var savedItem = repository.save(item); + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } - var retrievedItem = repository.findByBigDecimalValue(null); + @ParameterizedTest + @ValueSource(ints = {-1, 0, 1, -100_000_000, 100_000_000}) + void givenValues_inAndOut_shouldSucceed(int intValue) { + var item = new WrapperTypesModel(); + item.setBigIntegerValue(new WrapBigIntegerRecord(BigInteger.valueOf(intValue))); - assertThat(retrievedItem).isPresent() - .get() - .usingRecursiveComparison() - .isEqualTo(savedItem); + var savedItem = repository.save(item); + + var retrievedItem = repository.findByBigIntegerValue(savedItem.getBigIntegerValue()); + + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } } - @ParameterizedTest - @ValueSource(doubles = {-1, 0, 1, -0.001, 0.001, -100_000_000, 100_000_000}) - void givenValues_inAndOut_shouldSucceed(double doubleValue) { - var item = new WrapperTypesModel(); - item.setBigDecimalValue(new WrapBigDecimal(BigDecimal.valueOf(doubleValue))); + @Nested + class WrapDoubleRecordType { + @Test + void givenNull_inAndOut_shouldSucceed() { + var item = new WrapperTypesModel(); + item.setDoubleValue(null); + + var savedItem = repository.save(item); + + var retrievedItem = repository.findByDoubleValue(null); - var savedItem = repository.save(item); + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } - var retrievedItem = repository.findByBigDecimalValue(savedItem.getBigDecimalValue()); + @ParameterizedTest + @ValueSource(doubles = {-1, 0, 1, -0.001d, 0.001d, -100_000_000, 100_000_000}) + void givenValues_inAndOut_shouldSucceed(double doubleValue) { + var item = new WrapperTypesModel(); + item.setDoubleValue(new WrapDoubleRecord(doubleValue)); - assertThat(retrievedItem).isPresent() - .get() - .usingRecursiveComparison() - .isEqualTo(savedItem); + var savedItem = repository.save(item); + + var retrievedItem = repository.findByDoubleValue(savedItem.getDoubleValue()); + + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } } - } - @Nested - class WrapBigIntegerType { - @Test - void givenNull_inAndOut_shouldSucceed() { - var item = new WrapperTypesModel(); - item.setBigIntegerValue(null); + @Nested + class WrapFloatRecordType { + @Test + void givenNull_inAndOut_shouldSucceed() { + var item = new WrapperTypesModel(); + item.setFloatValue(null); + + var savedItem = repository.save(item); + + var retrievedItem = repository.findByFloatValue(null); + + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } + + @ParameterizedTest + @ValueSource(floats = {-1, 0, 1, -0.001f, 0.001f, -100_000_000, 100_000_000}) + void givenValues_inAndOut_shouldSucceed(float floatValue) { + var item = new WrapperTypesModel(); + item.setFloatValue(new WrapFloatRecord(floatValue)); - var savedItem = repository.save(item); + var savedItem = repository.save(item); - var retrievedItem = repository.findByBigIntegerValue(null); + var retrievedItem = repository.findByFloatValue(savedItem.getFloatValue()); - assertThat(retrievedItem).isPresent() - .get() - .usingRecursiveComparison() - .isEqualTo(savedItem); + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } } - @ParameterizedTest - @ValueSource(ints = {-1, 0, 1, -100_000_000, 100_000_000}) - void givenValues_inAndOut_shouldSucceed(int intValue) { - var item = new WrapperTypesModel(); - item.setBigIntegerValue(new WrapBigInteger(BigInteger.valueOf(intValue))); + @Nested + class WrapIntegerRecordType { + @Test + void givenNull_inAndOut_shouldSucceed() { + var item = new WrapperTypesModel(); + item.setIntegerValue(null); - var savedItem = repository.save(item); + var savedItem = repository.save(item); - var retrievedItem = repository.findByBigIntegerValue(savedItem.getBigIntegerValue()); + var retrievedItem = repository.findByIntegerValue(null); - assertThat(retrievedItem).isPresent() - .get() - .usingRecursiveComparison() - .isEqualTo(savedItem); + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } + + @ParameterizedTest + @ValueSource(ints = {-1, 0, 1, -100_000_000, 100_000_000}) + void givenValues_inAndOut_shouldSucceed(int intValue) { + var item = new WrapperTypesModel(); + item.setIntegerValue(new WrapIntegerRecord(intValue)); + + var savedItem = repository.save(item); + + var retrievedItem = repository.findByIntegerValue(savedItem.getIntegerValue()); + + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } } - } - @Nested - class WrapDoubleType { - @Test - void givenNull_inAndOut_shouldSucceed() { - var item = new WrapperTypesModel(); - item.setDoubleValue(null); + @Nested + class WrapLongRecordType { + @Test + void givenNull_inAndOut_shouldSucceed() { + var item = new WrapperTypesModel(); + item.setLongValue(null); + + var savedItem = repository.save(item); + + var retrievedItem = repository.findByLongValue(null); - var savedItem = repository.save(item); + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } - var retrievedItem = repository.findByDoubleValue(null); + @ParameterizedTest + @ValueSource(longs = {-1, 0, 1, -100_000_000, 100_000_000}) + void givenValues_inAndOut_shouldSucceed(long longValue) { + var item = new WrapperTypesModel(); + item.setLongValue(new WrapLongRecord(longValue)); - assertThat(retrievedItem).isPresent() - .get() - .usingRecursiveComparison() - .isEqualTo(savedItem); + var savedItem = repository.save(item); + + var retrievedItem = repository.findByLongValue(savedItem.getLongValue()); + + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } } - @ParameterizedTest - @ValueSource(doubles = {-1, 0, 1, -0.001, 0.001, -100_000_000, 100_000_000}) - void givenValues_inAndOut_shouldSucceed(double doubleValue) { - var item = new WrapperTypesModel(); - item.setDoubleValue(new WrapDouble(doubleValue)); + @Nested + class WrapScaledBigDecimalRecordType { + @Test + void givenNull_inAndOut_shouldSucceed() { + var item = new WrapperTypesModel(); + item.setScaledBigDecimalValue(null); + + var savedItem = repository.save(item); + + var retrievedItem = repository.findByScaledBigDecimalValue(null); - var savedItem = repository.save(item); + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } - var retrievedItem = repository.findByDoubleValue(savedItem.getDoubleValue()); + @ParameterizedTest + @ValueSource(doubles = {-1, 0, 1, -0.001d, 0.001d, -100_000_000, 100_000_000}) + void givenValues_inAndOut_shouldSucceed(double doubleValue) { + var item = new WrapperTypesModel(); + item.setScaledBigDecimalValue(new WrapScaledBigDecimalRecord(new ScaledBigDecimal(doubleValue))); - assertThat(retrievedItem).isPresent() - .get() - .usingRecursiveComparison() - .isEqualTo(savedItem); + var savedItem = repository.save(item); + + var retrievedItem = repository.findByScaledBigDecimalValue(savedItem.getScaledBigDecimalValue()); + + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } } - } - @Nested - class WrapFloatType { - @Test - void givenNull_inAndOut_shouldSucceed() { - var item = new WrapperTypesModel(); - item.setFloatValue(null); + @Nested + class WrapShortRecordType { + @Test + void givenNull_inAndOut_shouldSucceed() { + var item = new WrapperTypesModel(); + item.setShortValue(null); - var savedItem = repository.save(item); + var savedItem = repository.save(item); - var retrievedItem = repository.findByFloatValue(null); + var retrievedItem = repository.findByShortValue(null); - assertThat(retrievedItem).isPresent() - .get() - .usingRecursiveComparison() - .isEqualTo(savedItem); + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } + + @ParameterizedTest + @ValueSource(shorts = {-1, 0, 1, -10_000, 10_000}) + void givenValues_inAndOut_shouldSucceed(short shortValue) { + var item = new WrapperTypesModel(); + item.setShortValue(new WrapShortRecord(shortValue)); + + var savedItem = repository.save(item); + + var retrievedItem = repository.findByShortValue(savedItem.getShortValue()); + + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } } - @ParameterizedTest - @ValueSource(floats = {-1, 0, 1, -0.001f, 0.001f, -100_000_000, 100_000_000}) - void givenValues_inAndOut_shouldSucceed(float floatValue) { - var item = new WrapperTypesModel(); - item.setFloatValue(new WrapFloat(floatValue)); + @Nested + class WrapStringRecordType { + @Test + void givenNull_inAndOut_shouldSucceed() { + var item = new WrapperTypesModel(); + item.setStringValue(null); + + var savedItem = repository.save(item); + + var retrievedItem = repository.findByStringValue(null); + + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } + + @ParameterizedTest + @ValueSource(strings = {"", " ", "test", "some longer test", "\r", "\n"}) + void givenValues_inAndOut_shouldSucceed(String stringValue) { + var item = new WrapperTypesModel(); + item.setStringValue(new WrapStringRecord(stringValue)); - var savedItem = repository.save(item); + var savedItem = repository.save(item); - var retrievedItem = repository.findByFloatValue(savedItem.getFloatValue()); + var retrievedItem = repository.findByStringValue(savedItem.getStringValue()); - assertThat(retrievedItem).isPresent() - .get() - .usingRecursiveComparison() - .isEqualTo(savedItem); + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } } - } - @Nested - class WrapIntegerType { - @Test - void givenNull_inAndOut_shouldSucceed() { - var item = new WrapperTypesModel(); - item.setIntegerValue(null); + @Nested + class WrapCharacterRecordType { + @Test + void givenNull_inAndOut_shouldSucceed() { + var item = new WrapperTypesModel(); + item.setCharValue(null); + + var savedItem = repository.save(item); + + var retrievedItem = repository.findByCharValue(null); - var savedItem = repository.save(item); + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } - var retrievedItem = repository.findByIntegerValue(null); + @ParameterizedTest + @ValueSource(chars = {'t', 's', '\r', '\n'}) + void givenValues_inAndOut_shouldSucceed(Character charValue) { + var item = new WrapperTypesModel(); + item.setCharValue(new WrapCharacterRecord(charValue)); - assertThat(retrievedItem).isPresent() - .get() - .usingRecursiveComparison() - .isEqualTo(savedItem); + var savedItem = repository.save(item); + + var retrievedItem = repository.findByCharValue(savedItem.getCharValue()); + + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } } - @ParameterizedTest - @ValueSource(ints = {-1, 0, 1, -100_000_000, 100_000_000}) - void givenValues_inAndOut_shouldSucceed(int intValue) { - var item = new WrapperTypesModel(); - item.setIntegerValue(new WrapInteger(intValue)); + @Nested + class WrapByteRecordType { + @Test + void givenNull_inAndOut_shouldSucceed() { + var item = new WrapperTypesModel(); + item.setByteValue(null); + + var savedItem = repository.save(item); + + var retrievedItem = repository.findByByteValue(null); - var savedItem = repository.save(item); + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } - var retrievedItem = repository.findByIntegerValue(savedItem.getIntegerValue()); + @ParameterizedTest + @ValueSource(bytes = {-1, 0, 1, -128, 127}) + void givenValues_inAndOut_shouldSucceed(Byte byteValue) { + var item = new WrapperTypesModel(); + item.setByteValue(new WrapByteRecord(byteValue)); - assertThat(retrievedItem).isPresent() - .get() - .usingRecursiveComparison() - .isEqualTo(savedItem); + var savedItem = repository.save(item); + + var retrievedItem = repository.findByByteValue(savedItem.getByteValue()); + + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } + } + + @Nested + class WrapBooleanRecordType { + @Test + void givenNull_inAndOut_shouldSucceed() { + var item = new WrapperTypesModel(); + item.setBoolValue(null); + + var savedItem = repository.save(item); + + var retrievedItem = repository.findByBoolValue(null); + + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } + + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void givenValues_inAndOut_shouldSucceed(Boolean boolValue) { + var item = new WrapperTypesModel(); + item.setBoolValue(new WrapBooleanRecord(boolValue)); + + var savedItem = repository.save(item); + + var retrievedItem = repository.findByBoolValue(savedItem.getBoolValue()); + + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } } } @Nested - class WrapLongType { - @Test - void givenNull_inAndOut_shouldSucceed() { - var item = new WrapperTypesModel(); - item.setLongValue(null); + class ClassTypes { + @Nested + class WrapBigDecimalClassType { + @Test + void givenNull_inAndOut_shouldSucceed() { + var item = new WrapperTypesModel(); + item.setBigDecimalValueClass(null); + + var savedItem = repository.save(item); + + var retrievedItem = repository.findByBigDecimalValueClass(null); + + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } + + @ParameterizedTest + @ValueSource(doubles = {-1, 0, 1, -0.001d, 0.001d, -100_000_000, 100_000_000}) + void givenValues_inAndOut_shouldSucceed(double doubleValue) { + var item = new WrapperTypesModel(); + item.setBigDecimalValueClass(new WrapBigDecimalClass(BigDecimal.valueOf(doubleValue))); + + var savedItem = repository.save(item); + + var retrievedItem = repository.findByBigDecimalValueClass(savedItem.getBigDecimalValueClass()); + + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } + } + + @Nested + class WrapBigIntegerClassType { + @Test + void givenNull_inAndOut_shouldSucceed() { + var item = new WrapperTypesModel(); + item.setBigIntegerValueClass(null); + + var savedItem = repository.save(item); + + var retrievedItem = repository.findByBigIntegerValueClass(null); - var savedItem = repository.save(item); + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } - var retrievedItem = repository.findByLongValue(null); + @ParameterizedTest + @ValueSource(ints = {-1, 0, 1, -100_000_000, 100_000_000}) + void givenValues_inAndOut_shouldSucceed(int intValue) { + var item = new WrapperTypesModel(); + item.setBigIntegerValueClass(new WrapBigIntegerClass(BigInteger.valueOf(intValue))); - assertThat(retrievedItem).isPresent() - .get() - .usingRecursiveComparison() - .isEqualTo(savedItem); + var savedItem = repository.save(item); + + var retrievedItem = repository.findByBigIntegerValueClass(savedItem.getBigIntegerValueClass()); + + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } } - @ParameterizedTest - @ValueSource(longs = {-1, 0, 1, -100_000_000, 100_000_000}) - void givenValues_inAndOut_shouldSucceed(long longValue) { - var item = new WrapperTypesModel(); - item.setLongValue(new WrapLong(longValue)); + @Nested + class WrapDoubleClassType { + @Test + void givenNull_inAndOut_shouldSucceed() { + var item = new WrapperTypesModel(); + item.setDoubleValueClass(null); + + var savedItem = repository.save(item); + + var retrievedItem = repository.findByDoubleValueClass(null); - var savedItem = repository.save(item); + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } - var retrievedItem = repository.findByLongValue(savedItem.getLongValue()); + @ParameterizedTest + @ValueSource(doubles = {-1, 0, 1, -0.001d, 0.001d, -100_000_000, 100_000_000}) + void givenValues_inAndOut_shouldSucceed(double doubleValue) { + var item = new WrapperTypesModel(); + item.setDoubleValueClass(new WrapDoubleClass(doubleValue)); - assertThat(retrievedItem).isPresent() - .get() - .usingRecursiveComparison() - .isEqualTo(savedItem); + var savedItem = repository.save(item); + + var retrievedItem = repository.findByDoubleValueClass(savedItem.getDoubleValueClass()); + + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } } - } - @Nested - class WrapScaledBigDecimalType { - @Test - void givenNull_inAndOut_shouldSucceed() { - var item = new WrapperTypesModel(); - item.setScaledBigDecimalValue(null); + @Nested + class WrapFloatClassType { + @Test + void givenNull_inAndOut_shouldSucceed() { + var item = new WrapperTypesModel(); + item.setFloatValueClass(null); - var savedItem = repository.save(item); + var savedItem = repository.save(item); - var retrievedItem = repository.findByScaledBigDecimalValue(null); + var retrievedItem = repository.findByFloatValueClass(null); - assertThat(retrievedItem).isPresent() - .get() - .usingRecursiveComparison() - .isEqualTo(savedItem); + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } + + @ParameterizedTest + @ValueSource(floats = {-1, 0, 1, -0.001f, 0.001f, -100_000_000, 100_000_000}) + void givenValues_inAndOut_shouldSucceed(float floatValue) { + var item = new WrapperTypesModel(); + item.setFloatValueClass(new WrapFloatClass(floatValue)); + + var savedItem = repository.save(item); + + var retrievedItem = repository.findByFloatValueClass(savedItem.getFloatValueClass()); + + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } } - @ParameterizedTest - @ValueSource(doubles = {-1, 0, 1, -0.001, 0.001, -100_000_000, 100_000_000}) - void givenValues_inAndOut_shouldSucceed(double doubleValue) { - var item = new WrapperTypesModel(); - item.setScaledBigDecimalValue(new WrapScaledBigDecimal(new ScaledBigDecimal(doubleValue))); + @Nested + class WrapIntegerClassType { + @Test + void givenNull_inAndOut_shouldSucceed() { + var item = new WrapperTypesModel(); + item.setIntegerValueClass(null); + + var savedItem = repository.save(item); + + var retrievedItem = repository.findByIntegerValueClass(null); + + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } + + @ParameterizedTest + @ValueSource(ints = {-1, 0, 1, -100_000_000, 100_000_000}) + void givenValues_inAndOut_shouldSucceed(int intValue) { + var item = new WrapperTypesModel(); + item.setIntegerValueClass(new WrapIntegerClass(intValue)); - var savedItem = repository.save(item); + var savedItem = repository.save(item); - var retrievedItem = repository.findByScaledBigDecimalValue(savedItem.getScaledBigDecimalValue()); + var retrievedItem = repository.findByIntegerValueClass(savedItem.getIntegerValueClass()); - assertThat(retrievedItem).isPresent() - .get() - .usingRecursiveComparison() - .isEqualTo(savedItem); + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } } - } - @Nested - class WrapShortType { - @Test - void givenNull_inAndOut_shouldSucceed() { - var item = new WrapperTypesModel(); - item.setShortValue(null); + @Nested + class WrapLongClassType { + @Test + void givenNull_inAndOut_shouldSucceed() { + var item = new WrapperTypesModel(); + item.setLongValueClass(null); + + var savedItem = repository.save(item); + + var retrievedItem = repository.findByLongValueClass(null); - var savedItem = repository.save(item); + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } - var retrievedItem = repository.findByShortValue(null); + @ParameterizedTest + @ValueSource(longs = {-1, 0, 1, -100_000_000, 100_000_000}) + void givenValues_inAndOut_shouldSucceed(long longValue) { + var item = new WrapperTypesModel(); + item.setLongValueClass(new WrapLongClass(longValue)); - assertThat(retrievedItem).isPresent() - .get() - .usingRecursiveComparison() - .isEqualTo(savedItem); + var savedItem = repository.save(item); + + var retrievedItem = repository.findByLongValueClass(savedItem.getLongValueClass()); + + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } } - @ParameterizedTest - @ValueSource(shorts = {-1, 0, 1, -10_000, 10_000}) - void givenValues_inAndOut_shouldSucceed(short shortValue) { - var item = new WrapperTypesModel(); - item.setShortValue(new WrapShort(shortValue)); + @Nested + class WrapScaledBigDecimalClassType { + @Test + void givenNull_inAndOut_shouldSucceed() { + var item = new WrapperTypesModel(); + item.setScaledBigDecimalValueClass(null); + + var savedItem = repository.save(item); + + var retrievedItem = repository.findByScaledBigDecimalValueClass(null); - var savedItem = repository.save(item); + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } - var retrievedItem = repository.findByShortValue(savedItem.getShortValue()); + @ParameterizedTest + @ValueSource(doubles = {-1, 0, 1, -0.001d, 0.001d, -100_000_000, 100_000_000}) + void givenValues_inAndOut_shouldSucceed(double doubleValue) { + var item = new WrapperTypesModel(); + item.setScaledBigDecimalValueClass(new WrapScaledBigDecimalClass(new ScaledBigDecimal(doubleValue))); - assertThat(retrievedItem).isPresent() - .get() - .usingRecursiveComparison() - .isEqualTo(savedItem); + var savedItem = repository.save(item); + + var retrievedItem = repository.findByScaledBigDecimalValueClass(savedItem.getScaledBigDecimalValueClass()); + + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } } - } - @Nested - class WrapStringType { - @Test - void givenNull_inAndOut_shouldSucceed() { - var item = new WrapperTypesModel(); - item.setStringValue(null); + @Nested + class WrapShortClassType { + @Test + void givenNull_inAndOut_shouldSucceed() { + var item = new WrapperTypesModel(); + item.setShortValueClass(null); + + var savedItem = repository.save(item); + + var retrievedItem = repository.findByShortValueClass(null); + + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } + + @ParameterizedTest + @ValueSource(shorts = {-1, 0, 1, -10_000, 10_000}) + void givenValues_inAndOut_shouldSucceed(short shortValue) { + var item = new WrapperTypesModel(); + item.setShortValueClass(new WrapShortClass(shortValue)); - var savedItem = repository.save(item); + var savedItem = repository.save(item); - var retrievedItem = repository.findByStringValue(null); + var retrievedItem = repository.findByShortValueClass(savedItem.getShortValueClass()); - assertThat(retrievedItem).isPresent() - .get() - .usingRecursiveComparison() - .isEqualTo(savedItem); + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } } - @ParameterizedTest - @ValueSource(strings = {"", " ", "test", "some longer test", "\r", "\n"}) - void givenValues_inAndOut_shouldSucceed(String stringValue) { - var item = new WrapperTypesModel(); - item.setStringValue(new WrapString(stringValue)); + @Nested + class WrapStringClassType { + @Test + void givenNull_inAndOut_shouldSucceed() { + var item = new WrapperTypesModel(); + item.setStringValueClass(null); + + var savedItem = repository.save(item); + + var retrievedItem = repository.findByStringValueClass(null); + + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } + + @ParameterizedTest + @ValueSource(strings = {"", " ", "test", "some longer test", "\r", "\n"}) + void givenValues_inAndOut_shouldSucceed(String stringValue) { + var item = new WrapperTypesModel(); + item.setStringValueClass(new WrapStringClass(stringValue)); + + var savedItem = repository.save(item); + + var retrievedItem = repository.findByStringValueClass(savedItem.getStringValueClass()); + + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } + } + + @Nested + class WrapCharacterClassType { + @Test + void givenNull_inAndOut_shouldSucceed() { + var item = new WrapperTypesModel(); + item.setCharValue(null); + + var savedItem = repository.save(item); + + var retrievedItem = repository.findByCharValue(null); + + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } + + @ParameterizedTest + @ValueSource(chars = {'t', 's', '\r', '\n'}) + void givenValues_inAndOut_shouldSucceed(Character charValue) { + var item = new WrapperTypesModel(); + item.setCharValueClass(new WrapCharacterClass(charValue)); + + var savedItem = repository.save(item); + + var retrievedItem = repository.findByCharValueClass(savedItem.getCharValueClass()); + + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } + } + + @Nested + class WrapByteClassType { + @Test + void givenNull_inAndOut_shouldSucceed() { + var item = new WrapperTypesModel(); + item.setByteValue(null); + + var savedItem = repository.save(item); + + var retrievedItem = repository.findByByteValue(null); + + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } + + @ParameterizedTest + @ValueSource(bytes = {-1, 0, 1, -128, 127}) + void givenValues_inAndOut_shouldSucceed(Byte byteValue) { + var item = new WrapperTypesModel(); + item.setByteValueClass(new WrapByteClass(byteValue)); + + var savedItem = repository.save(item); + + var retrievedItem = repository.findByByteValueClass(savedItem.getByteValueClass()); + + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } + } + + @Nested + class WrapBooleanClassType { + @Test + void givenNull_inAndOut_shouldSucceed() { + var item = new WrapperTypesModel(); + item.setBoolValue(null); + + var savedItem = repository.save(item); + + var retrievedItem = repository.findByBoolValue(null); + + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } + + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void givenValues_inAndOut_shouldSucceed(Boolean boolValue) { + var item = new WrapperTypesModel(); + item.setBoolValueClass(new WrapBooleanClass(boolValue)); - var savedItem = repository.save(item); + var savedItem = repository.save(item); - var retrievedItem = repository.findByStringValue(savedItem.getStringValue()); + var retrievedItem = repository.findByBoolValueClass(savedItem.getBoolValueClass()); - assertThat(retrievedItem).isPresent() - .get() - .usingRecursiveComparison() - .isEqualTo(savedItem); + assertThat(retrievedItem).isPresent() + .get() + .usingRecursiveComparison() + .isEqualTo(savedItem); + } } } } diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapBigDecimalJavaType.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapBigDecimalClassJavaType.java similarity index 55% rename from src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapBigDecimalJavaType.java rename to src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapBigDecimalClassJavaType.java index f754b8c..ec5b845 100644 --- a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapBigDecimalJavaType.java +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapBigDecimalClassJavaType.java @@ -2,10 +2,10 @@ import it.aboutbits.springboot.toolbox.autoconfiguration.persistence.AutoRegisteredJavaType; import it.aboutbits.springboot.toolbox.persistence.javatype.base.WrappedBigDecimalJavaType; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBigDecimal; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBigDecimalClass; -public final class WrapBigDecimalJavaType extends WrappedBigDecimalJavaType implements AutoRegisteredJavaType { - public WrapBigDecimalJavaType() { - super(WrapBigDecimal.class); +public final class WrapBigDecimalClassJavaType extends WrappedBigDecimalJavaType implements AutoRegisteredJavaType { + public WrapBigDecimalClassJavaType() { + super(WrapBigDecimalClass.class); } } diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapBigDecimalRecordJavaType.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapBigDecimalRecordJavaType.java new file mode 100644 index 0000000..65bd53c --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapBigDecimalRecordJavaType.java @@ -0,0 +1,11 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype; + +import it.aboutbits.springboot.toolbox.autoconfiguration.persistence.AutoRegisteredJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.base.WrappedBigDecimalJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBigDecimalRecord; + +public final class WrapBigDecimalRecordJavaType extends WrappedBigDecimalJavaType implements AutoRegisteredJavaType { + public WrapBigDecimalRecordJavaType() { + super(WrapBigDecimalRecord.class); + } +} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapBigIntegerJavaType.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapBigIntegerClassJavaType.java similarity index 55% rename from src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapBigIntegerJavaType.java rename to src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapBigIntegerClassJavaType.java index 71d2a5d..708dbb7 100644 --- a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapBigIntegerJavaType.java +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapBigIntegerClassJavaType.java @@ -2,10 +2,10 @@ import it.aboutbits.springboot.toolbox.autoconfiguration.persistence.AutoRegisteredJavaType; import it.aboutbits.springboot.toolbox.persistence.javatype.base.WrappedBigIntegerJavaType; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBigInteger; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBigIntegerClass; -public final class WrapBigIntegerJavaType extends WrappedBigIntegerJavaType implements AutoRegisteredJavaType { - public WrapBigIntegerJavaType() { - super(WrapBigInteger.class); +public final class WrapBigIntegerClassJavaType extends WrappedBigIntegerJavaType implements AutoRegisteredJavaType { + public WrapBigIntegerClassJavaType() { + super(WrapBigIntegerClass.class); } } diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapBigIntegerRecordJavaType.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapBigIntegerRecordJavaType.java new file mode 100644 index 0000000..95a7396 --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapBigIntegerRecordJavaType.java @@ -0,0 +1,11 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype; + +import it.aboutbits.springboot.toolbox.autoconfiguration.persistence.AutoRegisteredJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.base.WrappedBigIntegerJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBigIntegerRecord; + +public final class WrapBigIntegerRecordJavaType extends WrappedBigIntegerJavaType implements AutoRegisteredJavaType { + public WrapBigIntegerRecordJavaType() { + super(WrapBigIntegerRecord.class); + } +} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapBooleanClassJavaType.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapBooleanClassJavaType.java new file mode 100644 index 0000000..a2af7fa --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapBooleanClassJavaType.java @@ -0,0 +1,11 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype; + +import it.aboutbits.springboot.toolbox.autoconfiguration.persistence.AutoRegisteredJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.base.WrappedBooleanJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBooleanClass; + +public final class WrapBooleanClassJavaType extends WrappedBooleanJavaType implements AutoRegisteredJavaType { + public WrapBooleanClassJavaType() { + super(WrapBooleanClass.class); + } +} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapBooleanRecordJavaType.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapBooleanRecordJavaType.java new file mode 100644 index 0000000..3514fc7 --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapBooleanRecordJavaType.java @@ -0,0 +1,11 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype; + +import it.aboutbits.springboot.toolbox.autoconfiguration.persistence.AutoRegisteredJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.base.WrappedBooleanJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBooleanRecord; + +public final class WrapBooleanRecordJavaType extends WrappedBooleanJavaType implements AutoRegisteredJavaType { + public WrapBooleanRecordJavaType() { + super(WrapBooleanRecord.class); + } +} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapByteClassJavaType.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapByteClassJavaType.java new file mode 100644 index 0000000..987f4bb --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapByteClassJavaType.java @@ -0,0 +1,11 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype; + +import it.aboutbits.springboot.toolbox.autoconfiguration.persistence.AutoRegisteredJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.base.WrappedByteJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapByteClass; + +public final class WrapByteClassJavaType extends WrappedByteJavaType implements AutoRegisteredJavaType { + public WrapByteClassJavaType() { + super(WrapByteClass.class); + } +} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapByteRecordJavaType.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapByteRecordJavaType.java new file mode 100644 index 0000000..ce2992c --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapByteRecordJavaType.java @@ -0,0 +1,11 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype; + +import it.aboutbits.springboot.toolbox.autoconfiguration.persistence.AutoRegisteredJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.base.WrappedByteJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapByteRecord; + +public final class WrapByteRecordJavaType extends WrappedByteJavaType implements AutoRegisteredJavaType { + public WrapByteRecordJavaType() { + super(WrapByteRecord.class); + } +} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapCharacterClassJavaType.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapCharacterClassJavaType.java new file mode 100644 index 0000000..d83cccc --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapCharacterClassJavaType.java @@ -0,0 +1,11 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype; + +import it.aboutbits.springboot.toolbox.autoconfiguration.persistence.AutoRegisteredJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.base.WrappedCharacterJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapCharacterClass; + +public final class WrapCharacterClassJavaType extends WrappedCharacterJavaType implements AutoRegisteredJavaType { + public WrapCharacterClassJavaType() { + super(WrapCharacterClass.class); + } +} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapCharacterRecordJavaType.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapCharacterRecordJavaType.java new file mode 100644 index 0000000..b044f46 --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapCharacterRecordJavaType.java @@ -0,0 +1,11 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype; + +import it.aboutbits.springboot.toolbox.autoconfiguration.persistence.AutoRegisteredJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.base.WrappedCharacterJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapCharacterRecord; + +public final class WrapCharacterRecordJavaType extends WrappedCharacterJavaType implements AutoRegisteredJavaType { + public WrapCharacterRecordJavaType() { + super(WrapCharacterRecord.class); + } +} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapDoubleJavaType.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapDoubleClassJavaType.java similarity index 57% rename from src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapDoubleJavaType.java rename to src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapDoubleClassJavaType.java index 2e69f31..3effe47 100644 --- a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapDoubleJavaType.java +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapDoubleClassJavaType.java @@ -2,10 +2,10 @@ import it.aboutbits.springboot.toolbox.autoconfiguration.persistence.AutoRegisteredJavaType; import it.aboutbits.springboot.toolbox.persistence.javatype.base.WrappedDoubleJavaType; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapDouble; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapDoubleClass; -public final class WrapDoubleJavaType extends WrappedDoubleJavaType implements AutoRegisteredJavaType { - public WrapDoubleJavaType() { - super(WrapDouble.class); +public final class WrapDoubleClassJavaType extends WrappedDoubleJavaType implements AutoRegisteredJavaType { + public WrapDoubleClassJavaType() { + super(WrapDoubleClass.class); } } diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapDoubleRecordJavaType.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapDoubleRecordJavaType.java new file mode 100644 index 0000000..bf5b975 --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapDoubleRecordJavaType.java @@ -0,0 +1,11 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype; + +import it.aboutbits.springboot.toolbox.autoconfiguration.persistence.AutoRegisteredJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.base.WrappedDoubleJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapDoubleRecord; + +public final class WrapDoubleRecordJavaType extends WrappedDoubleJavaType implements AutoRegisteredJavaType { + public WrapDoubleRecordJavaType() { + super(WrapDoubleRecord.class); + } +} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapFloatJavaType.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapFloatClassJavaType.java similarity index 58% rename from src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapFloatJavaType.java rename to src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapFloatClassJavaType.java index 81a1815..6d6ea8f 100644 --- a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapFloatJavaType.java +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapFloatClassJavaType.java @@ -2,10 +2,10 @@ import it.aboutbits.springboot.toolbox.autoconfiguration.persistence.AutoRegisteredJavaType; import it.aboutbits.springboot.toolbox.persistence.javatype.base.WrappedFloatJavaType; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapFloat; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapFloatClass; -public final class WrapFloatJavaType extends WrappedFloatJavaType implements AutoRegisteredJavaType { - public WrapFloatJavaType() { - super(WrapFloat.class); +public final class WrapFloatClassJavaType extends WrappedFloatJavaType implements AutoRegisteredJavaType { + public WrapFloatClassJavaType() { + super(WrapFloatClass.class); } } diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapFloatRecordJavaType.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapFloatRecordJavaType.java new file mode 100644 index 0000000..7784534 --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapFloatRecordJavaType.java @@ -0,0 +1,11 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype; + +import it.aboutbits.springboot.toolbox.autoconfiguration.persistence.AutoRegisteredJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.base.WrappedFloatJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapFloatRecord; + +public final class WrapFloatRecordJavaType extends WrappedFloatJavaType implements AutoRegisteredJavaType { + public WrapFloatRecordJavaType() { + super(WrapFloatRecord.class); + } +} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapIntegerJavaType.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapIntegerClassJavaType.java similarity index 57% rename from src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapIntegerJavaType.java rename to src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapIntegerClassJavaType.java index d20de96..18d9448 100644 --- a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapIntegerJavaType.java +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapIntegerClassJavaType.java @@ -2,10 +2,10 @@ import it.aboutbits.springboot.toolbox.autoconfiguration.persistence.AutoRegisteredJavaType; import it.aboutbits.springboot.toolbox.persistence.javatype.base.WrappedIntegerJavaType; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapInteger; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapIntegerClass; -public final class WrapIntegerJavaType extends WrappedIntegerJavaType implements AutoRegisteredJavaType { - public WrapIntegerJavaType() { - super(WrapInteger.class); +public final class WrapIntegerClassJavaType extends WrappedIntegerJavaType implements AutoRegisteredJavaType { + public WrapIntegerClassJavaType() { + super(WrapIntegerClass.class); } } diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapIntegerRecordJavaType.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapIntegerRecordJavaType.java new file mode 100644 index 0000000..4f20a8a --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapIntegerRecordJavaType.java @@ -0,0 +1,11 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype; + +import it.aboutbits.springboot.toolbox.autoconfiguration.persistence.AutoRegisteredJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.base.WrappedIntegerJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapIntegerRecord; + +public final class WrapIntegerRecordJavaType extends WrappedIntegerJavaType implements AutoRegisteredJavaType { + public WrapIntegerRecordJavaType() { + super(WrapIntegerRecord.class); + } +} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapLongJavaType.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapLongClassJavaType.java similarity index 58% rename from src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapLongJavaType.java rename to src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapLongClassJavaType.java index 9375633..9e3d566 100644 --- a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapLongJavaType.java +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapLongClassJavaType.java @@ -2,10 +2,10 @@ import it.aboutbits.springboot.toolbox.autoconfiguration.persistence.AutoRegisteredJavaType; import it.aboutbits.springboot.toolbox.persistence.javatype.base.WrappedLongJavaType; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapLong; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapLongClass; -public final class WrapLongJavaType extends WrappedLongJavaType implements AutoRegisteredJavaType { - public WrapLongJavaType() { - super(WrapLong.class); +public final class WrapLongClassJavaType extends WrappedLongJavaType implements AutoRegisteredJavaType { + public WrapLongClassJavaType() { + super(WrapLongClass.class); } } diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapLongRecordJavaType.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapLongRecordJavaType.java new file mode 100644 index 0000000..c9aa18b --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapLongRecordJavaType.java @@ -0,0 +1,11 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype; + +import it.aboutbits.springboot.toolbox.autoconfiguration.persistence.AutoRegisteredJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.base.WrappedLongJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapLongRecord; + +public final class WrapLongRecordJavaType extends WrappedLongJavaType implements AutoRegisteredJavaType { + public WrapLongRecordJavaType() { + super(WrapLongRecord.class); + } +} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapScaledBigDecimalJavaType.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapScaledBigDecimalClassJavaType.java similarity index 52% rename from src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapScaledBigDecimalJavaType.java rename to src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapScaledBigDecimalClassJavaType.java index 0959545..a667252 100644 --- a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapScaledBigDecimalJavaType.java +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapScaledBigDecimalClassJavaType.java @@ -2,10 +2,10 @@ import it.aboutbits.springboot.toolbox.autoconfiguration.persistence.AutoRegisteredJavaType; import it.aboutbits.springboot.toolbox.persistence.javatype.base.WrappedScaledBigDecimalJavaType; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapScaledBigDecimal; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapScaledBigDecimalClass; -public final class WrapScaledBigDecimalJavaType extends WrappedScaledBigDecimalJavaType implements AutoRegisteredJavaType { - public WrapScaledBigDecimalJavaType() { - super(WrapScaledBigDecimal.class); +public final class WrapScaledBigDecimalClassJavaType extends WrappedScaledBigDecimalJavaType implements AutoRegisteredJavaType { + public WrapScaledBigDecimalClassJavaType() { + super(WrapScaledBigDecimalClass.class); } } diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapScaledBigDecimalRecordJavaType.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapScaledBigDecimalRecordJavaType.java new file mode 100644 index 0000000..dea2da4 --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapScaledBigDecimalRecordJavaType.java @@ -0,0 +1,11 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype; + +import it.aboutbits.springboot.toolbox.autoconfiguration.persistence.AutoRegisteredJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.base.WrappedScaledBigDecimalJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapScaledBigDecimalRecord; + +public final class WrapScaledBigDecimalRecordJavaType extends WrappedScaledBigDecimalJavaType implements AutoRegisteredJavaType { + public WrapScaledBigDecimalRecordJavaType() { + super(WrapScaledBigDecimalRecord.class); + } +} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapShortJavaType.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapShortClassJavaType.java similarity index 58% rename from src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapShortJavaType.java rename to src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapShortClassJavaType.java index 78d3a36..f1d62d2 100644 --- a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapShortJavaType.java +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapShortClassJavaType.java @@ -2,10 +2,10 @@ import it.aboutbits.springboot.toolbox.autoconfiguration.persistence.AutoRegisteredJavaType; import it.aboutbits.springboot.toolbox.persistence.javatype.base.WrappedShortJavaType; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapShort; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapShortClass; -public final class WrapShortJavaType extends WrappedShortJavaType implements AutoRegisteredJavaType { - public WrapShortJavaType() { - super(WrapShort.class); +public final class WrapShortClassJavaType extends WrappedShortJavaType implements AutoRegisteredJavaType { + public WrapShortClassJavaType() { + super(WrapShortClass.class); } } diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapShortRecordJavaType.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapShortRecordJavaType.java new file mode 100644 index 0000000..77885ba --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapShortRecordJavaType.java @@ -0,0 +1,11 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype; + +import it.aboutbits.springboot.toolbox.autoconfiguration.persistence.AutoRegisteredJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.base.WrappedShortJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapShortRecord; + +public final class WrapShortRecordJavaType extends WrappedShortJavaType implements AutoRegisteredJavaType { + public WrapShortRecordJavaType() { + super(WrapShortRecord.class); + } +} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapStringJavaType.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapStringClassJavaType.java similarity index 57% rename from src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapStringJavaType.java rename to src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapStringClassJavaType.java index 43466e3..def61a4 100644 --- a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapStringJavaType.java +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapStringClassJavaType.java @@ -2,10 +2,10 @@ import it.aboutbits.springboot.toolbox.autoconfiguration.persistence.AutoRegisteredJavaType; import it.aboutbits.springboot.toolbox.persistence.javatype.base.WrappedStringJavaType; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapString; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapStringClass; -public final class WrapStringJavaType extends WrappedStringJavaType implements AutoRegisteredJavaType { - public WrapStringJavaType() { - super(WrapString.class); +public final class WrapStringClassJavaType extends WrappedStringJavaType implements AutoRegisteredJavaType { + public WrapStringClassJavaType() { + super(WrapStringClass.class); } } diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapStringRecordJavaType.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapStringRecordJavaType.java new file mode 100644 index 0000000..5e9bc43 --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/javatype/WrapStringRecordJavaType.java @@ -0,0 +1,11 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype; + +import it.aboutbits.springboot.toolbox.autoconfiguration.persistence.AutoRegisteredJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.base.WrappedStringJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapStringRecord; + +public final class WrapStringRecordJavaType extends WrappedStringJavaType implements AutoRegisteredJavaType { + public WrapStringRecordJavaType() { + super(WrapStringRecord.class); + } +} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/jpa/WrapperTypesModel.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/jpa/WrapperTypesModel.java index f2b5d84..6be216d 100644 --- a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/jpa/WrapperTypesModel.java +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/jpa/WrapperTypesModel.java @@ -1,27 +1,57 @@ package it.aboutbits.springboot.toolbox.persistence.javatype.impl.jpa; import it.aboutbits.springboot.toolbox.autoconfiguration.persistence.AutoRegisteredJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.base.WrappedLongJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapBigDecimalClassJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapBigDecimalRecordJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapBigIntegerClassJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapBigIntegerRecordJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapBooleanClassJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapBooleanRecordJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapByteClassJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapByteRecordJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapCharacterClassJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapCharacterRecordJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapDoubleClassJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapDoubleRecordJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapFloatClassJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapFloatRecordJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapIntegerClassJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapIntegerRecordJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapLongClassJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapLongRecordJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapScaledBigDecimalClassJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapScaledBigDecimalRecordJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapShortClassJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapShortRecordJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapStringClassJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapStringRecordJavaType; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBigDecimalClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBigDecimalRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBigIntegerClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBigIntegerRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBooleanClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBooleanRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapByteClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapByteRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapCharacterClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapCharacterRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapDoubleClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapDoubleRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapFloatClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapFloatRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapIntegerClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapIntegerRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapLongClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapLongRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapScaledBigDecimalClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapScaledBigDecimalRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapShortClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapShortRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapStringClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapStringRecord; import it.aboutbits.springboot.toolbox.type.identity.EntityId; import it.aboutbits.springboot.toolbox.type.identity.Identified; -import it.aboutbits.springboot.toolbox.persistence.javatype.base.WrappedLongJavaType; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapBigDecimalJavaType; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapBigIntegerJavaType; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapDoubleJavaType; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapFloatJavaType; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapIntegerJavaType; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapLongJavaType; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapScaledBigDecimalJavaType; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapShortJavaType; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.javatype.WrapStringJavaType; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBigDecimal; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBigInteger; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapDouble; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapFloat; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapInteger; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapLong; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapScaledBigDecimal; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapShort; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapString; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; @@ -42,40 +72,101 @@ public class WrapperTypesModel implements Identified { private ID id; @SuppressWarnings("JpaAttributeTypeInspection") - @JavaType(WrapBigDecimalJavaType.class) - private WrapBigDecimal bigDecimalValue; + @JavaType(WrapBigDecimalRecordJavaType.class) + private WrapBigDecimalRecord bigDecimalValue; @SuppressWarnings("JpaAttributeTypeInspection") - @JavaType(WrapBigIntegerJavaType.class) - private WrapBigInteger bigIntegerValue; + @JavaType(WrapBigIntegerRecordJavaType.class) + private WrapBigIntegerRecord bigIntegerValue; @SuppressWarnings("JpaAttributeTypeInspection") - @JavaType(WrapDoubleJavaType.class) - private WrapDouble doubleValue; + @JavaType(WrapDoubleRecordJavaType.class) + private WrapDoubleRecord doubleValue; @SuppressWarnings("JpaAttributeTypeInspection") - @JavaType(WrapFloatJavaType.class) - private WrapFloat floatValue; + @JavaType(WrapFloatRecordJavaType.class) + private WrapFloatRecord floatValue; @SuppressWarnings("JpaAttributeTypeInspection") - @JavaType(WrapIntegerJavaType.class) - private WrapInteger integerValue; + @JavaType(WrapIntegerRecordJavaType.class) + private WrapIntegerRecord integerValue; @SuppressWarnings("JpaAttributeTypeInspection") - @JavaType(WrapLongJavaType.class) - private WrapLong longValue; + @JavaType(WrapLongRecordJavaType.class) + private WrapLongRecord longValue; @SuppressWarnings("JpaAttributeTypeInspection") - @JavaType(WrapScaledBigDecimalJavaType.class) - private WrapScaledBigDecimal scaledBigDecimalValue; + @JavaType(WrapScaledBigDecimalRecordJavaType.class) + private WrapScaledBigDecimalRecord scaledBigDecimalValue; @SuppressWarnings("JpaAttributeTypeInspection") - @JavaType(WrapShortJavaType.class) - private WrapShort shortValue; + @JavaType(WrapShortRecordJavaType.class) + private WrapShortRecord shortValue; @SuppressWarnings("JpaAttributeTypeInspection") - @JavaType(WrapStringJavaType.class) - private WrapString stringValue; + @JavaType(WrapByteRecordJavaType.class) + private WrapByteRecord byteValue; + + @SuppressWarnings("JpaAttributeTypeInspection") + @JavaType(WrapStringRecordJavaType.class) + private WrapStringRecord stringValue; + + @SuppressWarnings("JpaAttributeTypeInspection") + @JavaType(WrapCharacterRecordJavaType.class) + private WrapCharacterRecord charValue; + + @SuppressWarnings("JpaAttributeTypeInspection") + @JavaType(WrapBooleanRecordJavaType.class) + private WrapBooleanRecord boolValue; + + @SuppressWarnings("JpaAttributeTypeInspection") + @JavaType(WrapBigDecimalClassJavaType.class) + private WrapBigDecimalClass bigDecimalValueClass; + + @SuppressWarnings("JpaAttributeTypeInspection") + @JavaType(WrapBigIntegerClassJavaType.class) + private WrapBigIntegerClass bigIntegerValueClass; + + @SuppressWarnings("JpaAttributeTypeInspection") + @JavaType(WrapDoubleClassJavaType.class) + private WrapDoubleClass doubleValueClass; + + @SuppressWarnings("JpaAttributeTypeInspection") + @JavaType(WrapFloatClassJavaType.class) + private WrapFloatClass floatValueClass; + + @SuppressWarnings("JpaAttributeTypeInspection") + @JavaType(WrapIntegerClassJavaType.class) + private WrapIntegerClass integerValueClass; + + @SuppressWarnings("JpaAttributeTypeInspection") + @JavaType(WrapLongClassJavaType.class) + private WrapLongClass longValueClass; + + @SuppressWarnings("JpaAttributeTypeInspection") + @JavaType(WrapScaledBigDecimalClassJavaType.class) + private WrapScaledBigDecimalClass scaledBigDecimalValueClass; + + @SuppressWarnings("JpaAttributeTypeInspection") + @JavaType(WrapShortClassJavaType.class) + private WrapShortClass shortValueClass; + + @SuppressWarnings("JpaAttributeTypeInspection") + @JavaType(WrapByteClassJavaType.class) + private WrapByteClass byteValueClass; + + @SuppressWarnings("JpaAttributeTypeInspection") + @JavaType(WrapStringClassJavaType.class) + private WrapStringClass stringValueClass; + + @SuppressWarnings("JpaAttributeTypeInspection") + @JavaType(WrapCharacterClassJavaType.class) + private WrapCharacterClass charValueClass; + + @SuppressWarnings("JpaAttributeTypeInspection") + @JavaType(WrapBooleanClassJavaType.class) + private WrapBooleanClass boolValueClass; + public record ID( Long value diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/jpa/WrapperTypesModelRepository.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/jpa/WrapperTypesModelRepository.java index e7c2459..10b271f 100644 --- a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/jpa/WrapperTypesModelRepository.java +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/jpa/WrapperTypesModelRepository.java @@ -1,34 +1,79 @@ package it.aboutbits.springboot.toolbox.persistence.javatype.impl.jpa; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBigDecimal; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBigInteger; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapDouble; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapFloat; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapInteger; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapLong; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapScaledBigDecimal; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapShort; -import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapString; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBigDecimalClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBigDecimalRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBigIntegerClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBigIntegerRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBooleanClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapBooleanRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapByteClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapByteRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapCharacterClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapCharacterRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapDoubleClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapDoubleRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapFloatClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapFloatRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapIntegerClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapIntegerRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapLongClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapLongRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapScaledBigDecimalClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapScaledBigDecimalRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapShortClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapShortRecord; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapStringClass; +import it.aboutbits.springboot.toolbox.persistence.javatype.impl.type.WrapStringRecord; import org.springframework.data.jpa.repository.JpaRepository; import java.util.Optional; public interface WrapperTypesModelRepository extends JpaRepository { - Optional findByBigDecimalValue(WrapBigDecimal value); + Optional findByBigDecimalValue(WrapBigDecimalRecord value); - Optional findByBigIntegerValue(WrapBigInteger value); + Optional findByBigIntegerValue(WrapBigIntegerRecord value); - Optional findByDoubleValue(WrapDouble value); + Optional findByDoubleValue(WrapDoubleRecord value); - Optional findByFloatValue(WrapFloat value); + Optional findByFloatValue(WrapFloatRecord value); - Optional findByIntegerValue(WrapInteger value); + Optional findByIntegerValue(WrapIntegerRecord value); - Optional findByLongValue(WrapLong value); + Optional findByLongValue(WrapLongRecord value); - Optional findByScaledBigDecimalValue(WrapScaledBigDecimal value); + Optional findByScaledBigDecimalValue(WrapScaledBigDecimalRecord value); - Optional findByShortValue(WrapShort value); + Optional findByShortValue(WrapShortRecord value); - Optional findByStringValue(WrapString value); + Optional findByStringValue(WrapStringRecord value); + + Optional findByBoolValue(WrapBooleanRecord value); + + Optional findByByteValue(WrapByteRecord value); + + Optional findByCharValue(WrapCharacterRecord value); + + Optional findByBigDecimalValueClass(WrapBigDecimalClass value); + + Optional findByBigIntegerValueClass(WrapBigIntegerClass value); + + Optional findByDoubleValueClass(WrapDoubleClass value); + + Optional findByFloatValueClass(WrapFloatClass value); + + Optional findByIntegerValueClass(WrapIntegerClass value); + + Optional findByLongValueClass(WrapLongClass value); + + Optional findByScaledBigDecimalValueClass(WrapScaledBigDecimalClass value); + + Optional findByShortValueClass(WrapShortClass value); + + Optional findByStringValueClass(WrapStringClass value); + + Optional findByBoolValueClass(WrapBooleanClass value); + + Optional findByByteValueClass(WrapByteClass value); + + Optional findByCharValueClass(WrapCharacterClass value); } diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapBigDecimalClass.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapBigDecimalClass.java new file mode 100644 index 0000000..177142b --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapBigDecimalClass.java @@ -0,0 +1,17 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.impl.type; + +import it.aboutbits.springboot.toolbox.type.CustomType; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +@Getter +@Accessors(fluent = true) +@EqualsAndHashCode +@RequiredArgsConstructor +public class WrapBigDecimalClass implements CustomType { + private final BigDecimal value; +} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapBigDecimal.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapBigDecimalRecord.java similarity index 64% rename from src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapBigDecimal.java rename to src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapBigDecimalRecord.java index 5b3b2b8..5291d1b 100644 --- a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapBigDecimal.java +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapBigDecimalRecord.java @@ -4,6 +4,6 @@ import java.math.BigDecimal; -public record WrapBigDecimal(BigDecimal value) implements CustomType { +public record WrapBigDecimalRecord(BigDecimal value) implements CustomType { } diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapBigIntegerClass.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapBigIntegerClass.java new file mode 100644 index 0000000..366a187 --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapBigIntegerClass.java @@ -0,0 +1,17 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.impl.type; + +import it.aboutbits.springboot.toolbox.type.CustomType; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.experimental.Accessors; + +import java.math.BigInteger; + +@Getter +@Accessors(fluent = true) +@EqualsAndHashCode +@RequiredArgsConstructor +public class WrapBigIntegerClass implements CustomType { + private final BigInteger value; +} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapBigInteger.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapBigIntegerRecord.java similarity index 64% rename from src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapBigInteger.java rename to src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapBigIntegerRecord.java index f97a743..7c86200 100644 --- a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapBigInteger.java +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapBigIntegerRecord.java @@ -4,6 +4,6 @@ import java.math.BigInteger; -public record WrapBigInteger(BigInteger value) implements CustomType { +public record WrapBigIntegerRecord(BigInteger value) implements CustomType { } diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapBooleanClass.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapBooleanClass.java new file mode 100644 index 0000000..70325a9 --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapBooleanClass.java @@ -0,0 +1,15 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.impl.type; + +import it.aboutbits.springboot.toolbox.type.CustomType; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.experimental.Accessors; + +@Getter +@Accessors(fluent = true) +@EqualsAndHashCode +@RequiredArgsConstructor +public class WrapBooleanClass implements CustomType { + private final Boolean value; +} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapBooleanRecord.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapBooleanRecord.java new file mode 100644 index 0000000..f0319ae --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapBooleanRecord.java @@ -0,0 +1,7 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.impl.type; + +import it.aboutbits.springboot.toolbox.type.CustomType; + +public record WrapBooleanRecord(Boolean value) implements CustomType { + +} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapByteClass.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapByteClass.java new file mode 100644 index 0000000..6f15e3a --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapByteClass.java @@ -0,0 +1,15 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.impl.type; + +import it.aboutbits.springboot.toolbox.type.CustomType; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.experimental.Accessors; + +@Getter +@Accessors(fluent = true) +@EqualsAndHashCode +@RequiredArgsConstructor +public class WrapByteClass implements CustomType { + private final Byte value; +} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapShort.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapByteRecord.java similarity index 65% rename from src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapShort.java rename to src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapByteRecord.java index 5933d1d..a30f64e 100644 --- a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapShort.java +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapByteRecord.java @@ -2,6 +2,6 @@ import it.aboutbits.springboot.toolbox.type.CustomType; -public record WrapShort(Short value) implements CustomType { +public record WrapByteRecord(Byte value) implements CustomType { } diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapCharacterClass.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapCharacterClass.java new file mode 100644 index 0000000..46c0e6d --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapCharacterClass.java @@ -0,0 +1,15 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.impl.type; + +import it.aboutbits.springboot.toolbox.type.CustomType; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.experimental.Accessors; + +@Getter +@Accessors(fluent = true) +@EqualsAndHashCode +@RequiredArgsConstructor +public class WrapCharacterClass implements CustomType { + private final Character value; +} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapCharacterRecord.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapCharacterRecord.java new file mode 100644 index 0000000..3a52373 --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapCharacterRecord.java @@ -0,0 +1,7 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.impl.type; + +import it.aboutbits.springboot.toolbox.type.CustomType; + +public record WrapCharacterRecord(Character value) implements CustomType { + +} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapDoubleClass.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapDoubleClass.java new file mode 100644 index 0000000..2b56662 --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapDoubleClass.java @@ -0,0 +1,15 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.impl.type; + +import it.aboutbits.springboot.toolbox.type.CustomType; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.experimental.Accessors; + +@Getter +@Accessors(fluent = true) +@EqualsAndHashCode +@RequiredArgsConstructor +public class WrapDoubleClass implements CustomType { + private final Double value; +} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapFloat.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapDoubleRecord.java similarity index 63% rename from src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapFloat.java rename to src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapDoubleRecord.java index 357b8aa..e2825a8 100644 --- a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapFloat.java +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapDoubleRecord.java @@ -2,6 +2,6 @@ import it.aboutbits.springboot.toolbox.type.CustomType; -public record WrapFloat(Float value) implements CustomType { +public record WrapDoubleRecord(Double value) implements CustomType { } diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapFloatClass.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapFloatClass.java new file mode 100644 index 0000000..9feb2b7 --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapFloatClass.java @@ -0,0 +1,15 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.impl.type; + +import it.aboutbits.springboot.toolbox.type.CustomType; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.experimental.Accessors; + +@Getter +@Accessors(fluent = true) +@EqualsAndHashCode +@RequiredArgsConstructor +public class WrapFloatClass implements CustomType { + private final Float value; +} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapInteger.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapFloatRecord.java similarity index 64% rename from src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapInteger.java rename to src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapFloatRecord.java index 73a08af..62b966d 100644 --- a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapInteger.java +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapFloatRecord.java @@ -2,6 +2,6 @@ import it.aboutbits.springboot.toolbox.type.CustomType; -public record WrapInteger(Integer value) implements CustomType { +public record WrapFloatRecord(Float value) implements CustomType { } diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapIntegerClass.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapIntegerClass.java new file mode 100644 index 0000000..8c12927 --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapIntegerClass.java @@ -0,0 +1,15 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.impl.type; + +import it.aboutbits.springboot.toolbox.type.CustomType; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.experimental.Accessors; + +@Getter +@Accessors(fluent = true) +@EqualsAndHashCode +@RequiredArgsConstructor +public class WrapIntegerClass implements CustomType { + private final Integer value; +} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapIntegerRecord.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapIntegerRecord.java new file mode 100644 index 0000000..08ba7f1 --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapIntegerRecord.java @@ -0,0 +1,7 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.impl.type; + +import it.aboutbits.springboot.toolbox.type.CustomType; + +public record WrapIntegerRecord(Integer value) implements CustomType { + +} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapLongClass.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapLongClass.java new file mode 100644 index 0000000..5ace546 --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapLongClass.java @@ -0,0 +1,15 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.impl.type; + +import it.aboutbits.springboot.toolbox.type.CustomType; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.experimental.Accessors; + +@Getter +@Accessors(fluent = true) +@EqualsAndHashCode +@RequiredArgsConstructor +public class WrapLongClass implements CustomType { + private final Long value; +} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapLong.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapLongRecord.java similarity index 65% rename from src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapLong.java rename to src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapLongRecord.java index fc54ee0..e77c55e 100644 --- a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapLong.java +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapLongRecord.java @@ -2,6 +2,6 @@ import it.aboutbits.springboot.toolbox.type.CustomType; -public record WrapLong(Long value) implements CustomType { +public record WrapLongRecord(Long value) implements CustomType { } diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapScaledBigDecimalClass.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapScaledBigDecimalClass.java new file mode 100644 index 0000000..b078910 --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapScaledBigDecimalClass.java @@ -0,0 +1,16 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.impl.type; + +import it.aboutbits.springboot.toolbox.type.CustomType; +import it.aboutbits.springboot.toolbox.type.ScaledBigDecimal; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.experimental.Accessors; + +@Getter +@Accessors(fluent = true) +@EqualsAndHashCode +@RequiredArgsConstructor +public class WrapScaledBigDecimalClass implements CustomType { + private final ScaledBigDecimal value; +} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapScaledBigDecimal.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapScaledBigDecimalRecord.java similarity index 64% rename from src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapScaledBigDecimal.java rename to src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapScaledBigDecimalRecord.java index 87746eb..966f2c6 100644 --- a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapScaledBigDecimal.java +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapScaledBigDecimalRecord.java @@ -3,6 +3,6 @@ import it.aboutbits.springboot.toolbox.type.CustomType; import it.aboutbits.springboot.toolbox.type.ScaledBigDecimal; -public record WrapScaledBigDecimal(ScaledBigDecimal value) implements CustomType { +public record WrapScaledBigDecimalRecord(ScaledBigDecimal value) implements CustomType { } diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapShortClass.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapShortClass.java new file mode 100644 index 0000000..7d2b8a5 --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapShortClass.java @@ -0,0 +1,15 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.impl.type; + +import it.aboutbits.springboot.toolbox.type.CustomType; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.experimental.Accessors; + +@Getter +@Accessors(fluent = true) +@EqualsAndHashCode +@RequiredArgsConstructor +public class WrapShortClass implements CustomType { + private final Short value; +} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapDouble.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapShortRecord.java similarity index 64% rename from src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapDouble.java rename to src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapShortRecord.java index 467527e..742e668 100644 --- a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapDouble.java +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapShortRecord.java @@ -2,6 +2,6 @@ import it.aboutbits.springboot.toolbox.type.CustomType; -public record WrapDouble(Double value) implements CustomType { +public record WrapShortRecord(Short value) implements CustomType { } diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapString.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapString.java deleted file mode 100644 index af28f4d..0000000 --- a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapString.java +++ /dev/null @@ -1,7 +0,0 @@ -package it.aboutbits.springboot.toolbox.persistence.javatype.impl.type; - -import it.aboutbits.springboot.toolbox.type.CustomType; - -public record WrapString(String value) implements CustomType { - -} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapStringClass.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapStringClass.java new file mode 100644 index 0000000..b435c6c --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapStringClass.java @@ -0,0 +1,15 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.impl.type; + +import it.aboutbits.springboot.toolbox.type.CustomType; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.experimental.Accessors; + +@Getter +@Accessors(fluent = true) +@EqualsAndHashCode +@RequiredArgsConstructor +public class WrapStringClass implements CustomType { + private final String value; +} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapStringRecord.java b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapStringRecord.java new file mode 100644 index 0000000..964f2b5 --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/persistence/javatype/impl/type/WrapStringRecord.java @@ -0,0 +1,7 @@ +package it.aboutbits.springboot.toolbox.persistence.javatype.impl.type; + +import it.aboutbits.springboot.toolbox.type.CustomType; + +public record WrapStringRecord(String value) implements CustomType { + +} diff --git a/src/test/java/it/aboutbits/springboot/toolbox/reflection/util/CustomTypeReflectionUtilTest.java b/src/test/java/it/aboutbits/springboot/toolbox/reflection/util/CustomTypeReflectionUtilTest.java new file mode 100644 index 0000000..48c9f7c --- /dev/null +++ b/src/test/java/it/aboutbits/springboot/toolbox/reflection/util/CustomTypeReflectionUtilTest.java @@ -0,0 +1,128 @@ +package it.aboutbits.springboot.toolbox.reflection.util; + +import it.aboutbits.springboot.toolbox.autoconfiguration.web.CustomTypeScanner; +import it.aboutbits.springboot.toolbox.type.CustomType; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; + +class CustomTypeReflectionUtilTest { + @Test + void testGetCustomTypeConstructorWithValidCustomType() throws Exception { + // given + var customTypeClass = ValidCustomType.class; + + // when + var constructor = CustomTypeReflectionUtil.getCustomTypeConstructor(customTypeClass); + + // then + assertThat(constructor).isNotNull(); + assertThat(constructor.getParameterCount()).isEqualTo(1); + assertThat(constructor.getParameterTypes()[0]).isEqualTo(String.class); + } + + @Test + void testGetCustomTypeConstructorWithMissingConstructor() { + // given + var customTypeClass = InvalidCustomType.class; + + // then + assertThatExceptionOfType(NoSuchMethodException.class).isThrownBy( + () -> CustomTypeReflectionUtil.getCustomTypeConstructor(customTypeClass) // when + ); + } + + @Test + void testGetCustomTypeConstructorWithMismatchingConstructor() { + // given + var customTypeClass = OtherInvalidCustomType.class; + + // then + assertThatExceptionOfType(NoSuchMethodException.class).isThrownBy( + () -> CustomTypeReflectionUtil.getCustomTypeConstructor(customTypeClass) // when + ); + } + + @Test + void testGetCustomTypeConstructorWithInheritedCustomType() throws Exception { + // given + var customTypeClass = ChildClass.class; + + // when + var constructor = CustomTypeReflectionUtil.getCustomTypeConstructor(customTypeClass); + + // then + assertThat(constructor).isNotNull(); + assertThat(constructor.getParameterCount()).isEqualTo(1); + assertThat(constructor.getParameterTypes()[0]).isEqualTo(Integer.class); + } + + @SuppressWarnings("checkstyle:RedundantModifier") + @CustomTypeScanner.DisableCustomTypeConfiguration + public static class ValidCustomType implements CustomType { + private final String value; + + public ValidCustomType(Long otherValue) { + this.value = ""; + } + + public ValidCustomType(String value) { + this.value = value; + } + + @Override + public String value() { + return value; + } + } + + @CustomTypeScanner.DisableCustomTypeConfiguration + public static class InvalidCustomType implements CustomType { + @Override + public String value() { + return null; + } + + // Missing the required constructor + } + + @SuppressWarnings("checkstyle:RedundantModifier") + @CustomTypeScanner.DisableCustomTypeConfiguration + public static class OtherInvalidCustomType implements CustomType { + private final String value; + + // wrong type constructor + public OtherInvalidCustomType(Long value) { + this.value = ""; + } + + @Override + public String value() { + return value; + } + } + + @SuppressWarnings("checkstyle:RedundantModifier") + @CustomTypeScanner.DisableCustomTypeConfiguration + public static class ParentClass implements CustomType { + private final Integer value; + + public ParentClass(Integer value) { + this.value = value; + } + + @Override + public Integer value() { + return value; + } + } + + @SuppressWarnings("checkstyle:RedundantModifier") + @CustomTypeScanner.DisableCustomTypeConfiguration + public static class ChildClass extends ParentClass { + public ChildClass(Integer value) { + super(value); + } + } +} diff --git a/src/test/resources/db/changelog/2024-09-06-create-wrapper-type-testing-table.yml b/src/test/resources/db/changelog/2024-09-06-create-wrapper-type-testing-table.yml index 1ae8cb5..fd963ca 100644 --- a/src/test/resources/db/changelog/2024-09-06-create-wrapper-type-testing-table.yml +++ b/src/test/resources/db/changelog/2024-09-06-create-wrapper-type-testing-table.yml @@ -37,6 +37,51 @@ databaseChangeLog: - column: name: short_value type: bigint + - column: + name: byte_value + type: integer - column: name: string_value type: text + - column: + name: char_value + type: char + - column: + name: bool_value + type: boolean + - column: + name: big_decimal_value_class + type: double + - column: + name: big_integer_value_class + type: bigint + - column: + name: double_value_class + type: double + - column: + name: float_value_class + type: double + - column: + name: integer_value_class + type: bigint + - column: + name: long_value_class + type: bigint + - column: + name: scaled_big_decimal_value_class + type: double + - column: + name: short_value_class + type: bigint + - column: + name: byte_value_class + type: integer + - column: + name: string_value_class + type: text + - column: + name: char_value_class + type: char + - column: + name: bool_value_class + type: boolean