I have an application , which operates on the hashmap at stages , in the sense it adds/deletes/modifies keys in different classes . Thought of creating wrapper class by extending the Map class . And Hacking the predefined put and remove methods .
STAGE 1 :
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("Key1","Value1");
hashMap.put("Key2","Value2");
hashMap.put("Key3","Value3");
hashMap.put("Key4", "Value4");
Desired Result :
Added:
Key1 : Value1
Key2 : Value2
Key3 : Value3
Key4 : Value4
STAGE 2:
hashMap.remove("Key1");
Desired Result :
Removed:
Key1 : Value1
STAGE 3:
hashMap.put("Key2", "ChangedValue");
Desired Result :
Modified :
Key2 : ChangedValue
What would be the best way or best logic to get only the diff ? The dataStructure HASHMAP is fixed .