mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#534 fix array initializer for NullValueMappingStrategy.RETURN_DEFAULT
This commit is contained in:
parent
229537284a
commit
8816b380c3
@ -33,7 +33,7 @@
|
|||||||
}
|
}
|
||||||
return<#if returnType.name != "void"> ${resultName}</#if>;
|
return<#if returnType.name != "void"> ${resultName}</#if>;
|
||||||
<#else>
|
<#else>
|
||||||
return new <@includeModel object=resultElementType/>[];
|
return new <@includeModel object=resultElementType/>[0];
|
||||||
</#if>
|
</#if>
|
||||||
<#else>
|
<#else>
|
||||||
<#if existingInstanceMapping>
|
<#if existingInstanceMapping>
|
||||||
|
@ -18,8 +18,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.array;
|
package org.mapstruct.ap.test.array;
|
||||||
|
|
||||||
import static org.fest.assertions.Assertions.assertThat;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -31,6 +29,8 @@ import org.mapstruct.ap.testutil.IssueKey;
|
|||||||
import org.mapstruct.ap.testutil.WithClasses;
|
import org.mapstruct.ap.testutil.WithClasses;
|
||||||
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
||||||
|
|
||||||
|
import static org.fest.assertions.Assertions.assertThat;
|
||||||
|
|
||||||
@WithClasses( { Scientist.class, ScientistDto.class, ScienceMapper.class } )
|
@WithClasses( { Scientist.class, ScientistDto.class, ScienceMapper.class } )
|
||||||
@RunWith(AnnotationProcessorTestRunner.class)
|
@RunWith(AnnotationProcessorTestRunner.class)
|
||||||
@IssueKey("108")
|
@IssueKey("108")
|
||||||
@ -142,6 +142,7 @@ public class ArrayMappingTest {
|
|||||||
assertThat( existingTarget ).onProperty( "name" ).containsOnly( "Jim" );
|
assertThat( existingTarget ).onProperty( "name" ).containsOnly( "Jim" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@IssueKey("534")
|
||||||
@Test
|
@Test
|
||||||
public void shouldMapbooleanWhenReturnDefault() {
|
public void shouldMapbooleanWhenReturnDefault() {
|
||||||
|
|
||||||
@ -150,6 +151,8 @@ public class ArrayMappingTest {
|
|||||||
|
|
||||||
assertThat( target ).containsOnly( false );
|
assertThat( target ).containsOnly( false );
|
||||||
assertThat( existingTarget ).containsOnly( false );
|
assertThat( existingTarget ).containsOnly( false );
|
||||||
|
|
||||||
|
assertThat( ScienceMapper.INSTANCE.nvmMapping( null ) ).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
package org.mapstruct.ap.test.array;
|
package org.mapstruct.ap.test.array;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.mapstruct.IterableMapping;
|
|
||||||
|
|
||||||
|
import org.mapstruct.IterableMapping;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.MappingTarget;
|
import org.mapstruct.MappingTarget;
|
||||||
import org.mapstruct.NullValueMappingStrategy;
|
import org.mapstruct.NullValueMappingStrategy;
|
||||||
@ -43,6 +43,9 @@ public interface ScienceMapper {
|
|||||||
|
|
||||||
ScientistDto[] scientistsToDtos(Scientist[] scientists, @MappingTarget ScientistDto[] target);
|
ScientistDto[] scientistsToDtos(Scientist[] scientists, @MappingTarget ScientistDto[] target);
|
||||||
|
|
||||||
|
@IterableMapping(nullValueMappingStrategy = NullValueMappingStrategy.RETURN_DEFAULT)
|
||||||
|
boolean[] nvmMapping(boolean[] source);
|
||||||
|
|
||||||
@IterableMapping( nullValueMappingStrategy = NullValueMappingStrategy.RETURN_DEFAULT )
|
@IterableMapping( nullValueMappingStrategy = NullValueMappingStrategy.RETURN_DEFAULT )
|
||||||
boolean[] nvmMapping(boolean[] source, @MappingTarget boolean[] target);
|
boolean[] nvmMapping(boolean[] source, @MappingTarget boolean[] target);
|
||||||
|
|
||||||
@ -71,6 +74,4 @@ public interface ScienceMapper {
|
|||||||
|
|
||||||
@IterableMapping( nullValueMappingStrategy = NullValueMappingStrategy.RETURN_DEFAULT )
|
@IterableMapping( nullValueMappingStrategy = NullValueMappingStrategy.RETURN_DEFAULT )
|
||||||
void nvmMappingVoidReturnDefault(int[] source, @MappingTarget long[] target);
|
void nvmMappingVoidReturnDefault(int[] source, @MappingTarget long[] target);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user