mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#3732 Do not generate obsolete imports for LocalDateTime <-> LocalDate conversion
This commit is contained in:
parent
21fdaa0f82
commit
c2bd847599
@ -7,11 +7,8 @@ package org.mapstruct.ap.internal.conversion;
|
|||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.mapstruct.ap.internal.model.common.ConversionContext;
|
import org.mapstruct.ap.internal.model.common.ConversionContext;
|
||||||
import org.mapstruct.ap.internal.model.common.Type;
|
|
||||||
import org.mapstruct.ap.internal.util.Collections;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SimpleConversion for mapping {@link LocalDateTime} to
|
* SimpleConversion for mapping {@link LocalDateTime} to
|
||||||
@ -25,22 +22,9 @@ public class JavaLocalDateTimeToLocalDateConversion extends SimpleConversion {
|
|||||||
return "<SOURCE>.toLocalDate()";
|
return "<SOURCE>.toLocalDate()";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Set<Type> getToConversionImportTypes(ConversionContext conversionContext) {
|
|
||||||
return Collections.asSet(
|
|
||||||
conversionContext.getTypeFactory().getType( LocalDate.class )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getFromExpression(ConversionContext conversionContext) {
|
protected String getFromExpression(ConversionContext conversionContext) {
|
||||||
return "<SOURCE>.atStartOfDay()";
|
return "<SOURCE>.atStartOfDay()";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Set<Type> getFromConversionImportTypes(ConversionContext conversionContext) {
|
|
||||||
return Collections.asSet(
|
|
||||||
conversionContext.getTypeFactory().getType( LocalDateTime.class )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* 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._3732;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Filip Hrisafov
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface Issue3732Mapper {
|
||||||
|
|
||||||
|
Target map(Source source);
|
||||||
|
|
||||||
|
Source map(Target source);
|
||||||
|
|
||||||
|
class Source {
|
||||||
|
private LocalDateTime value;
|
||||||
|
|
||||||
|
public LocalDateTime getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(LocalDateTime value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Target {
|
||||||
|
|
||||||
|
private LocalDate value;
|
||||||
|
|
||||||
|
public LocalDate getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(LocalDate value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* 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._3732;
|
||||||
|
|
||||||
|
import org.mapstruct.ap.testutil.IssueKey;
|
||||||
|
import org.mapstruct.ap.testutil.ProcessorTest;
|
||||||
|
import org.mapstruct.ap.testutil.WithClasses;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Filip Hrisafov
|
||||||
|
*/
|
||||||
|
@IssueKey("3732")
|
||||||
|
@WithClasses({ Issue3732Mapper.class })
|
||||||
|
class Issue3732Test {
|
||||||
|
|
||||||
|
@ProcessorTest
|
||||||
|
void shouldGenerateCorrectMapper() {
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user