I read about ModelMapper, today and it seems to be very interesting, but I'm not sure about the right usage.
I have a Spring-Project like this: I have my model classes which are necessary for serialization. My REST controller return DTO-objects to the front end. And my frontend returns DTOs to my controller and then I need my model objects from the DTOs to write it to the database.
I have a person class that has an attribute like: Set<Company> companies = new HashSet<Company>();
I want the modelmapper to map this set to an attribute: Set<String> companies = new HashSet<String>()
.The 2nd set shall be filled by calling companies.getName() instead of filling the Set with the whole object.
My questions:
- Do I need a PropertyMap or a converter?
- How exactly can I do this?
- Is it possible to say Convert from
Set<Companies>
into a single String. Like I want just one company?
Sorry, I'm very new to ModelMapper and I'm searching for the best way to map during serialization and deserialization in combinatino with spring.