mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
Merge branch '1.1-master'
This commit is contained in:
commit
22b28f58db
@ -25,13 +25,6 @@
|
||||
<#elseif wildCardSuperBound>
|
||||
? super <@includeModel object=typeBound />
|
||||
<#else>
|
||||
<#if imported>
|
||||
${name}
|
||||
<#else>
|
||||
${fullyQualifiedName}
|
||||
</#if>
|
||||
</#if>
|
||||
<#if (!ext.raw?? && typeParameters?size > 0) >
|
||||
<<#list typeParameters as typeParameter><@includeModel object=typeParameter /><#if typeParameter_has_next>, </#if></#list>>
|
||||
<#if imported>${name}<#else>${fullyQualifiedName}</#if></#if><#if (!ext.raw?? && typeParameters?size > 0) ><<#list typeParameters as typeParameter><@includeModel object=typeParameter /><#if typeParameter_has_next>, </#if></#list>>
|
||||
</#if>
|
||||
</@compress>
|
@ -18,6 +18,8 @@
|
||||
*/
|
||||
package org.mapstruct.ap.test.array;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@ -31,19 +33,14 @@ import org.mapstruct.ap.testutil.WithClasses;
|
||||
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
||||
import org.mapstruct.ap.testutil.runner.GeneratedSource;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@WithClasses( { Scientist.class, ScientistDto.class, ScienceMapper.class } )
|
||||
@RunWith(AnnotationProcessorTestRunner.class)
|
||||
@IssueKey("108")
|
||||
public class ArrayMappingTest {
|
||||
|
||||
private final GeneratedSource generatedSource = new GeneratedSource();
|
||||
|
||||
@Rule
|
||||
public GeneratedSource getGeneratedSource() {
|
||||
return generatedSource;
|
||||
}
|
||||
public final GeneratedSource generatedSource = new GeneratedSource()
|
||||
.addComparisonToFixtureFor( ScienceMapper.class );
|
||||
|
||||
@Test
|
||||
public void shouldCopyArraysInBean() {
|
||||
@ -238,6 +235,6 @@ public class ArrayMappingTest {
|
||||
@Test
|
||||
@IssueKey( "999" )
|
||||
public void shouldNotContainFQNForStringArray() {
|
||||
getGeneratedSource().forMapper( ScienceMapper.class ).content().doesNotContain( "java.lang.String[]" );
|
||||
generatedSource.forMapper( ScienceMapper.class ).content().doesNotContain( "java.lang.String[]" );
|
||||
}
|
||||
}
|
||||
|
@ -23,11 +23,13 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mapstruct.ap.testutil.IssueKey;
|
||||
import org.mapstruct.ap.testutil.WithClasses;
|
||||
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
||||
import org.mapstruct.ap.testutil.runner.GeneratedSource;
|
||||
|
||||
/**
|
||||
* All these test cases test the possible combinations in the SetterMapperForCollections.
|
||||
@ -49,6 +51,14 @@ import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
||||
@IssueKey( "913" )
|
||||
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
|
||||
* conversion from string to long that return null in the entire mapper, so also for the forged
|
||||
@ -325,8 +335,6 @@ public class Issue913SetterMapperForCollectionsTest {
|
||||
|
||||
/**
|
||||
* These assert check if non-null and default mapping is working as expected.
|
||||
*
|
||||
* @param domain
|
||||
*/
|
||||
private void doControlAsserts( Domain domain ) {
|
||||
assertThat( domain.getStringsInitialized() ).containsOnly( "5" );
|
||||
@ -336,8 +344,6 @@ public class Issue913SetterMapperForCollectionsTest {
|
||||
|
||||
/**
|
||||
* These assert check if non-null and default mapping is working as expected.
|
||||
*
|
||||
* @param domain
|
||||
*/
|
||||
private void doControlAsserts( Domain domain1, Domain domain2) {
|
||||
assertThat( domain1 ).isEqualTo( domain2 );
|
||||
|
@ -25,6 +25,7 @@ import static org.junit.Assert.assertTrue;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mapstruct.ap.test.collection.adder._target.AdderUsageObserver;
|
||||
@ -46,6 +47,7 @@ import org.mapstruct.ap.test.collection.adder.source.SourceTeeth;
|
||||
import org.mapstruct.ap.testutil.IssueKey;
|
||||
import org.mapstruct.ap.testutil.WithClasses;
|
||||
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
||||
import org.mapstruct.ap.testutil.runner.GeneratedSource;
|
||||
|
||||
/**
|
||||
* @author Sjaak Derksen
|
||||
@ -70,11 +72,22 @@ import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
||||
IndoorPet.class,
|
||||
OutdoorPet.class,
|
||||
DogException.class,
|
||||
CatException.class
|
||||
CatException.class,
|
||||
Target2.class,
|
||||
Source2.class,
|
||||
Source2Target2Mapper.class,
|
||||
Foo.class
|
||||
})
|
||||
@RunWith(AnnotationProcessorTestRunner.class)
|
||||
public class AdderTest {
|
||||
|
||||
@Rule
|
||||
public final GeneratedSource generatedSource = new GeneratedSource().addComparisonToFixtureFor(
|
||||
SourceTargetMapper.class,
|
||||
SourceTargetMapperStrategyDefault.class,
|
||||
SourceTargetMapperStrategySetterPreferred.class
|
||||
);
|
||||
|
||||
@IssueKey("241")
|
||||
@Test
|
||||
public void testAdd() throws DogException {
|
||||
@ -245,13 +258,8 @@ public class AdderTest {
|
||||
|
||||
@IssueKey( "310" )
|
||||
@Test
|
||||
@WithClasses( {
|
||||
Target2.class,
|
||||
Source2.class,
|
||||
Source2Target2Mapper.class,
|
||||
Foo.class
|
||||
} )
|
||||
public void testMissingImport() throws DogException {
|
||||
generatedSource.addComparisonToFixtureFor( Source2Target2Mapper.class );
|
||||
|
||||
Source2 source = new Source2();
|
||||
source.setAttributes( Arrays.asList( new Foo() ) );
|
||||
|
@ -18,13 +18,15 @@
|
||||
*/
|
||||
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.runner.RunWith;
|
||||
import org.mapstruct.ap.testutil.IssueKey;
|
||||
import org.mapstruct.ap.testutil.WithClasses;
|
||||
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
||||
import org.mapstruct.ap.testutil.runner.GeneratedSource;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@WithClasses({
|
||||
Source.class,
|
||||
@ -36,6 +38,10 @@ public class StringConversionTest {
|
||||
|
||||
private static final String STRING_CONSTANT = "String constant";
|
||||
|
||||
@Rule
|
||||
public final GeneratedSource generatedSource = new GeneratedSource().addComparisonToFixtureFor(
|
||||
SourceTargetMapper.class );
|
||||
|
||||
@Test
|
||||
public void shouldApplyStringConversions() {
|
||||
Source source = new Source();
|
||||
|
@ -18,8 +18,7 @@
|
||||
*/
|
||||
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.runner.RunWith;
|
||||
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.ExpectedCompilationOutcome;
|
||||
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 {
|
||||
|
||||
@Rule
|
||||
public final GeneratedSource generatedSource = new GeneratedSource();
|
||||
|
||||
@Test
|
||||
@WithClasses( {
|
||||
OrganizationMapper.class
|
||||
} )
|
||||
public void testPreferUpdateMethod() {
|
||||
generatedSource.addComparisonToFixtureFor( OrganizationMapper.class );
|
||||
|
||||
OrganizationEntity organizationEntity = new OrganizationEntity();
|
||||
CompanyEntity companyEntity = new CompanyEntity();
|
||||
@ -85,6 +91,7 @@ public class UpdateMethodsTest {
|
||||
OrganizationMapper.class
|
||||
} )
|
||||
public void testUpdateMethodClearsExistingValues() {
|
||||
generatedSource.addComparisonToFixtureFor( OrganizationMapper.class );
|
||||
|
||||
OrganizationEntity organizationEntity = new OrganizationEntity();
|
||||
CompanyEntity companyEntity = new CompanyEntity();
|
||||
@ -109,6 +116,7 @@ public class UpdateMethodsTest {
|
||||
OrganizationMapper.class
|
||||
})
|
||||
public void testPreferUpdateMethodSourceObjectNotDefined() {
|
||||
generatedSource.addComparisonToFixtureFor( OrganizationMapper.class );
|
||||
|
||||
OrganizationEntity organizationEntity = new OrganizationEntity();
|
||||
|
||||
@ -134,6 +142,7 @@ public class UpdateMethodsTest {
|
||||
DepartmentInBetween.class
|
||||
} )
|
||||
public void testPreferUpdateMethodEncapsulatingCreateMethod() {
|
||||
generatedSource.addComparisonToFixtureFor( CompanyMapper.class );
|
||||
|
||||
CompanyEntity companyEntity = new CompanyEntity();
|
||||
|
||||
|
@ -18,12 +18,11 @@
|
||||
*/
|
||||
package org.mapstruct.ap.test.updatemethods.selection;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.WithClasses;
|
||||
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 {
|
||||
|
||||
@Rule
|
||||
public final GeneratedSource generatedSource = new GeneratedSource().addComparisonToFixtureFor(
|
||||
OrganizationMapper1.class,
|
||||
ExternalMapper.class,
|
||||
DepartmentMapper.class
|
||||
);
|
||||
|
||||
@Test
|
||||
@WithClasses({
|
||||
OrganizationMapper1.class
|
||||
})
|
||||
public void shouldSelectGeneratedExternalMapper() {
|
||||
generatedSource.addComparisonToFixtureFor( OrganizationMapper1.class );
|
||||
|
||||
CompanyEntity entity = new CompanyEntity();
|
||||
CompanyDto dto = new CompanyDto();
|
||||
@ -85,6 +95,7 @@ public class ExternalSelectionTest {
|
||||
})
|
||||
@IssueKey("604")
|
||||
public void shouldSelectGeneratedExternalMapperWithImportForPropertyType() {
|
||||
generatedSource.addComparisonToFixtureFor( OrganizationMapper3.class );
|
||||
|
||||
BossEntity entity = new BossEntity();
|
||||
BossDto dto = new BossDto();
|
||||
@ -96,6 +107,7 @@ public class ExternalSelectionTest {
|
||||
OrganizationMapper2.class
|
||||
})
|
||||
public void shouldSelectGeneratedHandWrittenExternalMapper() {
|
||||
generatedSource.addComparisonToFixtureFor( OrganizationMapper2.class );
|
||||
|
||||
CompanyEntity entity = new CompanyEntity();
|
||||
CompanyDto dto = new CompanyDto();
|
||||
|
@ -18,12 +18,23 @@
|
||||
*/
|
||||
package org.mapstruct.ap.testutil.assertions;
|
||||
|
||||
import static java.lang.String.format;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.assertj.core.api.AbstractCharSequenceAssert;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.assertj.core.api.FileAssert;
|
||||
import org.assertj.core.api.exception.RuntimeIOException;
|
||||
import org.assertj.core.error.ShouldHaveSameContent;
|
||||
import org.assertj.core.internal.Diff;
|
||||
import org.assertj.core.internal.Failures;
|
||||
import org.assertj.core.util.diff.Delta;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.io.Files;
|
||||
@ -34,6 +45,15 @@ import com.google.common.io.Files;
|
||||
* @author Andreas Gudian
|
||||
*/
|
||||
public class JavaFileAssert extends FileAssert {
|
||||
|
||||
private static final String FIRST_LINE_LICENSE_REGEX = ".*Copyright 2012-\\d{4} Gunnar Morling.*";
|
||||
private static final String GENERATED_DATE_REGEX = "\\s+date = " +
|
||||
"\"\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\+\\d{4}\",";
|
||||
private static final String GENERATED_COMMENTS_REGEX = "\\s+comments = \"version: , compiler: .*, environment: " +
|
||||
".*\"";
|
||||
|
||||
private Diff diff = new Diff();
|
||||
|
||||
/**
|
||||
* @param actual the actual file
|
||||
*/
|
||||
@ -76,6 +96,69 @@ public class JavaFileAssert extends FileAssert {
|
||||
content().doesNotContain( getClassImportDeclaration( importedClass ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the expected file has the same content as this Java file. The verification ignores
|
||||
* the license header and the date/comments line from the {@code @Generated} annotation.
|
||||
*
|
||||
* @param expected the file that should be matched
|
||||
*/
|
||||
public void hasSameMapperContent(File expected) {
|
||||
Charset charset = Charset.forName( "UTF-8" );
|
||||
try {
|
||||
List<Delta<String>> diffs = new ArrayList<Delta<String>>( this.diff.diff(
|
||||
actual,
|
||||
charset,
|
||||
expected,
|
||||
charset
|
||||
) );
|
||||
Iterator<Delta<String>> iterator = diffs.iterator();
|
||||
while ( iterator.hasNext() ) {
|
||||
Delta<String> delta = iterator.next();
|
||||
if ( ignoreDelta( delta ) ) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
if ( !diffs.isEmpty() ) {
|
||||
throw Failures.instance()
|
||||
.failure( info, ShouldHaveSameContent.shouldHaveSameContent( actual, expected, diffs ) );
|
||||
}
|
||||
}
|
||||
catch ( IOException e ) {
|
||||
throw new RuntimeIOException( format(
|
||||
"Unable to compare contents of files:<%s> and:<%s>",
|
||||
actual,
|
||||
expected
|
||||
), e );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the delta should be ignored. The delta is ignored if it is a deletion type for the license header
|
||||
* or if it is a change delta for the date/comments part of a {@code @Generated} annotation.
|
||||
*
|
||||
* @param delta that needs to be checked
|
||||
*
|
||||
* @return {@code true} if this delta should be ignored, {@code false} otherwise
|
||||
*/
|
||||
private boolean ignoreDelta(Delta<String> delta) {
|
||||
if ( delta.getType() == Delta.TYPE.DELETE ) {
|
||||
List<String> lines = delta.getOriginal().getLines();
|
||||
return lines.size() > 2 && lines.get( 1 ).matches( FIRST_LINE_LICENSE_REGEX );
|
||||
}
|
||||
else if ( delta.getType() == Delta.TYPE.CHANGE ) {
|
||||
List<String> lines = delta.getOriginal().getLines();
|
||||
if ( lines.size() == 1 ) {
|
||||
return lines.get( 0 ).matches( GENERATED_DATE_REGEX );
|
||||
}
|
||||
else if ( lines.size() == 2 ) {
|
||||
return lines.get( 0 ).matches( GENERATED_DATE_REGEX ) &&
|
||||
lines.get( 1 ).matches( GENERATED_COMMENTS_REGEX );
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a class import declaration string.
|
||||
*
|
||||
|
@ -19,12 +19,19 @@
|
||||
package org.mapstruct.ap.testutil.runner;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.rules.TestRule;
|
||||
import org.junit.runner.Description;
|
||||
import org.junit.runners.model.Statement;
|
||||
import org.mapstruct.ap.testutil.assertions.JavaFileAssert;
|
||||
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* A {@link TestRule} to perform assertions on generated source files.
|
||||
* <p>
|
||||
@ -39,15 +46,19 @@ import org.mapstruct.ap.testutil.assertions.JavaFileAssert;
|
||||
*/
|
||||
public class GeneratedSource implements TestRule {
|
||||
|
||||
private static final String FIXTURES_ROOT = "fixtures/";
|
||||
|
||||
/**
|
||||
* static ThreadLocal, as the {@link CompilingStatement} must inject itself statically for this rule to gain access
|
||||
* to the statement's information. As test execution of different classes in parallel is supported.
|
||||
*/
|
||||
private static ThreadLocal<CompilingStatement> compilingStatement = new ThreadLocal<CompilingStatement>();
|
||||
|
||||
private List<Class<?>> fixturesFor = new ArrayList<Class<?>>();
|
||||
|
||||
@Override
|
||||
public Statement apply(Statement base, Description description) {
|
||||
return base;
|
||||
return new GeneratedSourceStatement( base );
|
||||
}
|
||||
|
||||
static void setCompilingStatement(CompilingStatement compilingStatement) {
|
||||
@ -58,16 +69,37 @@ public class GeneratedSource implements TestRule {
|
||||
GeneratedSource.compilingStatement.remove();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds more mappers that need to be compared.
|
||||
*
|
||||
* The comparison is done for mappers and the are compared against a Java file that matches the name of the
|
||||
* Mapper that would have been created for the fixture.
|
||||
*
|
||||
* @param fixturesFor the classes that need to be compared with
|
||||
* @return the same rule for chaining
|
||||
*/
|
||||
public GeneratedSource addComparisonToFixtureFor(Class<?>... fixturesFor) {
|
||||
for ( Class<?> fixture : fixturesFor ) {
|
||||
this.fixturesFor.add( fixture );
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mapperClass the class annotated with {@code @Mapper}
|
||||
*
|
||||
* @return an assert for the *Impl.java for the given mapper
|
||||
*/
|
||||
public JavaFileAssert forMapper(Class<?> mapperClass) {
|
||||
String generatedJavaFileName = mapperClass.getName().replace( '.', '/' ).concat( "Impl.java" );
|
||||
String generatedJavaFileName = getMapperName( mapperClass );
|
||||
return forJavaFile( generatedJavaFileName );
|
||||
}
|
||||
|
||||
private String getMapperName(Class<?> mapperClass) {
|
||||
return mapperClass.getName().replace( '.', '/' ).concat( "Impl.java" );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mapperClass the class annotated with {@code @Mapper} and {@code @DecoratedWith(..)}
|
||||
*
|
||||
@ -86,4 +118,38 @@ public class GeneratedSource implements TestRule {
|
||||
public JavaFileAssert forJavaFile(String path) {
|
||||
return new JavaFileAssert( new File( compilingStatement.get().getSourceOutputDir() + "/" + path ) );
|
||||
}
|
||||
|
||||
private class GeneratedSourceStatement extends Statement {
|
||||
private final Statement next;
|
||||
|
||||
private GeneratedSourceStatement(Statement next) {
|
||||
this.next = next;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate() throws Throwable {
|
||||
next.evaluate();
|
||||
handleFixtureComparison();
|
||||
}
|
||||
}
|
||||
|
||||
private void handleFixtureComparison() throws UnsupportedEncodingException {
|
||||
for ( Class<?> fixture : fixturesFor ) {
|
||||
String expectedFixture = FIXTURES_ROOT + getMapperName( fixture );
|
||||
URL expectedFile = getClass().getClassLoader().getResource( expectedFixture );
|
||||
if ( expectedFile == null ) {
|
||||
fail( String.format(
|
||||
"No reference file could be found for Mapper %s. You should create a file %s",
|
||||
fixture.getName(),
|
||||
expectedFixture
|
||||
) );
|
||||
}
|
||||
else {
|
||||
File expectedResource = new File( URLDecoder.decode( expectedFile.getFile(), "UTF-8" ) );
|
||||
forMapper( fixture ).hasSameMapperContent( expectedResource );
|
||||
}
|
||||
fixture.getPackage().getName();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,356 @@
|
||||
/**
|
||||
* 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.array;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import javax.annotation.Generated;
|
||||
import org.mapstruct.ap.test.array._target.ScientistDto;
|
||||
import org.mapstruct.ap.test.array.source.Scientist;
|
||||
|
||||
@Generated(
|
||||
value = "org.mapstruct.ap.MappingProcessor",
|
||||
date = "2016-12-28T17:52:06+0100",
|
||||
comments = "version: , compiler: javac, environment: Java 1.8.0_112 (Oracle Corporation)"
|
||||
)
|
||||
public class ScienceMapperImpl implements ScienceMapper {
|
||||
|
||||
@Override
|
||||
public ScientistDto scientistToDto(Scientist scientist) {
|
||||
if ( scientist == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ScientistDto scientistDto = new ScientistDto();
|
||||
|
||||
scientistDto.setName( scientist.getName() );
|
||||
String[] publications = scientist.getPublications();
|
||||
if ( publications != null ) {
|
||||
scientistDto.setPublications( Arrays.copyOf( publications, publications.length ) );
|
||||
}
|
||||
scientistDto.setPublicationYears( stringArrayTointArray( scientist.getPublicationYears() ) );
|
||||
String[] publicPublications = scientist.publicPublications;
|
||||
if ( publicPublications != null ) {
|
||||
scientistDto.publicPublications = Arrays.copyOf( publicPublications, publicPublications.length );
|
||||
}
|
||||
scientistDto.publicPublicationYears = stringArrayTointArray( scientist.publicPublicationYears );
|
||||
|
||||
return scientistDto;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScientistDto[] scientistsToDtos(Scientist[] scientists) {
|
||||
if ( scientists == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ScientistDto[] scientistDtoTmp = new ScientistDto[scientists.length];
|
||||
int i = 0;
|
||||
for ( Scientist scientist : scientists ) {
|
||||
scientistDtoTmp[i] = scientistToDto( scientist );
|
||||
i++;
|
||||
}
|
||||
|
||||
return scientistDtoTmp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScientistDto[] scientistsToDtos(List<Scientist> scientists) {
|
||||
if ( scientists == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ScientistDto[] scientistDtoTmp = new ScientistDto[scientists.size()];
|
||||
int i = 0;
|
||||
for ( Scientist scientist : scientists ) {
|
||||
scientistDtoTmp[i] = scientistToDto( scientist );
|
||||
i++;
|
||||
}
|
||||
|
||||
return scientistDtoTmp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ScientistDto> scientistsToDtosAsList(Scientist[] scientists) {
|
||||
if ( scientists == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<ScientistDto> list = new ArrayList<ScientistDto>();
|
||||
for ( Scientist scientist : scientists ) {
|
||||
list.add( scientistToDto( scientist ) );
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScientistDto[] scientistsToDtos(Scientist[] scientists, ScientistDto[] target) {
|
||||
if ( scientists == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for ( Scientist scientist : scientists ) {
|
||||
if ( ( i >= target.length ) || ( i >= scientists.length ) ) {
|
||||
break;
|
||||
}
|
||||
target[i] = scientistToDto( scientist );
|
||||
i++;
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean[] nvmMapping(boolean[] source) {
|
||||
if ( source == null ) {
|
||||
return new boolean[0];
|
||||
}
|
||||
|
||||
boolean[] booleanTmp = new boolean[source.length];
|
||||
int i = 0;
|
||||
for ( boolean boolean1 : source ) {
|
||||
booleanTmp[i] = boolean1;
|
||||
i++;
|
||||
}
|
||||
|
||||
return booleanTmp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean[] nvmMapping(boolean[] source, boolean[] target) {
|
||||
if ( source == null ) {
|
||||
for (int j = 0; j < target.length; j++ ) {
|
||||
target[j] = false;
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for ( boolean boolean1 : source ) {
|
||||
if ( ( i >= target.length ) || ( i >= source.length ) ) {
|
||||
break;
|
||||
}
|
||||
target[i] = boolean1;
|
||||
i++;
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short[] nvmMapping(int[] source, short[] target) {
|
||||
if ( source == null ) {
|
||||
for (int j = 0; j < target.length; j++ ) {
|
||||
target[j] = 0;
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for ( int int1 : source ) {
|
||||
if ( ( i >= target.length ) || ( i >= source.length ) ) {
|
||||
break;
|
||||
}
|
||||
target[i] = (short) int1;
|
||||
i++;
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] nvmMapping(String[] source, char[] target) {
|
||||
if ( source == null ) {
|
||||
for (int j = 0; j < target.length; j++ ) {
|
||||
target[j] = 0;
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for ( String string : source ) {
|
||||
if ( ( i >= target.length ) || ( i >= source.length ) ) {
|
||||
break;
|
||||
}
|
||||
target[i] = string.charAt( 0 );
|
||||
i++;
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] nvmMapping(int[] source, int[] target) {
|
||||
if ( source == null ) {
|
||||
for (int j = 0; j < target.length; j++ ) {
|
||||
target[j] = 0;
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for ( int int1 : source ) {
|
||||
if ( ( i >= target.length ) || ( i >= source.length ) ) {
|
||||
break;
|
||||
}
|
||||
target[i] = int1;
|
||||
i++;
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long[] nvmMapping(int[] source, long[] target) {
|
||||
if ( source == null ) {
|
||||
for (int j = 0; j < target.length; j++ ) {
|
||||
target[j] = 0L;
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for ( int int1 : source ) {
|
||||
if ( ( i >= target.length ) || ( i >= source.length ) ) {
|
||||
break;
|
||||
}
|
||||
target[i] = int1;
|
||||
i++;
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float[] nvmMapping(int[] source, float[] target) {
|
||||
if ( source == null ) {
|
||||
for (int j = 0; j < target.length; j++ ) {
|
||||
target[j] = 0.0f;
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for ( int int1 : source ) {
|
||||
if ( ( i >= target.length ) || ( i >= source.length ) ) {
|
||||
break;
|
||||
}
|
||||
target[i] = int1;
|
||||
i++;
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double[] nvmMapping(int[] source, double[] target) {
|
||||
if ( source == null ) {
|
||||
for (int j = 0; j < target.length; j++ ) {
|
||||
target[j] = 0.0d;
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for ( int int1 : source ) {
|
||||
if ( ( i >= target.length ) || ( i >= source.length ) ) {
|
||||
break;
|
||||
}
|
||||
target[i] = int1;
|
||||
i++;
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] nvmMapping(int[] source, String[] target) {
|
||||
if ( source == null ) {
|
||||
for (int j = 0; j < target.length; j++ ) {
|
||||
target[j] = null;
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for ( int int1 : source ) {
|
||||
if ( ( i >= target.length ) || ( i >= source.length ) ) {
|
||||
break;
|
||||
}
|
||||
target[i] = new DecimalFormat( "" ).format( int1 );
|
||||
i++;
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nvmMappingVoidReturnNull(int[] source, long[] target) {
|
||||
if ( source == null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for ( int int1 : source ) {
|
||||
if ( ( i >= target.length ) || ( i >= source.length ) ) {
|
||||
break;
|
||||
}
|
||||
target[i] = int1;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nvmMappingVoidReturnDefault(int[] source, long[] target) {
|
||||
if ( source == null ) {
|
||||
for (int j = 0; j < target.length; j++ ) {
|
||||
target[j] = 0L;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for ( int int1 : source ) {
|
||||
if ( ( i >= target.length ) || ( i >= source.length ) ) {
|
||||
break;
|
||||
}
|
||||
target[i] = int1;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
protected int[] stringArrayTointArray(String[] stringArray) {
|
||||
if ( stringArray == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int[] intTmp = new int[stringArray.length];
|
||||
int i = 0;
|
||||
for ( String string : stringArray ) {
|
||||
intTmp[i] = Integer.parseInt( string );
|
||||
i++;
|
||||
}
|
||||
|
||||
return intTmp;
|
||||
}
|
||||
}
|
@ -0,0 +1,243 @@
|
||||
/**
|
||||
* 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> set1 = stringListToLongSet( source.getStrings() );
|
||||
domain.setLongs( set1 );
|
||||
}
|
||||
if ( source.hasStrings() ) {
|
||||
List<String> list = source.getStrings();
|
||||
domain.setStrings( new HashSet<String>( list ) );
|
||||
}
|
||||
if ( source.hasStringsWithDefault() ) {
|
||||
List<String> list1 = source.getStringsWithDefault();
|
||||
domain.setStringsWithDefault( new ArrayList<String>( list1 ) );
|
||||
}
|
||||
else {
|
||||
domain.setStringsWithDefault( helper.toList( "3" ) );
|
||||
}
|
||||
if ( source.hasStringsInitialized() ) {
|
||||
List<String> list2 = source.getStringsInitialized();
|
||||
domain.setStringsInitialized( new HashSet<String>( list2 ) );
|
||||
}
|
||||
|
||||
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> set1 = stringListToLongSet( source.getStringsInitialized() );
|
||||
target.getLongsInitialized().clear();
|
||||
target.getLongsInitialized().addAll( set1 );
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( source.hasStringsInitialized() ) {
|
||||
Set<Long> set1 = stringListToLongSet( source.getStringsInitialized() );
|
||||
target.setLongsInitialized( set1 );
|
||||
}
|
||||
}
|
||||
if ( target.getStringsWithDefault() != null ) {
|
||||
if ( source.hasStringsWithDefault() ) {
|
||||
List<String> list1 = source.getStringsWithDefault();
|
||||
target.getStringsWithDefault().clear();
|
||||
target.getStringsWithDefault().addAll( list1 );
|
||||
}
|
||||
else {
|
||||
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( source.hasStringsWithDefault() ) {
|
||||
List<String> list1 = source.getStringsWithDefault();
|
||||
target.setStringsWithDefault( new ArrayList<String>( list1 ) );
|
||||
}
|
||||
else {
|
||||
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||
}
|
||||
}
|
||||
if ( target.getStringsInitialized() != null ) {
|
||||
if ( source.hasStringsInitialized() ) {
|
||||
List<String> list2 = source.getStringsInitialized();
|
||||
target.getStringsInitialized().clear();
|
||||
target.getStringsInitialized().addAll( list2 );
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( source.hasStringsInitialized() ) {
|
||||
List<String> list2 = source.getStringsInitialized();
|
||||
target.setStringsInitialized( new HashSet<String>( list2 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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> set1 = stringListToLongSet( source.getStringsInitialized() );
|
||||
target.getLongsInitialized().clear();
|
||||
target.getLongsInitialized().addAll( set1 );
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( source.hasStringsInitialized() ) {
|
||||
Set<Long> set1 = stringListToLongSet( source.getStringsInitialized() );
|
||||
target.setLongsInitialized( set1 );
|
||||
}
|
||||
}
|
||||
if ( target.getStringsWithDefault() != null ) {
|
||||
if ( source.hasStringsWithDefault() ) {
|
||||
List<String> list1 = source.getStringsWithDefault();
|
||||
target.getStringsWithDefault().clear();
|
||||
target.getStringsWithDefault().addAll( list1 );
|
||||
}
|
||||
else {
|
||||
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( source.hasStringsWithDefault() ) {
|
||||
List<String> list1 = source.getStringsWithDefault();
|
||||
target.setStringsWithDefault( new ArrayList<String>( list1 ) );
|
||||
}
|
||||
else {
|
||||
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||
}
|
||||
}
|
||||
if ( target.getStringsInitialized() != null ) {
|
||||
if ( source.hasStringsInitialized() ) {
|
||||
List<String> list2 = source.getStringsInitialized();
|
||||
target.getStringsInitialized().clear();
|
||||
target.getStringsInitialized().addAll( list2 );
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( source.hasStringsInitialized() ) {
|
||||
List<String> list2 = source.getStringsInitialized();
|
||||
target.setStringsInitialized( new HashSet<String>( list2 ) );
|
||||
}
|
||||
}
|
||||
|
||||
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,264 @@
|
||||
/**
|
||||
* 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> set1 = stringListToLongSet( source.getStrings() );
|
||||
if ( set1 != null ) {
|
||||
domain.setLongs( set1 );
|
||||
}
|
||||
List<String> list = source.getStrings();
|
||||
if ( list != null ) {
|
||||
domain.setStrings( new HashSet<String>( list ) );
|
||||
}
|
||||
List<String> list1 = source.getStringsWithDefault();
|
||||
if ( list1 != null ) {
|
||||
domain.setStringsWithDefault( new ArrayList<String>( list1 ) );
|
||||
}
|
||||
else {
|
||||
domain.setStringsWithDefault( helper.toList( "3" ) );
|
||||
}
|
||||
List<String> list2 = source.getStringsInitialized();
|
||||
if ( list2 != null ) {
|
||||
domain.setStringsInitialized( new HashSet<String>( list2 ) );
|
||||
}
|
||||
}
|
||||
|
||||
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> set1 = stringListToLongSet( source.getStringsInitialized() );
|
||||
if ( set1 != null ) {
|
||||
target.getLongsInitialized().clear();
|
||||
target.getLongsInitialized().addAll( set1 );
|
||||
}
|
||||
else {
|
||||
target.setLongsInitialized( null );
|
||||
}
|
||||
}
|
||||
else {
|
||||
Set<Long> set1 = stringListToLongSet( source.getStringsInitialized() );
|
||||
if ( set1 != null ) {
|
||||
target.setLongsInitialized( set1 );
|
||||
}
|
||||
}
|
||||
if ( target.getStringsWithDefault() != null ) {
|
||||
List<String> list1 = source.getStringsWithDefault();
|
||||
if ( list1 != null ) {
|
||||
target.getStringsWithDefault().clear();
|
||||
target.getStringsWithDefault().addAll( list1 );
|
||||
}
|
||||
else {
|
||||
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||
}
|
||||
}
|
||||
else {
|
||||
List<String> list1 = source.getStringsWithDefault();
|
||||
if ( list1 != null ) {
|
||||
target.setStringsWithDefault( new ArrayList<String>( list1 ) );
|
||||
}
|
||||
else {
|
||||
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||
}
|
||||
}
|
||||
if ( target.getStringsInitialized() != null ) {
|
||||
List<String> list2 = source.getStringsInitialized();
|
||||
if ( list2 != null ) {
|
||||
target.getStringsInitialized().clear();
|
||||
target.getStringsInitialized().addAll( list2 );
|
||||
}
|
||||
else {
|
||||
target.setStringsInitialized( null );
|
||||
}
|
||||
}
|
||||
else {
|
||||
List<String> list2 = source.getStringsInitialized();
|
||||
if ( list2 != null ) {
|
||||
target.setStringsInitialized( new HashSet<String>( list2 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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> set1 = stringListToLongSet( source.getStringsInitialized() );
|
||||
if ( set1 != null ) {
|
||||
target.getLongsInitialized().clear();
|
||||
target.getLongsInitialized().addAll( set1 );
|
||||
}
|
||||
else {
|
||||
target.setLongsInitialized( null );
|
||||
}
|
||||
}
|
||||
else {
|
||||
Set<Long> set1 = stringListToLongSet( source.getStringsInitialized() );
|
||||
if ( set1 != null ) {
|
||||
target.setLongsInitialized( set1 );
|
||||
}
|
||||
}
|
||||
if ( target.getStringsWithDefault() != null ) {
|
||||
List<String> list1 = source.getStringsWithDefault();
|
||||
if ( list1 != null ) {
|
||||
target.getStringsWithDefault().clear();
|
||||
target.getStringsWithDefault().addAll( list1 );
|
||||
}
|
||||
else {
|
||||
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||
}
|
||||
}
|
||||
else {
|
||||
List<String> list1 = source.getStringsWithDefault();
|
||||
if ( list1 != null ) {
|
||||
target.setStringsWithDefault( new ArrayList<String>( list1 ) );
|
||||
}
|
||||
else {
|
||||
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||
}
|
||||
}
|
||||
if ( target.getStringsInitialized() != null ) {
|
||||
List<String> list2 = source.getStringsInitialized();
|
||||
if ( list2 != null ) {
|
||||
target.getStringsInitialized().clear();
|
||||
target.getStringsInitialized().addAll( list2 );
|
||||
}
|
||||
else {
|
||||
target.setStringsInitialized( null );
|
||||
}
|
||||
}
|
||||
else {
|
||||
List<String> list2 = source.getStringsInitialized();
|
||||
if ( list2 != null ) {
|
||||
target.setStringsInitialized( new HashSet<String>( list2 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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,267 @@
|
||||
/**
|
||||
* 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> set1 = stringListToLongSet( source.getStrings() );
|
||||
if ( set1 != null ) {
|
||||
domain.setLongs( set1 );
|
||||
}
|
||||
List<String> list = source.getStrings();
|
||||
if ( list != null ) {
|
||||
domain.setStrings( new HashSet<String>( list ) );
|
||||
}
|
||||
List<String> list1 = source.getStringsWithDefault();
|
||||
if ( list1 != null ) {
|
||||
domain.setStringsWithDefault( new ArrayList<String>( list1 ) );
|
||||
}
|
||||
else {
|
||||
domain.setStringsWithDefault( helper.toList( "3" ) );
|
||||
}
|
||||
List<String> list2 = source.getStringsInitialized();
|
||||
if ( list2 != null ) {
|
||||
domain.setStringsInitialized( new HashSet<String>( list2 ) );
|
||||
}
|
||||
|
||||
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> set1 = stringListToLongSet( source.getStringsInitialized() );
|
||||
if ( set1 != null ) {
|
||||
target.getLongsInitialized().clear();
|
||||
target.getLongsInitialized().addAll( set1 );
|
||||
}
|
||||
else {
|
||||
target.setLongsInitialized( null );
|
||||
}
|
||||
}
|
||||
else {
|
||||
Set<Long> set1 = stringListToLongSet( source.getStringsInitialized() );
|
||||
if ( set1 != null ) {
|
||||
target.setLongsInitialized( set1 );
|
||||
}
|
||||
}
|
||||
if ( target.getStringsWithDefault() != null ) {
|
||||
List<String> list1 = source.getStringsWithDefault();
|
||||
if ( list1 != null ) {
|
||||
target.getStringsWithDefault().clear();
|
||||
target.getStringsWithDefault().addAll( list1 );
|
||||
}
|
||||
else {
|
||||
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||
}
|
||||
}
|
||||
else {
|
||||
List<String> list1 = source.getStringsWithDefault();
|
||||
if ( list1 != null ) {
|
||||
target.setStringsWithDefault( new ArrayList<String>( list1 ) );
|
||||
}
|
||||
else {
|
||||
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||
}
|
||||
}
|
||||
if ( target.getStringsInitialized() != null ) {
|
||||
List<String> list2 = source.getStringsInitialized();
|
||||
if ( list2 != null ) {
|
||||
target.getStringsInitialized().clear();
|
||||
target.getStringsInitialized().addAll( list2 );
|
||||
}
|
||||
else {
|
||||
target.setStringsInitialized( null );
|
||||
}
|
||||
}
|
||||
else {
|
||||
List<String> list2 = source.getStringsInitialized();
|
||||
if ( list2 != null ) {
|
||||
target.setStringsInitialized( new HashSet<String>( list2 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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> set1 = stringListToLongSet( source.getStringsInitialized() );
|
||||
if ( set1 != null ) {
|
||||
target.getLongsInitialized().clear();
|
||||
target.getLongsInitialized().addAll( set1 );
|
||||
}
|
||||
else {
|
||||
target.setLongsInitialized( null );
|
||||
}
|
||||
}
|
||||
else {
|
||||
Set<Long> set1 = stringListToLongSet( source.getStringsInitialized() );
|
||||
if ( set1 != null ) {
|
||||
target.setLongsInitialized( set1 );
|
||||
}
|
||||
}
|
||||
if ( target.getStringsWithDefault() != null ) {
|
||||
List<String> list1 = source.getStringsWithDefault();
|
||||
if ( list1 != null ) {
|
||||
target.getStringsWithDefault().clear();
|
||||
target.getStringsWithDefault().addAll( list1 );
|
||||
}
|
||||
else {
|
||||
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||
}
|
||||
}
|
||||
else {
|
||||
List<String> list1 = source.getStringsWithDefault();
|
||||
if ( list1 != null ) {
|
||||
target.setStringsWithDefault( new ArrayList<String>( list1 ) );
|
||||
}
|
||||
else {
|
||||
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||
}
|
||||
}
|
||||
if ( target.getStringsInitialized() != null ) {
|
||||
List<String> list2 = source.getStringsInitialized();
|
||||
if ( list2 != null ) {
|
||||
target.getStringsInitialized().clear();
|
||||
target.getStringsInitialized().addAll( list2 );
|
||||
}
|
||||
else {
|
||||
target.setStringsInitialized( null );
|
||||
}
|
||||
}
|
||||
else {
|
||||
List<String> list2 = source.getStringsInitialized();
|
||||
if ( list2 != null ) {
|
||||
target.setStringsInitialized( new HashSet<String>( list2 ) );
|
||||
}
|
||||
}
|
||||
|
||||
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,243 @@
|
||||
/**
|
||||
* 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> set1 = stringListToLongSet( source.getStrings() );
|
||||
domain.setLongs( set1 );
|
||||
}
|
||||
if ( source.hasStrings() ) {
|
||||
List<String> list = source.getStrings();
|
||||
domain.setStrings( new HashSet<String>( list ) );
|
||||
}
|
||||
if ( source.hasStringsWithDefault() ) {
|
||||
List<String> list1 = source.getStringsWithDefault();
|
||||
domain.setStringsWithDefault( new ArrayList<String>( list1 ) );
|
||||
}
|
||||
else {
|
||||
domain.setStringsWithDefault( helper.toList( "3" ) );
|
||||
}
|
||||
if ( source.hasStringsInitialized() ) {
|
||||
List<String> list2 = source.getStringsInitialized();
|
||||
domain.setStringsInitialized( new HashSet<String>( list2 ) );
|
||||
}
|
||||
|
||||
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> set1 = stringListToLongSet( source.getStringsInitialized() );
|
||||
target.getLongsInitialized().clear();
|
||||
target.getLongsInitialized().addAll( set1 );
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( source.hasStringsInitialized() ) {
|
||||
Set<Long> set1 = stringListToLongSet( source.getStringsInitialized() );
|
||||
target.setLongsInitialized( set1 );
|
||||
}
|
||||
}
|
||||
if ( target.getStringsWithDefault() != null ) {
|
||||
if ( source.hasStringsWithDefault() ) {
|
||||
List<String> list1 = source.getStringsWithDefault();
|
||||
target.getStringsWithDefault().clear();
|
||||
target.getStringsWithDefault().addAll( list1 );
|
||||
}
|
||||
else {
|
||||
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( source.hasStringsWithDefault() ) {
|
||||
List<String> list1 = source.getStringsWithDefault();
|
||||
target.setStringsWithDefault( new ArrayList<String>( list1 ) );
|
||||
}
|
||||
else {
|
||||
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||
}
|
||||
}
|
||||
if ( target.getStringsInitialized() != null ) {
|
||||
if ( source.hasStringsInitialized() ) {
|
||||
List<String> list2 = source.getStringsInitialized();
|
||||
target.getStringsInitialized().clear();
|
||||
target.getStringsInitialized().addAll( list2 );
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( source.hasStringsInitialized() ) {
|
||||
List<String> list2 = source.getStringsInitialized();
|
||||
target.setStringsInitialized( new HashSet<String>( list2 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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> set1 = stringListToLongSet( source.getStringsInitialized() );
|
||||
target.getLongsInitialized().clear();
|
||||
target.getLongsInitialized().addAll( set1 );
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( source.hasStringsInitialized() ) {
|
||||
Set<Long> set1 = stringListToLongSet( source.getStringsInitialized() );
|
||||
target.setLongsInitialized( set1 );
|
||||
}
|
||||
}
|
||||
if ( target.getStringsWithDefault() != null ) {
|
||||
if ( source.hasStringsWithDefault() ) {
|
||||
List<String> list1 = source.getStringsWithDefault();
|
||||
target.getStringsWithDefault().clear();
|
||||
target.getStringsWithDefault().addAll( list1 );
|
||||
}
|
||||
else {
|
||||
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( source.hasStringsWithDefault() ) {
|
||||
List<String> list1 = source.getStringsWithDefault();
|
||||
target.setStringsWithDefault( new ArrayList<String>( list1 ) );
|
||||
}
|
||||
else {
|
||||
target.setStringsWithDefault( helper.toList( "3" ) );
|
||||
}
|
||||
}
|
||||
if ( target.getStringsInitialized() != null ) {
|
||||
if ( source.hasStringsInitialized() ) {
|
||||
List<String> list2 = source.getStringsInitialized();
|
||||
target.getStringsInitialized().clear();
|
||||
target.getStringsInitialized().addAll( list2 );
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( source.hasStringsInitialized() ) {
|
||||
List<String> list2 = source.getStringsInitialized();
|
||||
target.setStringsInitialized( new HashSet<String>( list2 ) );
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
try {
|
||||
if ( source.getPets() != null ) {
|
||||
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 source1 = new Source();
|
||||
|
||||
try {
|
||||
List<String> list = petMapper.toSourcePets( source.getPets() );
|
||||
if ( list != null ) {
|
||||
source1.setPets( list );
|
||||
}
|
||||
}
|
||||
catch ( CatException e ) {
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
catch ( DogException e ) {
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
|
||||
return source1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toExistingTarget(Source source, Target target) {
|
||||
if ( source == null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if ( source.getPets() != null ) {
|
||||
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 tooth : source.getTeeth() ) {
|
||||
targetDali.addTeeth( teethMapper.toTooth( tooth ) );
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
try {
|
||||
if ( source.getPets() != null ) {
|
||||
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();
|
||||
|
||||
try {
|
||||
if ( source.getPets() != null ) {
|
||||
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();
|
||||
|
||||
try {
|
||||
if ( source.getPet() != null ) {
|
||||
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();
|
||||
|
||||
try {
|
||||
if ( source.getPets() != null ) {
|
||||
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,92 @@
|
||||
/**
|
||||
* 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 ( dto.getEmployees() != null ) {
|
||||
if ( entity.getEmployees() == null ) {
|
||||
entity.setEmployees( new ArrayList<EmployeeEntity>() );
|
||||
}
|
||||
externalHandWrittenMapper.toEmployeeEntityList( dto.getEmployees(), entity.getEmployees() );
|
||||
}
|
||||
else {
|
||||
entity.setEmployees( null );
|
||||
}
|
||||
if ( dto.getSecretaryToEmployee() != null ) {
|
||||
if ( entity.getSecretaryToEmployee() == null ) {
|
||||
entity.setSecretaryToEmployee( new HashMap<SecretaryEntity, EmployeeEntity>() );
|
||||
}
|
||||
externalHandWrittenMapper.toSecretaryEmployeeEntityMap( dto.getSecretaryToEmployee(), entity.getSecretaryToEmployee() );
|
||||
}
|
||||
else {
|
||||
entity.setSecretaryToEmployee( null );
|
||||
}
|
||||
}
|
||||
|
||||
@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