lombok 注解

lombok常用注解

  1. @Getter @Setter @Builder @NoArgsConstructor @AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
@AllArgsConstructor
@Builder
public class GamesInfo {

    @NotBlank(message = "userId can not be blank")
    private String userId;

    @NotBlank(message = "mobile can not be blank")
    private String mobile;

    @NotBlank(message = "activityId can not be blank")
    private String activityId;

    private int players;
    @NotBlank(message = "stub can not be blank")
    private String stub;

    private boolean activityStatus;

    @JsonIgnore
    @NotBlank(message = "stub can not be blank")
    private String score;

    @JsonIgnore
    @NotBlank(message = "maxScore can not be blank")
    private String maxScore;
    }

 1. @Getter 注解和@Setter 放在类上 ,省去当前类为每个属性写get方法和set方法
 2. @NoArgsConstructor  省去写类的无参构造方法
 3. @AllArgsConstructor  类的全参构造方法
 4. @Builder  提供创建类对象的builder方法,可以通过 GamesInfo.builder().userId("2").build();方式创建
 5. @JsonIgnore 注解放在属性方法上,该字段在返回给前端时,json串中不会出现该字段
 6. @NotBlank(message = "maxScore can not be blank") 放在类属性上,在请求校验对象属性时使用,与注解@RequestBody @Validated GamesInfo gamesInfo 配好使用
 7. @Data 注解也是提供get、set方法
 8. @Slf4j 提供日志类方法

       
       

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值