Coder Social home page Coder Social logo

Comments (6)

Chessray avatar Chessray commented on June 26, 2024

This is a funny one. The linked solution using TypeDescriptors relies on another Spring-internal mechanism.

Looking at this a bit closer: What is your actual use case? Are you trying to define a Converter<List<A>, List<B>>?

from mapstruct-spring-extensions.

hypercube-software avatar hypercube-software commented on June 26, 2024

indeed, I just want to convert a List to a List

from mapstruct-spring-extensions.

coding-guo avatar coding-guo commented on June 26, 2024

I have the same problem,I want to achieve such a requirement,I defined two mapper

First:
@Mapper(componentModel = "spring") public interface AreaMapperStruct extends Converter<List<Area>, List<AreaSimpleOutDTO>> { @Override List<AreaSimpleOutDTO> convert(List<Area> areaList); }

The second:
@Mapper(componentModel = "spring") public interface PartTypeMapperStruct extends Converter<List<PartType>, List<PartTypeOut>> { @Override List<PartTypeOut> convert(List<PartType> partTypes); }
Compile Error:
`public class ConfigurationServiceAdapter {
private final ConversionService conversionService;

public ConfigurationServiceAdapter(
@qualifier("partTypeConversionService") @lazy final ConversionService conversionService) {
this.conversionService = conversionService;
}

public List mapListToList(final List source) {
return conversionService.convert(source, List.class);
}

public DeviceBrand mapDeviceBrandOptDTOToDeviceBrand(final DeviceBrandOptDTO source) {
return conversionService.convert(source, DeviceBrand.class);
}

public AlarmCode mapAlarmCodeOptDTOToAlarmCode(final AlarmCodeOptDTO source) {
return conversionService.convert(source, AlarmCode.class);
}

public List mapListToList(final List source) {
return conversionService.convert(source, List.class);
}
}`

have two "mapListToList" method,how can i solve this problem

from mapstruct-spring-extensions.

Chessray avatar Chessray commented on June 26, 2024

Will have to look into this a bit. Until we can provide a full solution, the best thing I can suggest is not implementing the List Mapper as a Spring Converter and following standard MapStruct instead.

from mapstruct-spring-extensions.

coding-guo avatar coding-guo commented on June 26, 2024

Thank you and look forward to a better solution!!

Will have to look into this a bit. Until we can provide a full solution, the best thing I can suggest is not implementing the List Mapper as a Spring Converter and following standard MapStruct instead.

from mapstruct-spring-extensions.

Chessray avatar Chessray commented on June 26, 2024

Some notes:

  • The method TypeDescriptor.collection explicitly states that it's only applicable to anything extending the Collection interface. We should be able to check that.
  • Cater for nested Generics, e.g. List<Set<Object>>.
  • If we do this, we want to do it right.

from mapstruct-spring-extensions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.