I have the below map of and a string
/**
4->"welcome"
3->"to"
2->"my"
1->"blog"
*/
Map<Integer, String> myMap = ImmutableMap.of(4, "welcome", 3, "to", 2, "my",1,"blog");
String s= "welcome to my blog everyone"
Now I need to poulate the below object list by deleting the words from the string based on the order in decending order(the map is already sorted decending)
{
"level": 1,
"delete":["welcome"],
"modString":"to my blog everyone"
}
{
"level": 2,
"delete":["welcome","to"],
"modString":"my blog everyone"
}
{
"level": 3,
"delete":["welcome","to","my"],
"modString":"blog everyone"
}
{
"level": 4,
"delete":["welcome","to","my","blog"],
"modString":"everyone"
}
The list has the type Delete
public class Delete {
private Integer level;
private String modString;
private List<String> delete;
public Delete(
Integer level,
String modString,
List<String> delete) {
this.level = level;
this.modString = modString;
this.delete = delete;
}
//getters and setters
}
}
I can do it by iterating the map but I was thinking if this can be done using Streams.