Skip to content

Instantly share code, notes, and snippets.

@karthiks
Created October 24, 2024 10:00
Show Gist options
  • Save karthiks/5f654524046cfe78facb8722d6c3ce5a to your computer and use it in GitHub Desktop.
Save karthiks/5f654524046cfe78facb8722d6c3ce5a to your computer and use it in GitHub Desktop.
Person and Address class with equal() and hashCode() generated using Lombok utility library
import lombok.Data;
@Data // Generates getters for all fields, a useful toString method, and hashCode and equals implementations that checkall non-transient fields. Will also generate setters for all non-final fields, as well as a constructor.
// @Data = @Getter + @Setter + @RequiredArgsConstructor + @ToString + @EqualsAndHashCode
public class Person {
private Long id;
private String name;
}
@Data
class Address {
private String road;
private String city;
private String pincode;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment