Support for custom constructor for Mappers

336 views
Skip to first unread message

Ishan Bansal

unread,
Nov 23, 2015, 11:33:27 PM11/23/15
to mapstruct-users
I have a scenario

class CarMapper {
    
    public CarMapper(some args) {
         //some instantiation logic
    }
    
    Car map(CarDTO dto);
    CarDTO map(Car car);
}

Can we have support in map-struct to generate impls even if the default constructor is absent?

Gunnar Morling

unread,
Nov 24, 2015, 2:27:49 AM11/24/15
to Ishan Bansal, mapstruct-users
Hi,

We have scheduled support for mapping target types with custom
constructors for MapStruct 1.1 (see
https://github.com/mapstruct/mapstruct/issues/73), so far no one had
the need for mappers with non-default constructors.

It should be no problem for Spring/CDI, so I suppose you are working
with the default component model? We could add another method
getMappers(Object... args) to the Mappers factory. But we'd have no
way for checking type correctness, so that'd be on the user. It still
would not work for mappers referenced via @Mapper#uses(), though.

Cheers,

--Gunnar
> --
> You received this message because you are subscribed to the Google Groups
> "mapstruct-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mapstruct-use...@googlegroups.com.
> To post to this group, send email to mapstru...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages