Skip to content

Commit

Permalink
add nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS for all ma…
Browse files Browse the repository at this point in the history
…ppers

up version to 1.1.3-RELEAS
  • Loading branch information
Pinkolik committed Dec 29, 2021
1 parent 0703be7 commit b2a6b6a
Show file tree
Hide file tree
Showing 41 changed files with 137 additions and 52 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text eol=lf
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ Add this to your pom.xml.
<plugin>
<groupId>io.github.pinkolik</groupId>
<artifactId>general-classes-generator-maven-plugin</artifactId>
<version>1.1.2-RELEASE</version>
<version>1.1.3-RELEASE</version>
<executions>
<execution>
<id>generate-general-classes</id>
Expand Down Expand Up @@ -302,7 +302,7 @@ Add this to your pom.xml.
<dependency>
<groupId>io.github.pinkolik</groupId>
<artifactId>general-classes-generator-conversion</artifactId>
<version>1.1.2-RELEASE</version>
<version>1.1.3-RELEASE</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
Expand All @@ -325,7 +325,7 @@ Add this to your pom.xml.
<plugin>
<groupId>io.github.pinkolik</groupId>
<artifactId>general-classes-generator-maven-plugin</artifactId>
<version>1.1.2-RELEASE</version>
<version>1.1.3-RELEASE</version>
<executions>
<execution>
<id>generate-mappers</id>
Expand Down Expand Up @@ -412,7 +412,7 @@ Add this to your pom.xml.
<dependency>
<groupId>io.github.pinkolik</groupId>
<artifactId>general-classes-generator-conversion</artifactId>
<version>1.1.2-RELEASE</version>
<version>1.1.3-RELEASE</version>
</dependency>
...
</dependencies>
Expand All @@ -424,7 +424,7 @@ Add this to your pom.xml.
<plugin>
<groupId>io.github.pinkolik</groupId>
<artifactId>general-classes-generator-maven-plugin</artifactId>
<version>1.1.2-RELEASE</version>
<version>1.1.3-RELEASE</version>
<executions>
<execution>
<id>generate-base-converters-config</id>
Expand Down Expand Up @@ -540,10 +540,10 @@ Project Link: [https://github.com/Pinkolik/general-classes-generator](https://gi

[maven-central-plugin-shield]: https://img.shields.io/maven-central/v/io.github.pinkolik/general-classes-generator-maven-plugin?color=success&label=general-classes-generator-maven-plugin&style=plastic

[maven-central-plugin-url]: https://search.maven.org/artifact/io.github.pinkolik/general-classes-generator-maven-plugin/1.1.2-RELEASE/maven-plugin
[maven-central-plugin-url]: https://search.maven.org/artifact/io.github.pinkolik/general-classes-generator-maven-plugin/1.1.3-RELEASE/maven-plugin

[maven-central-conversion-shield]: https://img.shields.io/maven-central/v/io.github.pinkolik/general-classes-generator-conversion?color=success&label=general-classes-generator-conversion&style=plastic

[maven-central-conversion-url]: https://search.maven.org/artifact/io.github.pinkolik/general-classes-generator-conversion/1.1.2-RELEASE/jar
[maven-central-conversion-url]: https://search.maven.org/artifact/io.github.pinkolik/general-classes-generator-conversion/1.1.3-RELEASE/jar

[build-badge-url]: https://github.com/Pinkolik/general-classes-generator/actions/workflows/maven-publish.yml/badge.svg
2 changes: 1 addition & 1 deletion general-classes-generator-conversion/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>general-classes-generator</artifactId>
<groupId>io.github.pinkolik</groupId>
<version>1.1.2-RELEASE</version>
<version>1.1.3-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
4 changes: 2 additions & 2 deletions general-classes-generator-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>general-classes-generator</artifactId>
<groupId>io.github.pinkolik</groupId>
<version>1.1.2-RELEASE</version>
<version>1.1.3-RELEASE</version>
</parent>

<artifactId>general-classes-generator-maven-plugin</artifactId>
Expand Down Expand Up @@ -98,7 +98,7 @@
<dependency>
<groupId>io.github.pinkolik</groupId>
<artifactId>general-classes-generator-conversion</artifactId>
<version>1.1.2-RELEASE</version>
<version>1.1.3-RELEASE</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package ${package_name};

import org.mapstruct.Mapper;
import org.mapstruct.NullValueCheckStrategy;
import org.mapstruct.factory.Mappers;
import ${base_mapper_name};

@Mapper(uses = {${additional_mappers}})
@Mapper(nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS, uses = {${additional_mappers}})
public interface ${mapper_name} extends
${base_mapper_simple_name}<${versioned_class_name}, ${general_class_name}> {

Expand Down
2 changes: 1 addition & 1 deletion general-classes-generator-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>general-classes-generator</artifactId>
<groupId>io.github.pinkolik</groupId>
<version>1.1.2-RELEASE</version>
<version>1.1.3-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion general-classes-generator-tests/test-classes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>general-classes-generator-tests</artifactId>
<groupId>io.github.pinkolik</groupId>
<version>1.1.2-RELEASE</version>
<version>1.1.3-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.github.pinkolik.general_classes_generator.test.ver1;

import lombok.Data;

@Data
public class IgnoreNullTest {

public static boolean aWasNotSet = true;

private String a;

private String d;

public void setA(final String a) {
this.a = a;
aWasNotSet = false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.github.pinkolik.general_classes_generator.test.ver2;

import lombok.Data;

@Data
public class IgnoreNullTest {

private String b;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.github.pinkolik.general_classes_generator.test.ver3;

import lombok.Data;

@Data
public class IgnoreNullTest {

private String c;
}
14 changes: 7 additions & 7 deletions general-classes-generator-tests/tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>general-classes-generator-tests</artifactId>
<groupId>io.github.pinkolik</groupId>
<version>1.1.2-RELEASE</version>
<version>1.1.3-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -59,17 +59,17 @@
<dependency>
<groupId>io.github.pinkolik</groupId>
<artifactId>general-classes-generator-conversion</artifactId>
<version>1.1.2-RELEASE</version>
<version>1.1.3-RELEASE</version>
</dependency>
<dependency>
<groupId>io.github.pinkolik</groupId>
<artifactId>test-classes</artifactId>
<version>1.1.2-RELEASE</version>
<version>1.1.3-RELEASE</version>
</dependency>
<dependency>
<groupId>io.github.pinkolik</groupId>
<artifactId>general-classes-generator-maven-plugin</artifactId>
<version>1.1.2-RELEASE</version>
<version>1.1.3-RELEASE</version>
<scope>test</scope>
</dependency>

Expand Down Expand Up @@ -136,7 +136,7 @@
<target>
<echo level="info">Deleting old classes</echo>
<delete includeEmptyDirs="true" failonerror="false">
<fileset dir="src/main/java" includes="**/*"/>
<fileset dir="${project.basedir}/src/main/java" includes="**/*"/>
</delete>
</target>
</configuration>
Expand All @@ -146,7 +146,7 @@
<plugin>
<groupId>io.github.pinkolik</groupId>
<artifactId>general-classes-generator-maven-plugin</artifactId>
<version>1.1.2-RELEASE</version>
<version>1.1.3-RELEASE</version>
<executions>
<execution>
<id>generate-general-classes</id>
Expand Down Expand Up @@ -198,7 +198,7 @@
<dependency>
<groupId>io.github.pinkolik</groupId>
<artifactId>test-classes</artifactId>
<version>1.1.2-RELEASE</version>
<version>1.1.3-RELEASE</version>
</dependency>
</dependencies>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.github.pinkolik.general_classes_generator.conversion.BaseConverter;
import io.github.pinkolik.general_classes_generator.conversion.Generalized;
import io.github.pinkolik.general_classes_generator.test.IgnoreNullTest;
import io.github.pinkolik.general_classes_generator.test.InnerClassWithGenericField;
import io.github.pinkolik.general_classes_generator.test.Simple;
import io.github.pinkolik.general_classes_generator.test.UpcastingTestClass;
Expand All @@ -25,8 +26,6 @@ public class BaseConverterImplTest {
@Qualifier("baseConverterVer1")
private BaseConverter baseConverterVer1;

public static class ClassWithoutMapper implements Generalized {}

/*********************************************
* 1. Wrong package test *
* 2. Only generalized can be passed test *
Expand Down Expand Up @@ -153,8 +152,8 @@ void generalToVersionedCollectionTest() {

Object result = baseConverterVer1.convertToVersionedClass(obj);

Assertions
.assertTrue(result instanceof io.github.pinkolik.general_classes_generator.test.ver1.InnerClassWithGenericField);
Assertions.assertTrue(
result instanceof io.github.pinkolik.general_classes_generator.test.ver1.InnerClassWithGenericField);
List<io.github.pinkolik.general_classes_generator.test.ver1.InnerClassWithGenericField.Inner> resultList =
((io.github.pinkolik.general_classes_generator.test.ver1.InnerClassWithGenericField) result).getA();
Assertions.assertEquals(3, resultList.size());
Expand Down Expand Up @@ -245,4 +244,19 @@ void versionedToGeneralUpcastingCollectionTest() {
Assertions.assertEquals(simple.getA(), simpleResult.getA());
}
}

@Test
void generalToVersionedIgnoreNullTest() {
IgnoreNullTest ignoreNullTest = new IgnoreNullTest();
ignoreNullTest.setD("test");

io.github.pinkolik.general_classes_generator.test.ver1.IgnoreNullTest versioned =
(io.github.pinkolik.general_classes_generator.test.ver1.IgnoreNullTest) baseConverterVer1.convertToVersionedClass(
ignoreNullTest);

Assertions.assertEquals(ignoreNullTest.getD(), versioned.getD());
Assertions.assertTrue(io.github.pinkolik.general_classes_generator.test.ver1.IgnoreNullTest.aWasNotSet);
}

public static class ClassWithoutMapper implements Generalized {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public BaseConverter baseConverterVer1() {
versionedClassesToMappers.put(io.github.pinkolik.general_classes_generator.test.ver1.EnumIsNotSerializable.class, io.github.pinkolik.general_classes_generator.test.mappers.ver1.EnumIsNotSerializableMapper.INSTANCE);
generalClassesToMappers.put(io.github.pinkolik.general_classes_generator.test.EnumWithField.class, io.github.pinkolik.general_classes_generator.test.mappers.ver1.EnumWithFieldMapper.INSTANCE);
versionedClassesToMappers.put(io.github.pinkolik.general_classes_generator.test.ver1.EnumWithField.class, io.github.pinkolik.general_classes_generator.test.mappers.ver1.EnumWithFieldMapper.INSTANCE);
generalClassesToMappers.put(io.github.pinkolik.general_classes_generator.test.IgnoreNullTest.class, io.github.pinkolik.general_classes_generator.test.mappers.ver1.IgnoreNullTestMapper.INSTANCE);
versionedClassesToMappers.put(io.github.pinkolik.general_classes_generator.test.ver1.IgnoreNullTest.class, io.github.pinkolik.general_classes_generator.test.mappers.ver1.IgnoreNullTestMapper.INSTANCE);
generalClassesToMappers.put(io.github.pinkolik.general_classes_generator.test.InheritanceTestClass.class, io.github.pinkolik.general_classes_generator.test.mappers.ver1.InheritanceTestClassMapper.INSTANCE);
versionedClassesToMappers.put(io.github.pinkolik.general_classes_generator.test.ver1.InheritanceTestClass.class, io.github.pinkolik.general_classes_generator.test.mappers.ver1.InheritanceTestClassMapper.INSTANCE);
generalClassesToMappers.put(io.github.pinkolik.general_classes_generator.test.InheritanceWithSerializableTestClass.class, io.github.pinkolik.general_classes_generator.test.mappers.ver1.InheritanceWithSerializableTestClassMapper.INSTANCE);
Expand Down Expand Up @@ -72,6 +74,8 @@ public BaseConverter baseConverterVer2() {
versionedClassesToMappers.put(io.github.pinkolik.general_classes_generator.test.ver2.EnumIsNotSerializable.class, io.github.pinkolik.general_classes_generator.test.mappers.ver2.EnumIsNotSerializableMapper.INSTANCE);
generalClassesToMappers.put(io.github.pinkolik.general_classes_generator.test.EnumWithField.class, io.github.pinkolik.general_classes_generator.test.mappers.ver2.EnumWithFieldMapper.INSTANCE);
versionedClassesToMappers.put(io.github.pinkolik.general_classes_generator.test.ver2.EnumWithField.class, io.github.pinkolik.general_classes_generator.test.mappers.ver2.EnumWithFieldMapper.INSTANCE);
generalClassesToMappers.put(io.github.pinkolik.general_classes_generator.test.IgnoreNullTest.class, io.github.pinkolik.general_classes_generator.test.mappers.ver2.IgnoreNullTestMapper.INSTANCE);
versionedClassesToMappers.put(io.github.pinkolik.general_classes_generator.test.ver2.IgnoreNullTest.class, io.github.pinkolik.general_classes_generator.test.mappers.ver2.IgnoreNullTestMapper.INSTANCE);
generalClassesToMappers.put(io.github.pinkolik.general_classes_generator.test.InheritanceTestClass.class, io.github.pinkolik.general_classes_generator.test.mappers.ver2.InheritanceTestClassMapper.INSTANCE);
versionedClassesToMappers.put(io.github.pinkolik.general_classes_generator.test.ver2.InheritanceTestClass.class, io.github.pinkolik.general_classes_generator.test.mappers.ver2.InheritanceTestClassMapper.INSTANCE);
generalClassesToMappers.put(io.github.pinkolik.general_classes_generator.test.InheritanceWithSerializableTestClass.class, io.github.pinkolik.general_classes_generator.test.mappers.ver2.InheritanceWithSerializableTestClassMapper.INSTANCE);
Expand Down Expand Up @@ -117,6 +121,8 @@ public BaseConverter baseConverterVer3() {
versionedClassesToMappers.put(io.github.pinkolik.general_classes_generator.test.ver3.EnumIsNotSerializable.class, io.github.pinkolik.general_classes_generator.test.mappers.ver3.EnumIsNotSerializableMapper.INSTANCE);
generalClassesToMappers.put(io.github.pinkolik.general_classes_generator.test.EnumWithField.class, io.github.pinkolik.general_classes_generator.test.mappers.ver3.EnumWithFieldMapper.INSTANCE);
versionedClassesToMappers.put(io.github.pinkolik.general_classes_generator.test.ver3.EnumWithField.class, io.github.pinkolik.general_classes_generator.test.mappers.ver3.EnumWithFieldMapper.INSTANCE);
generalClassesToMappers.put(io.github.pinkolik.general_classes_generator.test.IgnoreNullTest.class, io.github.pinkolik.general_classes_generator.test.mappers.ver3.IgnoreNullTestMapper.INSTANCE);
versionedClassesToMappers.put(io.github.pinkolik.general_classes_generator.test.ver3.IgnoreNullTest.class, io.github.pinkolik.general_classes_generator.test.mappers.ver3.IgnoreNullTestMapper.INSTANCE);
generalClassesToMappers.put(io.github.pinkolik.general_classes_generator.test.InheritanceTestClass.class, io.github.pinkolik.general_classes_generator.test.mappers.ver3.InheritanceTestClassMapper.INSTANCE);
versionedClassesToMappers.put(io.github.pinkolik.general_classes_generator.test.ver3.InheritanceTestClass.class, io.github.pinkolik.general_classes_generator.test.mappers.ver3.InheritanceTestClassMapper.INSTANCE);
generalClassesToMappers.put(io.github.pinkolik.general_classes_generator.test.InheritanceWithSerializableTestClass.class, io.github.pinkolik.general_classes_generator.test.mappers.ver3.InheritanceWithSerializableTestClassMapper.INSTANCE);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package io.github.pinkolik.general_classes_generator.test.mappers.ver1;

import org.mapstruct.Mapper;
import org.mapstruct.NullValueCheckStrategy;
import org.mapstruct.factory.Mappers;
import io.github.pinkolik.general_classes_generator.conversion.BaseMapper;

@Mapper(uses = {})
@Mapper(nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS, uses = {})
public interface EnumMapper extends
BaseMapper<io.github.pinkolik.general_classes_generator.test.ver1.Enum, io.github.pinkolik.general_classes_generator.test.Enum> {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package io.github.pinkolik.general_classes_generator.test.mappers.ver1;

import org.mapstruct.Mapper;
import org.mapstruct.NullValueCheckStrategy;
import org.mapstruct.factory.Mappers;
import io.github.pinkolik.general_classes_generator.conversion.BaseMapper;

@Mapper(uses = {})
@Mapper(nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS, uses = {})
public interface InheritanceTestClassMapper extends
BaseMapper<io.github.pinkolik.general_classes_generator.test.ver1.InheritanceTestClass, io.github.pinkolik.general_classes_generator.test.InheritanceTestClass> {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package io.github.pinkolik.general_classes_generator.test.mappers.ver1;

import org.mapstruct.Mapper;
import org.mapstruct.NullValueCheckStrategy;
import org.mapstruct.factory.Mappers;
import io.github.pinkolik.general_classes_generator.conversion.BaseMapper;

@Mapper(uses = {InnerClass_InnerMapper.class, })
@Mapper(nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS, uses = {InnerClass_InnerMapper.class, })
public interface InnerClassMapper extends
BaseMapper<io.github.pinkolik.general_classes_generator.test.ver1.InnerClass, io.github.pinkolik.general_classes_generator.test.InnerClass> {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package io.github.pinkolik.general_classes_generator.test.mappers.ver1;

import org.mapstruct.Mapper;
import org.mapstruct.NullValueCheckStrategy;
import org.mapstruct.factory.Mappers;
import io.github.pinkolik.general_classes_generator.conversion.BaseMapper;

@Mapper(uses = {InnerClassWithInnerEnum_InnerClassWithEnumMapper.class, InnerClassWithInnerEnum_InnerClassWithEnum_InnerEnumMapper.class, })
@Mapper(nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS, uses = {InnerClassWithInnerEnum_InnerClassWithEnumMapper.class, InnerClassWithInnerEnum_InnerClassWithEnum_InnerEnumMapper.class, })
public interface InnerClassWithInnerEnumMapper extends
BaseMapper<io.github.pinkolik.general_classes_generator.test.ver1.InnerClassWithInnerEnum, io.github.pinkolik.general_classes_generator.test.InnerClassWithInnerEnum> {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package io.github.pinkolik.general_classes_generator.test.mappers.ver1;

import org.mapstruct.Mapper;
import org.mapstruct.NullValueCheckStrategy;
import org.mapstruct.factory.Mappers;
import io.github.pinkolik.general_classes_generator.conversion.BaseMapper;

@Mapper(uses = {InnerClassWithInnerEnum_InnerClassWithEnum_InnerEnumMapper.class, })
@Mapper(nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS, uses = {InnerClassWithInnerEnum_InnerClassWithEnum_InnerEnumMapper.class, })
public interface InnerClassWithInnerEnum_InnerClassWithEnumMapper extends
BaseMapper<io.github.pinkolik.general_classes_generator.test.ver1.InnerClassWithInnerEnum.InnerClassWithEnum, io.github.pinkolik.general_classes_generator.test.InnerClassWithInnerEnum.InnerClassWithEnum> {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package io.github.pinkolik.general_classes_generator.test.mappers.ver1;

import org.mapstruct.Mapper;
import org.mapstruct.NullValueCheckStrategy;
import org.mapstruct.factory.Mappers;
import io.github.pinkolik.general_classes_generator.conversion.BaseMapper;

@Mapper(uses = {})
@Mapper(nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS, uses = {})
public interface InnerClassWithInnerEnum_InnerClassWithEnum_InnerEnumMapper extends
BaseMapper<io.github.pinkolik.general_classes_generator.test.ver1.InnerClassWithInnerEnum.InnerClassWithEnum.InnerEnum, io.github.pinkolik.general_classes_generator.test.InnerClassWithInnerEnum.InnerClassWithEnum.InnerEnum> {

Expand Down
Loading

0 comments on commit b2a6b6a

Please sign in to comment.