mapstruct

mapstruct and gradle configuratoin issue in Intellij IDEA

不想你离开。 提交于 2019-12-05 22:43:57
问题 I have a project using gradle, and have mapstruct as one of dependency. everytime I tried to build project, it failed. I guess it is because Mapstruct will generate impl class that gradle was not able to find. Can anyone help me how to configure this in intellij IDEA? Thanks 回答1: This works for me In intellij IDEA go to File | Settings | Build, Execution, Deployment | Build Tools | Gradle | Runner Enable Delegate IDE build/run actions. Ref :- https://www.jetbrains.com/idea/whatsnew/#v2016-3

MapStruct: mapping from java.util.Map to Bean?

风格不统一 提交于 2019-12-05 20:15:33
I currently have a Map<String, String> that contains values in the form key = value and I would like to "expand" those into a real object. Is it possible to automate that with MapStruct and how would I do that? To clarify: The code I would write by hand would look something like this: public MyEntity mapToEntity(final Map<String, String> parameters) { final MyEntity result = new MyEntity(); result.setNote(parameters.get("note")); result.setDate(convertStringToDate(parameters.get("date"))); result.setCustomer(mapIdToCustomer(parameters.get("customerId"))); // ... return result; } Method 1 The

MapStruct String to List mapping

余生长醉 提交于 2019-12-05 14:23:49
问题 How would i map String to List and List to String? Consider we have following classess class People{ private String primaryEmailAddress; private String secondaryEmailAddress; private List<String> phones; //getter and setters } class PeopleTO{ private List<String> emailAddress; private String primaryPhone; private String secondaryPhone; //getter and setters } In Dozer and Orika, we can easily map with the following line of code fields("primaryEmailAddress", "emailAddress[0]") fields(

Map multiple source fields to same type target fields with Mapstruct

蓝咒 提交于 2019-12-05 04:30:24
Consider the following POJOs: public class SchedulePayload { public String name; public String scheduler; public PeriodPayload notificationPeriod; public PeriodPayload schedulePeriod; } private class Lecture { public ZonedDateTime start; public ZonedDateTime end; } public class XmlSchedule { public String scheduleName; public String schedulerName; public DateTime notificationFrom; public DateTime notificationTo; public DateTime scheduleFrom; public DateTime scheduleTo; } public class PeriodPayload { public DateTime start; public DateTime finish; } Using MapStruct, I created a mapper that maps

Mapping an object to an immutable object with builder (using immutables annotation processor) in mapstruct

被刻印的时光 ゝ 提交于 2019-12-05 03:50:37
We are using the immutables framework to generate all DTOs. Now we would like to map these objects one to another with mapstruct . But the generated DTOs are immutable and have no setters and no constructor, corresponding to the builder pattern. They are only filled through the corresponding builder accessed by a static builder() -method. We instead tried to map DTO1 to DTO2.Builder which would work if mapstruct would recognize the setter in the Builder but these do not have void return type but return the Builder itself for fluent concatenation. So here is the code of the example. We have two

MapStruct: Mapping 2 objects to a 3rd one

…衆ロ難τιáo~ 提交于 2019-12-04 18:26:26
问题 I have Object1 and Object2. Now, I want to map object3, with attributes from 1 & 2. Say, I have 2 object: 1. User: {first_name, last_name, id} 2. Address: {street, locality, city, state, pin, id} Now, with these, I want to map that in User_View: {firstName, lastName, city, state}. Where, first_name & last_name will be from User object and city & state from Address object. Now, my question is, how to do that? However, currently, I'm doing like this @Mapper public abstract class UserViewMapper

Nested Mapping in Mapstruct

元气小坏坏 提交于 2019-12-04 13:12:23
I am new to MapStruct API, can anyone say how to do nested Mapping. I have two classes one is my actual purchaseOrder class, which is known my target class, the other is EDPurchaseOrder class which known as source file, here don't worry about the naming conventions I used, just go with source and target files. Source Classes Source class EDCustomerOrder and its reference classes public class EDCustomerOrder{ private Integer orderID; private String orderNumber; private BigDecimal orderTotalQty; private String UOM; private PickupDTO pickupPoints; private Integer supplierID; private String

MapStruct implementation is not working in Spring Boot Web Application

前提是你 提交于 2019-12-04 11:44:26
I am a newbie to Spring Boot and MapStruct Tool. Earlier, A Project(written by other team using these technologies) is not starting up. Then, I had made some changes in Mapper Abstract Class but now mapper object is coming as null on application startup. Mapper Abstract Class: @Mapper(componentModel = "spring") public abstract class UserAndEmployeeMapper { public UserAndEmployeeMapper INSTANCE = Mappers.getMapper( UserAndEmployeeMapper.class ); @Mapping(source = "username", target = "name") @Mapping(source = "ssn", target = "ssn", defaultValue = "xxxxxx" ) @Mapping(target = "salary", constant

mapstruct and gradle configuratoin issue in Intellij IDEA

北城余情 提交于 2019-12-04 03:25:48
I have a project using gradle, and have mapstruct as one of dependency. everytime I tried to build project, it failed. I guess it is because Mapstruct will generate impl class that gradle was not able to find. Can anyone help me how to configure this in intellij IDEA? Thanks This works for me In intellij IDEA go to File | Settings | Build, Execution, Deployment | Build Tools | Gradle | Runner Enable Delegate IDE build/run actions. Ref :- https://www.jetbrains.com/idea/whatsnew/#v2016-3-gradle In build.gradle buildscript { ... } plugins { id 'net.ltgt.apt' version '0.9' } apply plugin: 'idea'

MapStruct String to List mapping

孤街醉人 提交于 2019-12-04 00:35:51
How would i map String to List and List to String? Consider we have following classess class People{ private String primaryEmailAddress; private String secondaryEmailAddress; private List<String> phones; //getter and setters } class PeopleTO{ private List<String> emailAddress; private String primaryPhone; private String secondaryPhone; //getter and setters } In Dozer and Orika, we can easily map with the following line of code fields("primaryEmailAddress", "emailAddress[0]") fields("secondaryEmailAddress", "emailAddress[1]") fields("phones[0]", "primaryPhone") fields("phones[1]",