Do not try to create mappings for objects in the java package #1154

Closed
filiphr opened this Issue Mar 23, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@filiphr
Member

filiphr commented Mar 23, 2017

When we generate missing mappings we shouldn't try to go into objects from the java package.

For example if we have:

public class MyDate {

    private String someProperty;

    //getters and setters omitted for brevity
}
public class Entity {
    
    private MyDate date;

    //getters and setters omitted for brevity
}
public class EntityDto {
    
    private Date date;

    //getters and setters omitted for brevity
}
@Mapper
public interface MyMapper {

    EntityDto map(Entity entity);
}

We are going to generate:

protected Date myDateToDate(MyDate myDate) {
        if ( myDate == null ) {
            return null;
        }

        Date date = new Date();

        return date;
}

In my opinion we shouldn't try to instantiate and create objects from the java package. We also then continue and try to see if there are properties that can be mapped between Date and MyDate.

@agudian

This comment has been minimized.

Show comment
Hide comment
@agudian

agudian Mar 26, 2017

Member

Makes sense! I'm trying to come up with examples of classes in java.* where treating them as beans would be okay, but I can't find any... 😁
How about limiting this to known full package names, such as java.lang, java.util, java.time, ...? That gives us a little bit more control.

Member

agudian commented Mar 26, 2017

Makes sense! I'm trying to come up with examples of classes in java.* where treating them as beans would be okay, but I can't find any... 😁
How about limiting this to known full package names, such as java.lang, java.util, java.time, ...? That gives us a little bit more control.

filiphr added a commit to filiphr/mapstruct that referenced this issue Apr 5, 2017

#1154 Add SPI for excluding types/elements from automatic sub-mappin…
…g generation.

Default implementation of SPI ignores types in the java/javax packages

@filiphr filiphr self-assigned this Apr 7, 2017

@filiphr filiphr added the enhancement label Apr 7, 2017

@filiphr filiphr added this to the 1.2.0.CR1 milestone Apr 7, 2017

@filiphr

This comment has been minimized.

Show comment
Hide comment
@filiphr

filiphr Apr 7, 2017

Member

Just as information, I already have a 90% ready implementation for this. I am waiting for #1146 to be resolved/merged to create a PR. The reason is that I am using something from there to ignore the java packages :)

Member

filiphr commented Apr 7, 2017

Just as information, I already have a 90% ready implementation for this. I am waiting for #1146 to be resolved/merged to create a PR. The reason is that I am using something from there to ignore the java packages :)

filiphr added a commit to filiphr/mapstruct that referenced this issue Apr 20, 2017

#1154 Add SPI for excluding types/elements from automatic sub-mappin…
…g generation.

Default implementation of SPI ignores types in the java/javax packages

filiphr added a commit to filiphr/mapstruct that referenced this issue Apr 21, 2017

#1154 Add SPI for excluding types/elements from automatic sub-mappin…
…g generation.

Default implementation of SPI ignores types in the java/javax packages

filiphr added a commit to filiphr/mapstruct that referenced this issue Apr 22, 2017

#1154 Add SPI for excluding types/elements from automatic sub-mappin…
…g generation.

Default implementation of SPI ignores types in the java/javax packages

filiphr added a commit to filiphr/mapstruct that referenced this issue Apr 23, 2017

#1154 Add SPI for excluding types/elements from automatic sub-mappin…
…g generation.

Default implementation of SPI ignores types in the java/javax packages

filiphr added a commit to filiphr/mapstruct that referenced this issue Apr 23, 2017

#1154 Add SPI for excluding types/elements from automatic sub-mappin…
…g generation.

Default implementation of SPI ignores types in the java/javax packages

filiphr added a commit to filiphr/mapstruct that referenced this issue Apr 23, 2017

#1154 Add SPI for excluding types/elements from automatic sub-mappin…
…g generation.

Default implementation of SPI ignores types in the java/javax packages

filiphr added a commit to filiphr/mapstruct that referenced this issue Apr 25, 2017

#1154 Add SPI for excluding types/elements from automatic sub-mappin…
…g generation.

Default implementation of SPI ignores types in the java/javax packages

filiphr added a commit to filiphr/mapstruct that referenced this issue May 7, 2017

#1154 Add SPI for excluding types/elements from automatic sub-mappin…
…g generation.

Default implementation of SPI ignores types in the java/javax packages

@filiphr filiphr closed this in #1183 May 17, 2017

filiphr added a commit that referenced this issue May 17, 2017

#1154 Add SPI for excluding types/elements from automatic sub-mappin…
…g generation


Default implementation of SPI ignores types in the java/javax packages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment