How to Delete Duplicates From an ArrayList of Type Pojo/DTO

Recently, in my current project, I got a requirement where I had to delete duplicates from anArrayList of type Pojo. I did a lot of research and found all the examples referring to an ArrayList of type String and where is easy to remove duplicates. However, the real world is always different!

Here is code to delete duplicates from an ArrayList based on two fields Material Type (matnrType) and Supplier (supplier).