Created
December 12, 2019 02:41
-
-
Save upangka/782e1524f942e4bfa31f924941a30c55 to your computer and use it in GitHub Desktop.
spring BeanUtils 对lombok @builder操作
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.vpu.mp.service.pojo.shop.member.ucard; | |
import javax.validation.constraints.NotNull; | |
import lombok.Builder; | |
import lombok.Data; | |
@Data | |
@Builder | |
public class ActivateCardParam { | |
@NotNull | |
private String cardNo; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.vpu.mp.controller.admin.member; | |
import org.springframework.beans.BeanUtils; | |
import com.vpu.mp.service.pojo.shop.member.ucard.ActivateCardParam; | |
import com.vpu.mp.service.pojo.shop.member.ucard.ReceiveCardParam; | |
public class Main { | |
public static void main(String ...args) { | |
System.out.println("Hello World"); | |
ReceiveCardParam source = new ReceiveCardParam(); | |
source.setCardNo("123456"); | |
System.out.println(source); | |
ActivateCardParam target = ActivateCardParam.builder().build(); | |
System.out.println(target); | |
BeanUtils.copyProperties(source, target); | |
System.out.println(target); | |
} | |
} | |
/** | |
Hello World | |
ReceiveCardParam(cardId=null, cardNo=123456, cardPwd=null, code=null, userId=null) | |
ActivateCardParam(cardNo=null) | |
ActivateCardParam(cardNo=123456) | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.vpu.mp.service.pojo.shop.member.ucard; | |
import javax.validation.constraints.NotNull; | |
import lombok.Data; | |
@Data | |
public class ReceiveCardParam { | |
@NotNull | |
private Integer cardId; | |
private String cardNo; | |
private String cardPwd; | |
private String code; | |
private Integer userId; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment