mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
parent
38744d9f73
commit
a95d1c59c3
@ -383,6 +383,10 @@ public class MappingResolverImpl implements MappingResolver {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( type.isEnumType() ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if ( type.isArrayType() ) {
|
if ( type.isArrayType() ) {
|
||||||
return type.isJavaLangType() || type.getComponentType().isPrimitive();
|
return type.isJavaLangType() || type.getComponentType().isPrimitive();
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright MapStruct Authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*/
|
||||||
|
package org.mapstruct.ap.test.bugs._2505;
|
||||||
|
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.control.DeepClone;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Sjaak Derksen
|
||||||
|
*/
|
||||||
|
@Mapper( mappingControl = DeepClone.class )
|
||||||
|
public interface Issue2505Mapper {
|
||||||
|
|
||||||
|
Issue2505Mapper INSTANCE = Mappers.getMapper( Issue2505Mapper.class );
|
||||||
|
|
||||||
|
Customer map(CustomerDTO value);
|
||||||
|
|
||||||
|
enum Status {
|
||||||
|
ENABLED, DISABLED,
|
||||||
|
}
|
||||||
|
|
||||||
|
class Customer {
|
||||||
|
|
||||||
|
private Status status;
|
||||||
|
|
||||||
|
public Status getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(Status stat) {
|
||||||
|
this.status = stat;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class CustomerDTO {
|
||||||
|
|
||||||
|
private Status status;
|
||||||
|
|
||||||
|
public Status getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(Status status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright MapStruct Authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*/
|
||||||
|
package org.mapstruct.ap.test.bugs._2505;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
|
import org.mapstruct.ap.testutil.IssueKey;
|
||||||
|
import org.mapstruct.ap.testutil.ProcessorTest;
|
||||||
|
import org.mapstruct.ap.testutil.WithClasses;
|
||||||
|
import org.mapstruct.ap.testutil.runner.GeneratedSource;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Sjaak derksen
|
||||||
|
*/
|
||||||
|
@IssueKey("2505")
|
||||||
|
@WithClasses( Issue2505Mapper.class )
|
||||||
|
class Issue2505Test {
|
||||||
|
|
||||||
|
@RegisterExtension
|
||||||
|
final GeneratedSource generatedSource = new GeneratedSource()
|
||||||
|
.addComparisonToFixtureFor( Issue2505Mapper.class );
|
||||||
|
|
||||||
|
@ProcessorTest
|
||||||
|
void shouldNotGenerateEnumMappingMethodForDeepClone() {
|
||||||
|
Issue2505Mapper.CustomerDTO source = new Issue2505Mapper.CustomerDTO();
|
||||||
|
source.setStatus( Issue2505Mapper.Status.DISABLED );
|
||||||
|
|
||||||
|
Issue2505Mapper.Customer target = Issue2505Mapper.INSTANCE.map( source );
|
||||||
|
|
||||||
|
assertThat( target.getStatus() ).isEqualTo( Issue2505Mapper.Status.DISABLED );
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright MapStruct Authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*/
|
||||||
|
package org.mapstruct.ap.test.bugs._2505;
|
||||||
|
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
|
||||||
|
@Generated(
|
||||||
|
value = "org.mapstruct.ap.MappingProcessor",
|
||||||
|
date = "2021-07-03T14:21:53+0200",
|
||||||
|
comments = "version: , compiler: Eclipse JDT (Batch) 3.20.0.v20191203-2131, environment: Java 1.8.0_181 (Oracle Corporation)"
|
||||||
|
)
|
||||||
|
public class Issue2505MapperImpl implements Issue2505Mapper {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Customer map(CustomerDTO value) {
|
||||||
|
if ( value == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Customer customer = new Customer();
|
||||||
|
|
||||||
|
customer.setStatus( value.getStatus() );
|
||||||
|
|
||||||
|
return customer;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user