How to use @EqualsAndHashCode With Include - Lombok

前端 未结 3 1352
Happy的楠姐
Happy的楠姐 2021-02-19 02:42

How to use @EqualsAndHashCode With Include, Lombok library for Java.

@EqualsAndHashCode.Include( )

How to make Equal

3条回答
  •  伪装坚强ぢ
    2021-02-19 03:20

    The Include annotation is used on the member(s) you want to include in the equals and hashCode methods. If you want to specify exactly which members should be used (instead of the default of all non-static non-transient members), you could use the onlyExplicitlyIncluded = true option in the @EqualsAndHashCode annotation:

    @EqualsAndHashCode(onlyExplicitlyIncluded = true)
    @Table(name = "USER")
    public class User
    {
    
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name = "IDENTITY_USER")
      @EqualsAndHashCode.Include
      private Long identity;
    }
    

提交回复
热议问题