mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#1007 Add additional generated code tests
This commit is contained in:
parent
8654d8f45a
commit
ec6913618e
@ -20,12 +20,16 @@ package org.mapstruct.ap.test.bugs._913;
|
|||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
|
||||||
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mapstruct.ap.testutil.IssueKey;
|
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 org.mapstruct.ap.testutil.runner.GeneratedSource;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All these test cases test the possible combinations in the SetterMapperForCollections.
|
* All these test cases test the possible combinations in the SetterMapperForCollections.
|
||||||
@ -47,6 +51,14 @@ import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
|||||||
@IssueKey( "913" )
|
@IssueKey( "913" )
|
||||||
public class Issue913SetterMapperForCollectionsTest {
|
public class Issue913SetterMapperForCollectionsTest {
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public final GeneratedSource generatedSource = new GeneratedSource().addComparisonToFixtureFor(
|
||||||
|
DomainDtoWithNvmsNullMapper.class,
|
||||||
|
DomainDtoWithNvmsDefaultMapper.class,
|
||||||
|
DomainDtoWithPresenceCheckMapper.class,
|
||||||
|
DomainDtoWithNcvsAlwaysMapper.class
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The null value mapping strategy on type level (Mapper) should generate forged methods for the
|
* The null value mapping strategy on type level (Mapper) should generate forged methods for the
|
||||||
* conversion from string to long that return null in the entire mapper, so also for the forged
|
* conversion from string to long that return null in the entire mapper, so also for the forged
|
||||||
|
@ -18,13 +18,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.collection.adder;
|
package org.mapstruct.ap.test.collection.adder;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mapstruct.ap.test.collection.adder._target.AdderUsageObserver;
|
import org.mapstruct.ap.test.collection.adder._target.AdderUsageObserver;
|
||||||
@ -46,6 +43,11 @@ import org.mapstruct.ap.test.collection.adder.source.SourceTeeth;
|
|||||||
import org.mapstruct.ap.testutil.IssueKey;
|
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 org.mapstruct.ap.testutil.runner.GeneratedSource;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Sjaak Derksen
|
* @author Sjaak Derksen
|
||||||
@ -75,6 +77,13 @@ import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
|||||||
@RunWith(AnnotationProcessorTestRunner.class)
|
@RunWith(AnnotationProcessorTestRunner.class)
|
||||||
public class AdderTest {
|
public class AdderTest {
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public final GeneratedSource generatedSource = new GeneratedSource().addComparisonToFixtureFor(
|
||||||
|
SourceTargetMapper.class,
|
||||||
|
SourceTargetMapperStrategyDefault.class,
|
||||||
|
SourceTargetMapperStrategySetterPreferred.class
|
||||||
|
);
|
||||||
|
|
||||||
@IssueKey("241")
|
@IssueKey("241")
|
||||||
@Test
|
@Test
|
||||||
public void testAdd() throws DogException {
|
public void testAdd() throws DogException {
|
||||||
@ -252,6 +261,7 @@ public class AdderTest {
|
|||||||
Foo.class
|
Foo.class
|
||||||
} )
|
} )
|
||||||
public void testMissingImport() throws DogException {
|
public void testMissingImport() throws DogException {
|
||||||
|
generatedSource.addComparisonToFixtureFor( Source2Target2Mapper.class );
|
||||||
|
|
||||||
Source2 source = new Source2();
|
Source2 source = new Source2();
|
||||||
source.setAttributes( Arrays.asList( new Foo() ) );
|
source.setAttributes( Arrays.asList( new Foo() ) );
|
||||||
|
@ -18,13 +18,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.conversion.string;
|
package org.mapstruct.ap.test.conversion.string;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import org.junit.Rule;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mapstruct.ap.testutil.IssueKey;
|
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 org.mapstruct.ap.testutil.runner.GeneratedSource;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@WithClasses({
|
@WithClasses({
|
||||||
Source.class,
|
Source.class,
|
||||||
@ -36,6 +38,10 @@ public class StringConversionTest {
|
|||||||
|
|
||||||
private static final String STRING_CONSTANT = "String constant";
|
private static final String STRING_CONSTANT = "String constant";
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public final GeneratedSource generatedSource = new GeneratedSource().addComparisonToFixtureFor(
|
||||||
|
SourceTargetMapper.class );
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldApplyStringConversions() {
|
public void shouldApplyStringConversions() {
|
||||||
Source source = new Source();
|
Source source = new Source();
|
||||||
|
@ -18,8 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.updatemethods;
|
package org.mapstruct.ap.test.updatemethods;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import org.junit.Rule;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mapstruct.ap.testutil.IssueKey;
|
import org.mapstruct.ap.testutil.IssueKey;
|
||||||
@ -28,6 +27,9 @@ import org.mapstruct.ap.testutil.compilation.annotation.CompilationResult;
|
|||||||
import org.mapstruct.ap.testutil.compilation.annotation.Diagnostic;
|
import org.mapstruct.ap.testutil.compilation.annotation.Diagnostic;
|
||||||
import org.mapstruct.ap.testutil.compilation.annotation.ExpectedCompilationOutcome;
|
import org.mapstruct.ap.testutil.compilation.annotation.ExpectedCompilationOutcome;
|
||||||
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
||||||
|
import org.mapstruct.ap.testutil.runner.GeneratedSource;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -52,11 +54,15 @@ import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
|||||||
})
|
})
|
||||||
public class UpdateMethodsTest {
|
public class UpdateMethodsTest {
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public final GeneratedSource generatedSource = new GeneratedSource();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@WithClasses( {
|
@WithClasses( {
|
||||||
OrganizationMapper.class
|
OrganizationMapper.class
|
||||||
} )
|
} )
|
||||||
public void testPreferUpdateMethod() {
|
public void testPreferUpdateMethod() {
|
||||||
|
generatedSource.addComparisonToFixtureFor( OrganizationMapper.class );
|
||||||
|
|
||||||
OrganizationEntity organizationEntity = new OrganizationEntity();
|
OrganizationEntity organizationEntity = new OrganizationEntity();
|
||||||
CompanyEntity companyEntity = new CompanyEntity();
|
CompanyEntity companyEntity = new CompanyEntity();
|
||||||
@ -85,6 +91,7 @@ public class UpdateMethodsTest {
|
|||||||
OrganizationMapper.class
|
OrganizationMapper.class
|
||||||
} )
|
} )
|
||||||
public void testUpdateMethodClearsExistingValues() {
|
public void testUpdateMethodClearsExistingValues() {
|
||||||
|
generatedSource.addComparisonToFixtureFor( OrganizationMapper.class );
|
||||||
|
|
||||||
OrganizationEntity organizationEntity = new OrganizationEntity();
|
OrganizationEntity organizationEntity = new OrganizationEntity();
|
||||||
CompanyEntity companyEntity = new CompanyEntity();
|
CompanyEntity companyEntity = new CompanyEntity();
|
||||||
@ -109,6 +116,7 @@ public class UpdateMethodsTest {
|
|||||||
OrganizationMapper.class
|
OrganizationMapper.class
|
||||||
})
|
})
|
||||||
public void testPreferUpdateMethodSourceObjectNotDefined() {
|
public void testPreferUpdateMethodSourceObjectNotDefined() {
|
||||||
|
generatedSource.addComparisonToFixtureFor( OrganizationMapper.class );
|
||||||
|
|
||||||
OrganizationEntity organizationEntity = new OrganizationEntity();
|
OrganizationEntity organizationEntity = new OrganizationEntity();
|
||||||
|
|
||||||
@ -134,6 +142,7 @@ public class UpdateMethodsTest {
|
|||||||
DepartmentInBetween.class
|
DepartmentInBetween.class
|
||||||
} )
|
} )
|
||||||
public void testPreferUpdateMethodEncapsulatingCreateMethod() {
|
public void testPreferUpdateMethodEncapsulatingCreateMethod() {
|
||||||
|
generatedSource.addComparisonToFixtureFor( CompanyMapper.class );
|
||||||
|
|
||||||
CompanyEntity companyEntity = new CompanyEntity();
|
CompanyEntity companyEntity = new CompanyEntity();
|
||||||
|
|
||||||
|
@ -18,12 +18,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.updatemethods.selection;
|
package org.mapstruct.ap.test.updatemethods.selection;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mapstruct.ap.test.updatemethods.BossDto;
|
import org.mapstruct.ap.test.updatemethods.BossDto;
|
||||||
@ -41,6 +40,9 @@ import org.mapstruct.ap.test.updatemethods.SecretaryEntity;
|
|||||||
import org.mapstruct.ap.testutil.IssueKey;
|
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 org.mapstruct.ap.testutil.runner.GeneratedSource;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -68,11 +70,19 @@ import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
|||||||
})
|
})
|
||||||
public class ExternalSelectionTest {
|
public class ExternalSelectionTest {
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public final GeneratedSource generatedSource = new GeneratedSource().addComparisonToFixtureFor(
|
||||||
|
OrganizationMapper1.class,
|
||||||
|
ExternalMapper.class,
|
||||||
|
DepartmentMapper.class
|
||||||
|
);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@WithClasses({
|
@WithClasses({
|
||||||
OrganizationMapper1.class
|
OrganizationMapper1.class
|
||||||
})
|
})
|
||||||
public void shouldSelectGeneratedExternalMapper() {
|
public void shouldSelectGeneratedExternalMapper() {
|
||||||
|
generatedSource.addComparisonToFixtureFor( OrganizationMapper1.class );
|
||||||
|
|
||||||
CompanyEntity entity = new CompanyEntity();
|
CompanyEntity entity = new CompanyEntity();
|
||||||
CompanyDto dto = new CompanyDto();
|
CompanyDto dto = new CompanyDto();
|
||||||
@ -85,6 +95,7 @@ public class ExternalSelectionTest {
|
|||||||
})
|
})
|
||||||
@IssueKey("604")
|
@IssueKey("604")
|
||||||
public void shouldSelectGeneratedExternalMapperWithImportForPropertyType() {
|
public void shouldSelectGeneratedExternalMapperWithImportForPropertyType() {
|
||||||
|
generatedSource.addComparisonToFixtureFor( OrganizationMapper3.class );
|
||||||
|
|
||||||
BossEntity entity = new BossEntity();
|
BossEntity entity = new BossEntity();
|
||||||
BossDto dto = new BossDto();
|
BossDto dto = new BossDto();
|
||||||
@ -96,6 +107,7 @@ public class ExternalSelectionTest {
|
|||||||
OrganizationMapper2.class
|
OrganizationMapper2.class
|
||||||
})
|
})
|
||||||
public void shouldSelectGeneratedHandWrittenExternalMapper() {
|
public void shouldSelectGeneratedHandWrittenExternalMapper() {
|
||||||
|
generatedSource.addComparisonToFixtureFor( OrganizationMapper2.class );
|
||||||
|
|
||||||
CompanyEntity entity = new CompanyEntity();
|
CompanyEntity entity = new CompanyEntity();
|
||||||
CompanyDto dto = new CompanyDto();
|
CompanyDto dto = new CompanyDto();
|
||||||
|
@ -0,0 +1,252 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/)
|
||||||
|
* and/or other contributors as indicated by the @authors tag. See the
|
||||||
|
* copyright.txt file in the distribution for a full listing of all
|
||||||
|
* contributors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.mapstruct.ap.test.bugs._913;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
|
||||||
|
@Generated(
|
||||||
|
value = "org.mapstruct.ap.MappingProcessor",
|
||||||
|
date = "2016-12-30T19:07:28+0100",
|
||||||
|
comments = "version: , compiler: javac, environment: Java 1.8.0_112 (Oracle Corporation)"
|
||||||
|
)
|
||||||
|
public class DomainDtoWithNcvsAlwaysMapperImpl implements DomainDtoWithNcvsAlwaysMapper {
|
||||||
|
|
||||||
|
private final Helper helper = new Helper();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Domain create(DtoWithPresenceCheck source) {
|
||||||
|
if ( source == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Domain domain = new Domain();
|
||||||
|
|
||||||
|
if ( source.hasStringsInitialized() ) {
|
||||||
|
Set<Long> set = stringListToLongSet( source.getStringsInitialized() );
|
||||||
|
domain.setLongsInitialized( set );
|
||||||
|
}
|
||||||
|
if ( source.hasStrings() ) {
|
||||||
|
Set<Long> set_ = stringListToLongSet( source.getStrings() );
|
||||||
|
domain.setLongs( set_ );
|
||||||
|
}
|
||||||
|
if ( source.hasStrings() ) {
|
||||||
|
List<String> list = source.getStrings();
|
||||||
|
domain.setStrings( new HashSet<String>( list )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if ( source.hasStringsWithDefault() ) {
|
||||||
|
List<String> list_ = source.getStringsWithDefault();
|
||||||
|
domain.setStringsWithDefault( new ArrayList<String>( list_ )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
domain.setStringsWithDefault( helper.toList( "3" ) );
|
||||||
|
}
|
||||||
|
if ( source.hasStringsInitialized() ) {
|
||||||
|
List<String> list__ = source.getStringsInitialized();
|
||||||
|
domain.setStringsInitialized( new HashSet<String>( list__ )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(DtoWithPresenceCheck source, Domain target) {
|
||||||
|
if ( source == null ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( target.getLongs() != null ) {
|
||||||
|
if ( source.hasStrings() ) {
|
||||||
|
Set<Long> set = stringListToLongSet( source.getStrings() );
|
||||||
|
target.getLongs().clear();
|
||||||
|
target.getLongs().addAll( set );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ( source.hasStrings() ) {
|
||||||
|
Set<Long> set = stringListToLongSet( source.getStrings() );
|
||||||
|
target.setLongs( set );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getStrings() != null ) {
|
||||||
|
if ( source.hasStrings() ) {
|
||||||
|
List<String> list = source.getStrings();
|
||||||
|
target.getStrings().clear();
|
||||||
|
target.getStrings().addAll( list );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ( source.hasStrings() ) {
|
||||||
|
List<String> list = source.getStrings();
|
||||||
|
target.setStrings( new HashSet<String>( list )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getLongsInitialized() != null ) {
|
||||||
|
if ( source.hasStringsInitialized() ) {
|
||||||
|
Set<Long> set_ = stringListToLongSet( source.getStringsInitialized() );
|
||||||
|
target.getLongsInitialized().clear();
|
||||||
|
target.getLongsInitialized().addAll( set_ );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ( source.hasStringsInitialized() ) {
|
||||||
|
Set<Long> set_ = stringListToLongSet( source.getStringsInitialized() );
|
||||||
|
target.setLongsInitialized( set_ );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getStringsWithDefault() != null ) {
|
||||||
|
if ( source.hasStringsWithDefault() ) {
|
||||||
|
List<String> list_ = source.getStringsWithDefault();
|
||||||
|
target.getStringsWithDefault().clear();
|
||||||
|
target.getStringsWithDefault().addAll( list_ );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ( source.hasStringsWithDefault() ) {
|
||||||
|
List<String> list_ = source.getStringsWithDefault();
|
||||||
|
target.setStringsWithDefault( new ArrayList<String>( list_ )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getStringsInitialized() != null ) {
|
||||||
|
if ( source.hasStringsInitialized() ) {
|
||||||
|
List<String> list__ = source.getStringsInitialized();
|
||||||
|
target.getStringsInitialized().clear();
|
||||||
|
target.getStringsInitialized().addAll( list__ );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ( source.hasStringsInitialized() ) {
|
||||||
|
List<String> list__ = source.getStringsInitialized();
|
||||||
|
target.setStringsInitialized( new HashSet<String>( list__ )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Domain updateWithReturn(DtoWithPresenceCheck source, Domain target) {
|
||||||
|
if ( source == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( target.getLongs() != null ) {
|
||||||
|
if ( source.hasStrings() ) {
|
||||||
|
Set<Long> set = stringListToLongSet( source.getStrings() );
|
||||||
|
target.getLongs().clear();
|
||||||
|
target.getLongs().addAll( set );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ( source.hasStrings() ) {
|
||||||
|
Set<Long> set = stringListToLongSet( source.getStrings() );
|
||||||
|
target.setLongs( set );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getStrings() != null ) {
|
||||||
|
if ( source.hasStrings() ) {
|
||||||
|
List<String> list = source.getStrings();
|
||||||
|
target.getStrings().clear();
|
||||||
|
target.getStrings().addAll( list );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ( source.hasStrings() ) {
|
||||||
|
List<String> list = source.getStrings();
|
||||||
|
target.setStrings( new HashSet<String>( list )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getLongsInitialized() != null ) {
|
||||||
|
if ( source.hasStringsInitialized() ) {
|
||||||
|
Set<Long> set_ = stringListToLongSet( source.getStringsInitialized() );
|
||||||
|
target.getLongsInitialized().clear();
|
||||||
|
target.getLongsInitialized().addAll( set_ );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ( source.hasStringsInitialized() ) {
|
||||||
|
Set<Long> set_ = stringListToLongSet( source.getStringsInitialized() );
|
||||||
|
target.setLongsInitialized( set_ );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getStringsWithDefault() != null ) {
|
||||||
|
if ( source.hasStringsWithDefault() ) {
|
||||||
|
List<String> list_ = source.getStringsWithDefault();
|
||||||
|
target.getStringsWithDefault().clear();
|
||||||
|
target.getStringsWithDefault().addAll( list_ );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ( source.hasStringsWithDefault() ) {
|
||||||
|
List<String> list_ = source.getStringsWithDefault();
|
||||||
|
target.setStringsWithDefault( new ArrayList<String>( list_ )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getStringsInitialized() != null ) {
|
||||||
|
if ( source.hasStringsInitialized() ) {
|
||||||
|
List<String> list__ = source.getStringsInitialized();
|
||||||
|
target.getStringsInitialized().clear();
|
||||||
|
target.getStringsInitialized().addAll( list__ );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ( source.hasStringsInitialized() ) {
|
||||||
|
List<String> list__ = source.getStringsInitialized();
|
||||||
|
target.setStringsInitialized( new HashSet<String>( list__ )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Set<Long> stringListToLongSet(List<String> list) {
|
||||||
|
if ( list == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<Long> set = new HashSet<Long>();
|
||||||
|
for ( String string : list ) {
|
||||||
|
set.add( Long.parseLong( string ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,273 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/)
|
||||||
|
* and/or other contributors as indicated by the @authors tag. See the
|
||||||
|
* copyright.txt file in the distribution for a full listing of all
|
||||||
|
* contributors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.mapstruct.ap.test.bugs._913;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
|
||||||
|
@Generated(
|
||||||
|
value = "org.mapstruct.ap.MappingProcessor",
|
||||||
|
date = "2016-12-30T19:07:27+0100",
|
||||||
|
comments = "version: , compiler: javac, environment: Java 1.8.0_112 (Oracle Corporation)"
|
||||||
|
)
|
||||||
|
public class DomainDtoWithNvmsDefaultMapperImpl implements DomainDtoWithNvmsDefaultMapper {
|
||||||
|
|
||||||
|
private final Helper helper = new Helper();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Domain create(Dto source) {
|
||||||
|
|
||||||
|
Domain domain = new Domain();
|
||||||
|
|
||||||
|
if ( source != null ) {
|
||||||
|
Set<Long> set = stringListToLongSet( source.getStringsInitialized() );
|
||||||
|
if ( set != null ) {
|
||||||
|
domain.setLongsInitialized( set );
|
||||||
|
}
|
||||||
|
Set<Long> set_ = stringListToLongSet( source.getStrings() );
|
||||||
|
if ( set_ != null ) {
|
||||||
|
domain.setLongs( set_ );
|
||||||
|
}
|
||||||
|
List<String> list = source.getStrings();
|
||||||
|
if ( list != null ) {
|
||||||
|
domain.setStrings( new HashSet<String>( list )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
List<String> list_ = source.getStringsWithDefault();
|
||||||
|
if ( list_ != null ) {
|
||||||
|
domain.setStringsWithDefault( new ArrayList<String>( list_ )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
domain.setStringsWithDefault( helper.toList( "3" ) );
|
||||||
|
}
|
||||||
|
List<String> list__ = source.getStringsInitialized();
|
||||||
|
if ( list__ != null ) {
|
||||||
|
domain.setStringsInitialized( new HashSet<String>( list__ )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Dto source, Domain target) {
|
||||||
|
|
||||||
|
if ( source != null ) {
|
||||||
|
if ( target.getLongs() != null ) {
|
||||||
|
Set<Long> set = stringListToLongSet( source.getStrings() );
|
||||||
|
if ( set != null ) {
|
||||||
|
target.getLongs().clear();
|
||||||
|
target.getLongs().addAll( set );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setLongs( null );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Set<Long> set = stringListToLongSet( source.getStrings() );
|
||||||
|
if ( set != null ) {
|
||||||
|
target.setLongs( set );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getStrings() != null ) {
|
||||||
|
List<String> list = source.getStrings();
|
||||||
|
if ( list != null ) {
|
||||||
|
target.getStrings().clear();
|
||||||
|
target.getStrings().addAll( list );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setStrings( null );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
List<String> list = source.getStrings();
|
||||||
|
if ( list != null ) {
|
||||||
|
target.setStrings( new HashSet<String>( list )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getLongsInitialized() != null ) {
|
||||||
|
Set<Long> set_ = stringListToLongSet( source.getStringsInitialized() );
|
||||||
|
if ( set_ != null ) {
|
||||||
|
target.getLongsInitialized().clear();
|
||||||
|
target.getLongsInitialized().addAll( set_ );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setLongsInitialized( null );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Set<Long> set_ = stringListToLongSet( source.getStringsInitialized() );
|
||||||
|
if ( set_ != null ) {
|
||||||
|
target.setLongsInitialized( set_ );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getStringsWithDefault() != null ) {
|
||||||
|
List<String> list_ = source.getStringsWithDefault();
|
||||||
|
if ( list_ != null ) {
|
||||||
|
target.getStringsWithDefault().clear();
|
||||||
|
target.getStringsWithDefault().addAll( list_ );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
List<String> list_ = source.getStringsWithDefault();
|
||||||
|
if ( list_ != null ) {
|
||||||
|
target.setStringsWithDefault( new ArrayList<String>( list_ )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getStringsInitialized() != null ) {
|
||||||
|
List<String> list__ = source.getStringsInitialized();
|
||||||
|
if ( list__ != null ) {
|
||||||
|
target.getStringsInitialized().clear();
|
||||||
|
target.getStringsInitialized().addAll( list__ );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setStringsInitialized( null );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
List<String> list__ = source.getStringsInitialized();
|
||||||
|
if ( list__ != null ) {
|
||||||
|
target.setStringsInitialized( new HashSet<String>( list__ )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Domain updateWithReturn(Dto source, Domain target) {
|
||||||
|
|
||||||
|
if ( source != null ) {
|
||||||
|
if ( target.getLongs() != null ) {
|
||||||
|
Set<Long> set = stringListToLongSet( source.getStrings() );
|
||||||
|
if ( set != null ) {
|
||||||
|
target.getLongs().clear();
|
||||||
|
target.getLongs().addAll( set );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setLongs( null );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Set<Long> set = stringListToLongSet( source.getStrings() );
|
||||||
|
if ( set != null ) {
|
||||||
|
target.setLongs( set );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getStrings() != null ) {
|
||||||
|
List<String> list = source.getStrings();
|
||||||
|
if ( list != null ) {
|
||||||
|
target.getStrings().clear();
|
||||||
|
target.getStrings().addAll( list );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setStrings( null );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
List<String> list = source.getStrings();
|
||||||
|
if ( list != null ) {
|
||||||
|
target.setStrings( new HashSet<String>( list )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getLongsInitialized() != null ) {
|
||||||
|
Set<Long> set_ = stringListToLongSet( source.getStringsInitialized() );
|
||||||
|
if ( set_ != null ) {
|
||||||
|
target.getLongsInitialized().clear();
|
||||||
|
target.getLongsInitialized().addAll( set_ );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setLongsInitialized( null );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Set<Long> set_ = stringListToLongSet( source.getStringsInitialized() );
|
||||||
|
if ( set_ != null ) {
|
||||||
|
target.setLongsInitialized( set_ );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getStringsWithDefault() != null ) {
|
||||||
|
List<String> list_ = source.getStringsWithDefault();
|
||||||
|
if ( list_ != null ) {
|
||||||
|
target.getStringsWithDefault().clear();
|
||||||
|
target.getStringsWithDefault().addAll( list_ );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
List<String> list_ = source.getStringsWithDefault();
|
||||||
|
if ( list_ != null ) {
|
||||||
|
target.setStringsWithDefault( new ArrayList<String>( list_ )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getStringsInitialized() != null ) {
|
||||||
|
List<String> list__ = source.getStringsInitialized();
|
||||||
|
if ( list__ != null ) {
|
||||||
|
target.getStringsInitialized().clear();
|
||||||
|
target.getStringsInitialized().addAll( list__ );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setStringsInitialized( null );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
List<String> list__ = source.getStringsInitialized();
|
||||||
|
if ( list__ != null ) {
|
||||||
|
target.setStringsInitialized( new HashSet<String>( list__ )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Set<Long> stringListToLongSet(List<String> list) {
|
||||||
|
if ( list == null ) {
|
||||||
|
return new HashSet<Long>();
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<Long> set = new HashSet<Long>();
|
||||||
|
for ( String string : list ) {
|
||||||
|
set.add( Long.parseLong( string ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,276 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/)
|
||||||
|
* and/or other contributors as indicated by the @authors tag. See the
|
||||||
|
* copyright.txt file in the distribution for a full listing of all
|
||||||
|
* contributors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.mapstruct.ap.test.bugs._913;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
|
||||||
|
@Generated(
|
||||||
|
value = "org.mapstruct.ap.MappingProcessor",
|
||||||
|
date = "2016-12-30T19:07:28+0100",
|
||||||
|
comments = "version: , compiler: javac, environment: Java 1.8.0_112 (Oracle Corporation)"
|
||||||
|
)
|
||||||
|
public class DomainDtoWithNvmsNullMapperImpl implements DomainDtoWithNvmsNullMapper {
|
||||||
|
|
||||||
|
private final Helper helper = new Helper();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Domain create(Dto source) {
|
||||||
|
if ( source == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Domain domain = new Domain();
|
||||||
|
|
||||||
|
Set<Long> set = stringListToLongSet( source.getStringsInitialized() );
|
||||||
|
if ( set != null ) {
|
||||||
|
domain.setLongsInitialized( set );
|
||||||
|
}
|
||||||
|
Set<Long> set_ = stringListToLongSet( source.getStrings() );
|
||||||
|
if ( set_ != null ) {
|
||||||
|
domain.setLongs( set_ );
|
||||||
|
}
|
||||||
|
List<String> list = source.getStrings();
|
||||||
|
if ( list != null ) {
|
||||||
|
domain.setStrings( new HashSet<String>( list )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
List<String> list_ = source.getStringsWithDefault();
|
||||||
|
if ( list_ != null ) {
|
||||||
|
domain.setStringsWithDefault( new ArrayList<String>( list_ )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
domain.setStringsWithDefault( helper.toList( "3" ) );
|
||||||
|
}
|
||||||
|
List<String> list__ = source.getStringsInitialized();
|
||||||
|
if ( list__ != null ) {
|
||||||
|
domain.setStringsInitialized( new HashSet<String>( list__ )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Dto source, Domain target) {
|
||||||
|
if ( source == null ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( target.getLongs() != null ) {
|
||||||
|
Set<Long> set = stringListToLongSet( source.getStrings() );
|
||||||
|
if ( set != null ) {
|
||||||
|
target.getLongs().clear();
|
||||||
|
target.getLongs().addAll( set );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setLongs( null );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Set<Long> set = stringListToLongSet( source.getStrings() );
|
||||||
|
if ( set != null ) {
|
||||||
|
target.setLongs( set );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getStrings() != null ) {
|
||||||
|
List<String> list = source.getStrings();
|
||||||
|
if ( list != null ) {
|
||||||
|
target.getStrings().clear();
|
||||||
|
target.getStrings().addAll( list );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setStrings( null );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
List<String> list = source.getStrings();
|
||||||
|
if ( list != null ) {
|
||||||
|
target.setStrings( new HashSet<String>( list )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getLongsInitialized() != null ) {
|
||||||
|
Set<Long> set_ = stringListToLongSet( source.getStringsInitialized() );
|
||||||
|
if ( set_ != null ) {
|
||||||
|
target.getLongsInitialized().clear();
|
||||||
|
target.getLongsInitialized().addAll( set_ );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setLongsInitialized( null );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Set<Long> set_ = stringListToLongSet( source.getStringsInitialized() );
|
||||||
|
if ( set_ != null ) {
|
||||||
|
target.setLongsInitialized( set_ );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getStringsWithDefault() != null ) {
|
||||||
|
List<String> list_ = source.getStringsWithDefault();
|
||||||
|
if ( list_ != null ) {
|
||||||
|
target.getStringsWithDefault().clear();
|
||||||
|
target.getStringsWithDefault().addAll( list_ );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
List<String> list_ = source.getStringsWithDefault();
|
||||||
|
if ( list_ != null ) {
|
||||||
|
target.setStringsWithDefault( new ArrayList<String>( list_ )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getStringsInitialized() != null ) {
|
||||||
|
List<String> list__ = source.getStringsInitialized();
|
||||||
|
if ( list__ != null ) {
|
||||||
|
target.getStringsInitialized().clear();
|
||||||
|
target.getStringsInitialized().addAll( list__ );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setStringsInitialized( null );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
List<String> list__ = source.getStringsInitialized();
|
||||||
|
if ( list__ != null ) {
|
||||||
|
target.setStringsInitialized( new HashSet<String>( list__ )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Domain updateWithReturn(Dto source, Domain target) {
|
||||||
|
if ( source == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( target.getLongs() != null ) {
|
||||||
|
Set<Long> set = stringListToLongSet( source.getStrings() );
|
||||||
|
if ( set != null ) {
|
||||||
|
target.getLongs().clear();
|
||||||
|
target.getLongs().addAll( set );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setLongs( null );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Set<Long> set = stringListToLongSet( source.getStrings() );
|
||||||
|
if ( set != null ) {
|
||||||
|
target.setLongs( set );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getStrings() != null ) {
|
||||||
|
List<String> list = source.getStrings();
|
||||||
|
if ( list != null ) {
|
||||||
|
target.getStrings().clear();
|
||||||
|
target.getStrings().addAll( list );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setStrings( null );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
List<String> list = source.getStrings();
|
||||||
|
if ( list != null ) {
|
||||||
|
target.setStrings( new HashSet<String>( list )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getLongsInitialized() != null ) {
|
||||||
|
Set<Long> set_ = stringListToLongSet( source.getStringsInitialized() );
|
||||||
|
if ( set_ != null ) {
|
||||||
|
target.getLongsInitialized().clear();
|
||||||
|
target.getLongsInitialized().addAll( set_ );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setLongsInitialized( null );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Set<Long> set_ = stringListToLongSet( source.getStringsInitialized() );
|
||||||
|
if ( set_ != null ) {
|
||||||
|
target.setLongsInitialized( set_ );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getStringsWithDefault() != null ) {
|
||||||
|
List<String> list_ = source.getStringsWithDefault();
|
||||||
|
if ( list_ != null ) {
|
||||||
|
target.getStringsWithDefault().clear();
|
||||||
|
target.getStringsWithDefault().addAll( list_ );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
List<String> list_ = source.getStringsWithDefault();
|
||||||
|
if ( list_ != null ) {
|
||||||
|
target.setStringsWithDefault( new ArrayList<String>( list_ )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getStringsInitialized() != null ) {
|
||||||
|
List<String> list__ = source.getStringsInitialized();
|
||||||
|
if ( list__ != null ) {
|
||||||
|
target.getStringsInitialized().clear();
|
||||||
|
target.getStringsInitialized().addAll( list__ );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setStringsInitialized( null );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
List<String> list__ = source.getStringsInitialized();
|
||||||
|
if ( list__ != null ) {
|
||||||
|
target.setStringsInitialized( new HashSet<String>( list__ )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Set<Long> stringListToLongSet(List<String> list) {
|
||||||
|
if ( list == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<Long> set = new HashSet<Long>();
|
||||||
|
for ( String string : list ) {
|
||||||
|
set.add( Long.parseLong( string ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,252 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/)
|
||||||
|
* and/or other contributors as indicated by the @authors tag. See the
|
||||||
|
* copyright.txt file in the distribution for a full listing of all
|
||||||
|
* contributors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.mapstruct.ap.test.bugs._913;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
|
||||||
|
@Generated(
|
||||||
|
value = "org.mapstruct.ap.MappingProcessor",
|
||||||
|
date = "2016-12-30T19:07:28+0100",
|
||||||
|
comments = "version: , compiler: javac, environment: Java 1.8.0_112 (Oracle Corporation)"
|
||||||
|
)
|
||||||
|
public class DomainDtoWithPresenceCheckMapperImpl implements DomainDtoWithPresenceCheckMapper {
|
||||||
|
|
||||||
|
private final Helper helper = new Helper();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Domain create(DtoWithPresenceCheck source) {
|
||||||
|
if ( source == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Domain domain = new Domain();
|
||||||
|
|
||||||
|
if ( source.hasStringsInitialized() ) {
|
||||||
|
Set<Long> set = stringListToLongSet( source.getStringsInitialized() );
|
||||||
|
domain.setLongsInitialized( set );
|
||||||
|
}
|
||||||
|
if ( source.hasStrings() ) {
|
||||||
|
Set<Long> set_ = stringListToLongSet( source.getStrings() );
|
||||||
|
domain.setLongs( set_ );
|
||||||
|
}
|
||||||
|
if ( source.hasStrings() ) {
|
||||||
|
List<String> list = source.getStrings();
|
||||||
|
domain.setStrings( new HashSet<String>( list )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if ( source.hasStringsWithDefault() ) {
|
||||||
|
List<String> list_ = source.getStringsWithDefault();
|
||||||
|
domain.setStringsWithDefault( new ArrayList<String>( list_ )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
domain.setStringsWithDefault( helper.toList( "3" ) );
|
||||||
|
}
|
||||||
|
if ( source.hasStringsInitialized() ) {
|
||||||
|
List<String> list__ = source.getStringsInitialized();
|
||||||
|
domain.setStringsInitialized( new HashSet<String>( list__ )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(DtoWithPresenceCheck source, Domain target) {
|
||||||
|
if ( source == null ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( target.getLongs() != null ) {
|
||||||
|
if ( source.hasStrings() ) {
|
||||||
|
Set<Long> set = stringListToLongSet( source.getStrings() );
|
||||||
|
target.getLongs().clear();
|
||||||
|
target.getLongs().addAll( set );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ( source.hasStrings() ) {
|
||||||
|
Set<Long> set = stringListToLongSet( source.getStrings() );
|
||||||
|
target.setLongs( set );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getStrings() != null ) {
|
||||||
|
if ( source.hasStrings() ) {
|
||||||
|
List<String> list = source.getStrings();
|
||||||
|
target.getStrings().clear();
|
||||||
|
target.getStrings().addAll( list );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ( source.hasStrings() ) {
|
||||||
|
List<String> list = source.getStrings();
|
||||||
|
target.setStrings( new HashSet<String>( list )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getLongsInitialized() != null ) {
|
||||||
|
if ( source.hasStringsInitialized() ) {
|
||||||
|
Set<Long> set_ = stringListToLongSet( source.getStringsInitialized() );
|
||||||
|
target.getLongsInitialized().clear();
|
||||||
|
target.getLongsInitialized().addAll( set_ );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ( source.hasStringsInitialized() ) {
|
||||||
|
Set<Long> set_ = stringListToLongSet( source.getStringsInitialized() );
|
||||||
|
target.setLongsInitialized( set_ );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getStringsWithDefault() != null ) {
|
||||||
|
if ( source.hasStringsWithDefault() ) {
|
||||||
|
List<String> list_ = source.getStringsWithDefault();
|
||||||
|
target.getStringsWithDefault().clear();
|
||||||
|
target.getStringsWithDefault().addAll( list_ );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ( source.hasStringsWithDefault() ) {
|
||||||
|
List<String> list_ = source.getStringsWithDefault();
|
||||||
|
target.setStringsWithDefault( new ArrayList<String>( list_ )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getStringsInitialized() != null ) {
|
||||||
|
if ( source.hasStringsInitialized() ) {
|
||||||
|
List<String> list__ = source.getStringsInitialized();
|
||||||
|
target.getStringsInitialized().clear();
|
||||||
|
target.getStringsInitialized().addAll( list__ );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ( source.hasStringsInitialized() ) {
|
||||||
|
List<String> list__ = source.getStringsInitialized();
|
||||||
|
target.setStringsInitialized( new HashSet<String>( list__ )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Domain updateWithReturn(DtoWithPresenceCheck source, Domain target) {
|
||||||
|
if ( source == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( target.getLongs() != null ) {
|
||||||
|
if ( source.hasStrings() ) {
|
||||||
|
Set<Long> set = stringListToLongSet( source.getStrings() );
|
||||||
|
target.getLongs().clear();
|
||||||
|
target.getLongs().addAll( set );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ( source.hasStrings() ) {
|
||||||
|
Set<Long> set = stringListToLongSet( source.getStrings() );
|
||||||
|
target.setLongs( set );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getStrings() != null ) {
|
||||||
|
if ( source.hasStrings() ) {
|
||||||
|
List<String> list = source.getStrings();
|
||||||
|
target.getStrings().clear();
|
||||||
|
target.getStrings().addAll( list );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ( source.hasStrings() ) {
|
||||||
|
List<String> list = source.getStrings();
|
||||||
|
target.setStrings( new HashSet<String>( list )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getLongsInitialized() != null ) {
|
||||||
|
if ( source.hasStringsInitialized() ) {
|
||||||
|
Set<Long> set_ = stringListToLongSet( source.getStringsInitialized() );
|
||||||
|
target.getLongsInitialized().clear();
|
||||||
|
target.getLongsInitialized().addAll( set_ );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ( source.hasStringsInitialized() ) {
|
||||||
|
Set<Long> set_ = stringListToLongSet( source.getStringsInitialized() );
|
||||||
|
target.setLongsInitialized( set_ );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getStringsWithDefault() != null ) {
|
||||||
|
if ( source.hasStringsWithDefault() ) {
|
||||||
|
List<String> list_ = source.getStringsWithDefault();
|
||||||
|
target.getStringsWithDefault().clear();
|
||||||
|
target.getStringsWithDefault().addAll( list_ );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ( source.hasStringsWithDefault() ) {
|
||||||
|
List<String> list_ = source.getStringsWithDefault();
|
||||||
|
target.setStringsWithDefault( new ArrayList<String>( list_ )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( target.getStringsInitialized() != null ) {
|
||||||
|
if ( source.hasStringsInitialized() ) {
|
||||||
|
List<String> list__ = source.getStringsInitialized();
|
||||||
|
target.getStringsInitialized().clear();
|
||||||
|
target.getStringsInitialized().addAll( list__ );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ( source.hasStringsInitialized() ) {
|
||||||
|
List<String> list__ = source.getStringsInitialized();
|
||||||
|
target.setStringsInitialized( new HashSet<String>( list__ )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Set<Long> stringListToLongSet(List<String> list) {
|
||||||
|
if ( list == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<Long> set = new HashSet<Long>();
|
||||||
|
for ( String string : list ) {
|
||||||
|
set.add( Long.parseLong( string ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/)
|
||||||
|
* and/or other contributors as indicated by the @authors tag. See the
|
||||||
|
* copyright.txt file in the distribution for a full listing of all
|
||||||
|
* contributors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.mapstruct.ap.test.collection.adder;
|
||||||
|
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
import org.mapstruct.ap.test.collection.adder._target.Target2;
|
||||||
|
import org.mapstruct.ap.test.collection.adder.source.Foo;
|
||||||
|
import org.mapstruct.ap.test.collection.adder.source.Source2;
|
||||||
|
|
||||||
|
@Generated(
|
||||||
|
value = "org.mapstruct.ap.MappingProcessor",
|
||||||
|
date = "2016-12-30T19:10:39+0100",
|
||||||
|
comments = "version: , compiler: javac, environment: Java 1.8.0_112 (Oracle Corporation)"
|
||||||
|
)
|
||||||
|
public class Source2Target2MapperImpl extends Source2Target2Mapper {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Target2 toTarget(Source2 source) {
|
||||||
|
if ( source == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Target2 target2 = new Target2();
|
||||||
|
|
||||||
|
if ( source.getAttributes() != null ) {
|
||||||
|
for ( Foo attribute : source.getAttributes() ) {
|
||||||
|
target2.addAttribute( attribute );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return target2;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,213 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/)
|
||||||
|
* and/or other contributors as indicated by the @authors tag. See the
|
||||||
|
* copyright.txt file in the distribution for a full listing of all
|
||||||
|
* contributors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.mapstruct.ap.test.collection.adder;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
import org.mapstruct.ap.test.collection.adder._target.IndoorPet;
|
||||||
|
import org.mapstruct.ap.test.collection.adder._target.Target;
|
||||||
|
import org.mapstruct.ap.test.collection.adder._target.TargetDali;
|
||||||
|
import org.mapstruct.ap.test.collection.adder._target.TargetHuman;
|
||||||
|
import org.mapstruct.ap.test.collection.adder._target.TargetOnlyGetter;
|
||||||
|
import org.mapstruct.ap.test.collection.adder._target.TargetViaTargetType;
|
||||||
|
import org.mapstruct.ap.test.collection.adder.source.SingleElementSource;
|
||||||
|
import org.mapstruct.ap.test.collection.adder.source.Source;
|
||||||
|
import org.mapstruct.ap.test.collection.adder.source.SourceTeeth;
|
||||||
|
|
||||||
|
@Generated(
|
||||||
|
value = "org.mapstruct.ap.MappingProcessor",
|
||||||
|
date = "2016-12-30T19:10:39+0100",
|
||||||
|
comments = "version: , compiler: javac, environment: Java 1.8.0_112 (Oracle Corporation)"
|
||||||
|
)
|
||||||
|
public class SourceTargetMapperImpl implements SourceTargetMapper {
|
||||||
|
|
||||||
|
private final PetMapper petMapper = new PetMapper();
|
||||||
|
private final TeethMapper teethMapper = new TeethMapper();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Target toTarget(Source source) throws DogException {
|
||||||
|
if ( source == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Target target = new Target();
|
||||||
|
|
||||||
|
if ( source.getPets() != null ) {
|
||||||
|
try {
|
||||||
|
for ( String pet : source.getPets() ) {
|
||||||
|
target.addPet( petMapper.toPet( pet ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch ( CatException e ) {
|
||||||
|
throw new RuntimeException( e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Source toSource(Target source) {
|
||||||
|
if ( source == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Source source_ = new Source();
|
||||||
|
|
||||||
|
try {
|
||||||
|
List<String> list = petMapper.toSourcePets( source.getPets() );
|
||||||
|
if ( list != null ) {
|
||||||
|
source_.setPets( list );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch ( CatException e ) {
|
||||||
|
throw new RuntimeException( e );
|
||||||
|
}
|
||||||
|
catch ( DogException e ) {
|
||||||
|
throw new RuntimeException( e );
|
||||||
|
}
|
||||||
|
|
||||||
|
return source_;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toExistingTarget(Source source, Target target) {
|
||||||
|
if ( source == null ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( source.getPets() != null ) {
|
||||||
|
try {
|
||||||
|
for ( String pet : source.getPets() ) {
|
||||||
|
target.addPet( petMapper.toPet( pet ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch ( CatException e ) {
|
||||||
|
throw new RuntimeException( e );
|
||||||
|
}
|
||||||
|
catch ( DogException e ) {
|
||||||
|
throw new RuntimeException( e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TargetDali toTargetDali(SourceTeeth source) {
|
||||||
|
if ( source == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
TargetDali targetDali = new TargetDali();
|
||||||
|
|
||||||
|
if ( source.getTeeth() != null ) {
|
||||||
|
for ( String teeth : source.getTeeth() ) {
|
||||||
|
targetDali.addTeeth( teethMapper.toTooth( teeth ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return targetDali;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TargetHuman toTargetHuman(SourceTeeth source) {
|
||||||
|
if ( source == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
TargetHuman targetHuman = new TargetHuman();
|
||||||
|
|
||||||
|
if ( source.getTeeth() != null ) {
|
||||||
|
for ( String tooth : source.getTeeth() ) {
|
||||||
|
targetHuman.addTooth( teethMapper.toTooth( tooth ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return targetHuman;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TargetOnlyGetter toTargetOnlyGetter(Source source) throws DogException {
|
||||||
|
if ( source == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
TargetOnlyGetter targetOnlyGetter = new TargetOnlyGetter();
|
||||||
|
|
||||||
|
if ( source.getPets() != null ) {
|
||||||
|
try {
|
||||||
|
for ( String pet : source.getPets() ) {
|
||||||
|
targetOnlyGetter.addPet( petMapper.toPet( pet ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch ( CatException e ) {
|
||||||
|
throw new RuntimeException( e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return targetOnlyGetter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TargetViaTargetType toTargetViaTargetType(Source source) {
|
||||||
|
if ( source == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
TargetViaTargetType targetViaTargetType = new TargetViaTargetType();
|
||||||
|
|
||||||
|
if ( source.getPets() != null ) {
|
||||||
|
try {
|
||||||
|
for ( String pet : source.getPets() ) {
|
||||||
|
targetViaTargetType.addPet( petMapper.toPet( pet, IndoorPet.class ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch ( CatException e ) {
|
||||||
|
throw new RuntimeException( e );
|
||||||
|
}
|
||||||
|
catch ( DogException e ) {
|
||||||
|
throw new RuntimeException( e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return targetViaTargetType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Target fromSingleElementSource(SingleElementSource source) {
|
||||||
|
if ( source == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Target target = new Target();
|
||||||
|
|
||||||
|
if ( source.getPet() != null ) {
|
||||||
|
try {
|
||||||
|
target.addPet( petMapper.toPet( source.getPet() ) );
|
||||||
|
}
|
||||||
|
catch ( CatException e ) {
|
||||||
|
throw new RuntimeException( e );
|
||||||
|
}
|
||||||
|
catch ( DogException e ) {
|
||||||
|
throw new RuntimeException( e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/)
|
||||||
|
* and/or other contributors as indicated by the @authors tag. See the
|
||||||
|
* copyright.txt file in the distribution for a full listing of all
|
||||||
|
* contributors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.mapstruct.ap.test.collection.adder;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
import org.mapstruct.ap.test.collection.adder._target.Target;
|
||||||
|
import org.mapstruct.ap.test.collection.adder.source.Source;
|
||||||
|
|
||||||
|
@Generated(
|
||||||
|
value = "org.mapstruct.ap.MappingProcessor",
|
||||||
|
date = "2016-12-30T19:10:39+0100",
|
||||||
|
comments = "version: , compiler: javac, environment: Java 1.8.0_112 (Oracle Corporation)"
|
||||||
|
)
|
||||||
|
public class SourceTargetMapperStrategyDefaultImpl implements SourceTargetMapperStrategyDefault {
|
||||||
|
|
||||||
|
private final PetMapper petMapper = new PetMapper();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Target shouldFallBackToAdder(Source source) throws DogException {
|
||||||
|
if ( source == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Target target = new Target();
|
||||||
|
|
||||||
|
try {
|
||||||
|
List<Long> list = petMapper.toPets( source.getPets() );
|
||||||
|
if ( list != null ) {
|
||||||
|
target.setPets( list );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch ( CatException e ) {
|
||||||
|
throw new RuntimeException( e );
|
||||||
|
}
|
||||||
|
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/)
|
||||||
|
* and/or other contributors as indicated by the @authors tag. See the
|
||||||
|
* copyright.txt file in the distribution for a full listing of all
|
||||||
|
* contributors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.mapstruct.ap.test.collection.adder;
|
||||||
|
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
import org.mapstruct.ap.test.collection.adder._target.TargetWithoutSetter;
|
||||||
|
import org.mapstruct.ap.test.collection.adder.source.Source;
|
||||||
|
|
||||||
|
@Generated(
|
||||||
|
value = "org.mapstruct.ap.MappingProcessor",
|
||||||
|
date = "2016-12-30T19:10:39+0100",
|
||||||
|
comments = "version: , compiler: javac, environment: Java 1.8.0_112 (Oracle Corporation)"
|
||||||
|
)
|
||||||
|
public class SourceTargetMapperStrategySetterPreferredImpl implements SourceTargetMapperStrategySetterPreferred {
|
||||||
|
|
||||||
|
private final PetMapper petMapper = new PetMapper();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TargetWithoutSetter toTargetDontUseAdder(Source source) throws DogException {
|
||||||
|
if ( source == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
TargetWithoutSetter targetWithoutSetter = new TargetWithoutSetter();
|
||||||
|
|
||||||
|
if ( source.getPets() != null ) {
|
||||||
|
try {
|
||||||
|
for ( String pet : source.getPets() ) {
|
||||||
|
targetWithoutSetter.addPet( petMapper.toPet( pet ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch ( CatException e ) {
|
||||||
|
throw new RuntimeException( e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return targetWithoutSetter;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,134 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/)
|
||||||
|
* and/or other contributors as indicated by the @authors tag. See the
|
||||||
|
* copyright.txt file in the distribution for a full listing of all
|
||||||
|
* contributors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.mapstruct.ap.test.conversion.string;
|
||||||
|
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
|
||||||
|
@Generated(
|
||||||
|
value = "org.mapstruct.ap.MappingProcessor",
|
||||||
|
date = "2016-12-30T19:22:52+0100",
|
||||||
|
comments = "version: , compiler: javac, environment: Java 1.8.0_112 (Oracle Corporation)"
|
||||||
|
)
|
||||||
|
public class SourceTargetMapperImpl implements SourceTargetMapper {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Target sourceToTarget(Source source) {
|
||||||
|
if ( source == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Target target = new Target();
|
||||||
|
|
||||||
|
target.setB( String.valueOf( source.getB() ) );
|
||||||
|
if ( source.getBb() != null ) {
|
||||||
|
target.setBb( String.valueOf( source.getBb() ) );
|
||||||
|
}
|
||||||
|
target.setS( String.valueOf( source.getS() ) );
|
||||||
|
if ( source.getSs() != null ) {
|
||||||
|
target.setSs( String.valueOf( source.getSs() ) );
|
||||||
|
}
|
||||||
|
target.setI( String.valueOf( source.getI() ) );
|
||||||
|
if ( source.getIi() != null ) {
|
||||||
|
target.setIi( String.valueOf( source.getIi() ) );
|
||||||
|
}
|
||||||
|
target.setL( String.valueOf( source.getL() ) );
|
||||||
|
if ( source.getLl() != null ) {
|
||||||
|
target.setLl( String.valueOf( source.getLl() ) );
|
||||||
|
}
|
||||||
|
target.setF( String.valueOf( source.getF() ) );
|
||||||
|
if ( source.getFf() != null ) {
|
||||||
|
target.setFf( String.valueOf( source.getFf() ) );
|
||||||
|
}
|
||||||
|
target.setD( String.valueOf( source.getD() ) );
|
||||||
|
if ( source.getDd() != null ) {
|
||||||
|
target.setDd( String.valueOf( source.getDd() ) );
|
||||||
|
}
|
||||||
|
target.setBool( String.valueOf( source.getBool() ) );
|
||||||
|
if ( source.getBoolBool() != null ) {
|
||||||
|
target.setBoolBool( String.valueOf( source.getBoolBool() ) );
|
||||||
|
}
|
||||||
|
target.setC( String.valueOf( source.getC() ) );
|
||||||
|
if ( source.getCc() != null ) {
|
||||||
|
target.setCc( source.getCc().toString() );
|
||||||
|
}
|
||||||
|
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Source targetToSource(Target target) {
|
||||||
|
if ( target == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Source source = new Source();
|
||||||
|
|
||||||
|
if ( target.getB() != null ) {
|
||||||
|
source.setB( Byte.parseByte( target.getB() ) );
|
||||||
|
}
|
||||||
|
if ( target.getBb() != null ) {
|
||||||
|
source.setBb( Byte.parseByte( target.getBb() ) );
|
||||||
|
}
|
||||||
|
if ( target.getS() != null ) {
|
||||||
|
source.setS( Short.parseShort( target.getS() ) );
|
||||||
|
}
|
||||||
|
if ( target.getSs() != null ) {
|
||||||
|
source.setSs( Short.parseShort( target.getSs() ) );
|
||||||
|
}
|
||||||
|
if ( target.getI() != null ) {
|
||||||
|
source.setI( Integer.parseInt( target.getI() ) );
|
||||||
|
}
|
||||||
|
if ( target.getIi() != null ) {
|
||||||
|
source.setIi( Integer.parseInt( target.getIi() ) );
|
||||||
|
}
|
||||||
|
if ( target.getL() != null ) {
|
||||||
|
source.setL( Long.parseLong( target.getL() ) );
|
||||||
|
}
|
||||||
|
if ( target.getLl() != null ) {
|
||||||
|
source.setLl( Long.parseLong( target.getLl() ) );
|
||||||
|
}
|
||||||
|
if ( target.getF() != null ) {
|
||||||
|
source.setF( Float.parseFloat( target.getF() ) );
|
||||||
|
}
|
||||||
|
if ( target.getFf() != null ) {
|
||||||
|
source.setFf( Float.parseFloat( target.getFf() ) );
|
||||||
|
}
|
||||||
|
if ( target.getD() != null ) {
|
||||||
|
source.setD( Double.parseDouble( target.getD() ) );
|
||||||
|
}
|
||||||
|
if ( target.getDd() != null ) {
|
||||||
|
source.setDd( Double.parseDouble( target.getDd() ) );
|
||||||
|
}
|
||||||
|
if ( target.getBool() != null ) {
|
||||||
|
source.setBool( Boolean.parseBoolean( target.getBool() ) );
|
||||||
|
}
|
||||||
|
if ( target.getBoolBool() != null ) {
|
||||||
|
source.setBoolBool( Boolean.parseBoolean( target.getBoolBool() ) );
|
||||||
|
}
|
||||||
|
if ( target.getC() != null ) {
|
||||||
|
source.setC( target.getC().charAt( 0 ) );
|
||||||
|
}
|
||||||
|
if ( target.getCc() != null ) {
|
||||||
|
source.setCc( target.getCc().charAt( 0 ) );
|
||||||
|
}
|
||||||
|
source.setObject( target.getObject() );
|
||||||
|
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/)
|
||||||
|
* and/or other contributors as indicated by the @authors tag. See the
|
||||||
|
* copyright.txt file in the distribution for a full listing of all
|
||||||
|
* contributors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.mapstruct.ap.test.updatemethods;
|
||||||
|
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
|
||||||
|
@Generated(
|
||||||
|
value = "org.mapstruct.ap.MappingProcessor",
|
||||||
|
date = "2016-12-30T19:11:46+0100",
|
||||||
|
comments = "version: , compiler: javac, environment: Java 1.8.0_112 (Oracle Corporation)"
|
||||||
|
)
|
||||||
|
public class CompanyMapperImpl implements CompanyMapper {
|
||||||
|
|
||||||
|
private final DepartmentEntityFactory departmentEntityFactory = new DepartmentEntityFactory();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toCompanyEntity(CompanyDto dto, CompanyEntity entity) {
|
||||||
|
if ( dto == null ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
entity.setName( dto.getName() );
|
||||||
|
if ( dto.getDepartment() != null ) {
|
||||||
|
if ( entity.getDepartment() == null ) {
|
||||||
|
entity.setDepartment( departmentEntityFactory.createDepartmentEntity() );
|
||||||
|
}
|
||||||
|
toDepartmentEntity( toInBetween( dto.getDepartment() ), entity.getDepartment() );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
entity.setDepartment( null );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DepartmentInBetween toInBetween(DepartmentDto dto) {
|
||||||
|
if ( dto == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
DepartmentInBetween departmentInBetween_ = new DepartmentInBetween();
|
||||||
|
|
||||||
|
departmentInBetween_.setName( dto.getName() );
|
||||||
|
|
||||||
|
return departmentInBetween_;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toDepartmentEntity(DepartmentInBetween dto, DepartmentEntity entity) {
|
||||||
|
if ( dto == null ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
entity.setName( dto.getName() );
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,98 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/)
|
||||||
|
* and/or other contributors as indicated by the @authors tag. See the
|
||||||
|
* copyright.txt file in the distribution for a full listing of all
|
||||||
|
* contributors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.mapstruct.ap.test.updatemethods;
|
||||||
|
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
|
||||||
|
@Generated(
|
||||||
|
value = "org.mapstruct.ap.MappingProcessor",
|
||||||
|
date = "2016-12-30T19:11:45+0100",
|
||||||
|
comments = "version: , compiler: javac, environment: Java 1.8.0_112 (Oracle Corporation)"
|
||||||
|
)
|
||||||
|
public class OrganizationMapperImpl implements OrganizationMapper {
|
||||||
|
|
||||||
|
private final DepartmentEntityFactory departmentEntityFactory = new DepartmentEntityFactory();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toOrganizationEntity(OrganizationDto dto, OrganizationEntity entity) {
|
||||||
|
if ( dto == null ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( dto.getCompany() != null ) {
|
||||||
|
if ( entity.getCompany() == null ) {
|
||||||
|
entity.setCompany( new CompanyEntity() );
|
||||||
|
}
|
||||||
|
toCompanyEntity( dto.getCompany(), entity.getCompany() );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
entity.setCompany( null );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( entity.getType() == null ) {
|
||||||
|
entity.setType( new OrganizationTypeEntity() );
|
||||||
|
}
|
||||||
|
toName( "commercial", entity.getType() );
|
||||||
|
if ( entity.getTypeNr() == null ) {
|
||||||
|
entity.setTypeNr( new OrganizationTypeNrEntity() );
|
||||||
|
}
|
||||||
|
toNumber( Integer.parseInt( "5" ), entity.getTypeNr() );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toCompanyEntity(CompanyDto dto, CompanyEntity entity) {
|
||||||
|
if ( dto == null ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
entity.setName( dto.getName() );
|
||||||
|
entity.setDepartment( toDepartmentEntity( dto.getDepartment() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DepartmentEntity toDepartmentEntity(DepartmentDto dto) {
|
||||||
|
if ( dto == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
DepartmentEntity departmentEntity_ = departmentEntityFactory.createDepartmentEntity();
|
||||||
|
|
||||||
|
departmentEntity_.setName( dto.getName() );
|
||||||
|
|
||||||
|
return departmentEntity_;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toName(String type, OrganizationTypeEntity entity) {
|
||||||
|
if ( type == null ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
entity.setType( type );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toNumber(Integer number, OrganizationTypeNrEntity entity) {
|
||||||
|
if ( number == null ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
entity.setNumber( number );
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/)
|
||||||
|
* and/or other contributors as indicated by the @authors tag. See the
|
||||||
|
* copyright.txt file in the distribution for a full listing of all
|
||||||
|
* contributors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.mapstruct.ap.test.updatemethods.selection;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
import org.mapstruct.ap.test.updatemethods.DepartmentDto;
|
||||||
|
import org.mapstruct.ap.test.updatemethods.DepartmentEntity;
|
||||||
|
import org.mapstruct.ap.test.updatemethods.EmployeeDto;
|
||||||
|
import org.mapstruct.ap.test.updatemethods.EmployeeEntity;
|
||||||
|
import org.mapstruct.ap.test.updatemethods.SecretaryDto;
|
||||||
|
import org.mapstruct.ap.test.updatemethods.SecretaryEntity;
|
||||||
|
|
||||||
|
@Generated(
|
||||||
|
value = "org.mapstruct.ap.MappingProcessor",
|
||||||
|
date = "2016-12-30T19:17:50+0100",
|
||||||
|
comments = "version: , compiler: javac, environment: Java 1.8.0_112 (Oracle Corporation)"
|
||||||
|
)
|
||||||
|
public class DepartmentMapperImpl implements DepartmentMapper {
|
||||||
|
|
||||||
|
private final ExternalHandWrittenMapper externalHandWrittenMapper = new ExternalHandWrittenMapper();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toDepartmentEntity(DepartmentDto dto, DepartmentEntity entity) {
|
||||||
|
if ( dto == null ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
entity.setName( dto.getName() );
|
||||||
|
if ( entity.getEmployees() == null ) {
|
||||||
|
entity.setEmployees( new ArrayList<EmployeeEntity>() );
|
||||||
|
}
|
||||||
|
externalHandWrittenMapper.toEmployeeEntityList( dto.getEmployees(), entity.getEmployees() );
|
||||||
|
if ( entity.getSecretaryToEmployee() == null ) {
|
||||||
|
entity.setSecretaryToEmployee( new HashMap<SecretaryEntity, EmployeeEntity>() );
|
||||||
|
}
|
||||||
|
externalHandWrittenMapper.toSecretaryEmployeeEntityMap( dto.getSecretaryToEmployee(), entity.getSecretaryToEmployee() );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EmployeeEntity toEmployeeEntity(EmployeeDto dto) {
|
||||||
|
if ( dto == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
EmployeeEntity employeeEntity = new EmployeeEntity();
|
||||||
|
|
||||||
|
employeeEntity.setName( dto.getName() );
|
||||||
|
|
||||||
|
return employeeEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SecretaryEntity toSecretaryEntity(SecretaryDto dto) {
|
||||||
|
if ( dto == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
SecretaryEntity secretaryEntity = new SecretaryEntity();
|
||||||
|
|
||||||
|
secretaryEntity.setName( dto.getName() );
|
||||||
|
|
||||||
|
return secretaryEntity;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/)
|
||||||
|
* and/or other contributors as indicated by the @authors tag. See the
|
||||||
|
* copyright.txt file in the distribution for a full listing of all
|
||||||
|
* contributors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.mapstruct.ap.test.updatemethods.selection;
|
||||||
|
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
import org.mapstruct.ap.test.updatemethods.DepartmentDto;
|
||||||
|
import org.mapstruct.ap.test.updatemethods.DepartmentEntity;
|
||||||
|
|
||||||
|
@Generated(
|
||||||
|
value = "org.mapstruct.ap.MappingProcessor",
|
||||||
|
date = "2016-12-30T19:17:50+0100",
|
||||||
|
comments = "version: , compiler: javac, environment: Java 1.8.0_112 (Oracle Corporation)"
|
||||||
|
)
|
||||||
|
public class ExternalMapperImpl implements ExternalMapper {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toDepartmentEntity(DepartmentDto dto, DepartmentEntity entity) {
|
||||||
|
if ( dto == null ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
entity.setName( dto.getName() );
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/)
|
||||||
|
* and/or other contributors as indicated by the @authors tag. See the
|
||||||
|
* copyright.txt file in the distribution for a full listing of all
|
||||||
|
* contributors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.mapstruct.ap.test.updatemethods.selection;
|
||||||
|
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
import org.mapstruct.ap.test.updatemethods.CompanyDto;
|
||||||
|
import org.mapstruct.ap.test.updatemethods.CompanyEntity;
|
||||||
|
import org.mapstruct.ap.test.updatemethods.DepartmentEntityFactory;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
@Generated(
|
||||||
|
value = "org.mapstruct.ap.MappingProcessor",
|
||||||
|
date = "2016-12-30T19:17:50+0100",
|
||||||
|
comments = "version: , compiler: javac, environment: Java 1.8.0_112 (Oracle Corporation)"
|
||||||
|
)
|
||||||
|
public class OrganizationMapper1Impl implements OrganizationMapper1 {
|
||||||
|
|
||||||
|
private final ExternalMapper externalMapper = Mappers.getMapper( ExternalMapper.class );
|
||||||
|
private final DepartmentEntityFactory departmentEntityFactory = new DepartmentEntityFactory();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toCompanyEntity(CompanyDto dto, CompanyEntity entity) {
|
||||||
|
if ( dto == null ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
entity.setName( dto.getName() );
|
||||||
|
if ( dto.getDepartment() != null ) {
|
||||||
|
if ( entity.getDepartment() == null ) {
|
||||||
|
entity.setDepartment( departmentEntityFactory.createDepartmentEntity() );
|
||||||
|
}
|
||||||
|
externalMapper.toDepartmentEntity( dto.getDepartment(), entity.getDepartment() );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
entity.setDepartment( null );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/)
|
||||||
|
* and/or other contributors as indicated by the @authors tag. See the
|
||||||
|
* copyright.txt file in the distribution for a full listing of all
|
||||||
|
* contributors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.mapstruct.ap.test.updatemethods.selection;
|
||||||
|
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
import org.mapstruct.ap.test.updatemethods.CompanyDto;
|
||||||
|
import org.mapstruct.ap.test.updatemethods.CompanyEntity;
|
||||||
|
import org.mapstruct.ap.test.updatemethods.DepartmentEntityFactory;
|
||||||
|
|
||||||
|
@Generated(
|
||||||
|
value = "org.mapstruct.ap.MappingProcessor",
|
||||||
|
date = "2016-12-30T19:17:47+0100",
|
||||||
|
comments = "version: , compiler: javac, environment: Java 1.8.0_112 (Oracle Corporation)"
|
||||||
|
)
|
||||||
|
public class OrganizationMapper2Impl implements OrganizationMapper2 {
|
||||||
|
|
||||||
|
private final ExternalHandWrittenMapper externalHandWrittenMapper = new ExternalHandWrittenMapper();
|
||||||
|
private final DepartmentEntityFactory departmentEntityFactory = new DepartmentEntityFactory();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toCompanyEntity(CompanyDto dto, CompanyEntity entity) {
|
||||||
|
if ( dto == null ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
entity.setName( dto.getName() );
|
||||||
|
if ( dto.getDepartment() != null ) {
|
||||||
|
if ( entity.getDepartment() == null ) {
|
||||||
|
entity.setDepartment( departmentEntityFactory.createDepartmentEntity() );
|
||||||
|
}
|
||||||
|
externalHandWrittenMapper.toDepartmentEntity( dto.getDepartment(), entity.getDepartment() );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
entity.setDepartment( null );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/)
|
||||||
|
* and/or other contributors as indicated by the @authors tag. See the
|
||||||
|
* copyright.txt file in the distribution for a full listing of all
|
||||||
|
* contributors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.mapstruct.ap.test.updatemethods.selection;
|
||||||
|
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
import org.mapstruct.ap.test.updatemethods.BossDto;
|
||||||
|
import org.mapstruct.ap.test.updatemethods.BossEntity;
|
||||||
|
import org.mapstruct.ap.test.updatemethods.ConstructableDepartmentEntity;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
@Generated(
|
||||||
|
value = "org.mapstruct.ap.MappingProcessor",
|
||||||
|
date = "2016-12-30T19:17:49+0100",
|
||||||
|
comments = "version: , compiler: javac, environment: Java 1.8.0_112 (Oracle Corporation)"
|
||||||
|
)
|
||||||
|
public class OrganizationMapper3Impl implements OrganizationMapper3 {
|
||||||
|
|
||||||
|
private final ExternalMapper externalMapper = Mappers.getMapper( ExternalMapper.class );
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toBossEntity(BossDto dto, BossEntity entity) {
|
||||||
|
if ( dto == null ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
entity.setName( dto.getName() );
|
||||||
|
if ( dto.getDepartment() != null ) {
|
||||||
|
if ( entity.getDepartment() == null ) {
|
||||||
|
entity.setDepartment( new ConstructableDepartmentEntity() );
|
||||||
|
}
|
||||||
|
externalMapper.toDepartmentEntity( dto.getDepartment(), entity.getDepartment() );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
entity.setDepartment( null );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user