Click here to Skip to main content
15,615,466 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Have a map<String, Object>, in object I have 10 variables, I want to extract only one variable with its value too?

map is something like :
data = hashmap
 > fire -> (BasicClassName)
   > key -> "contents"
   > value -> (BasicClassName)
     > limit= "80"
     > category = "Standard"
     >details ="details"
   <pre>> key -> "temp"
   > value -> (BasicClassName)
     > limit= "80"
     > category = "Standard"
     >details ="details"

I want to filter only key contents and out of values want only limit as object in map.

What I have tried:

I tried :

 .filter(map -> map.getKey().equals("contents"))
                                .collect(Collectors.toMap(map -> map.getKey(), map -> new BasicClassName().setLimit((BasicClassName)map.getValue()).getLimit())));
Updated 27-Jul-22 1:58am
Richard MacCutchan 27-Jul-22 10:07am    
You forgot to explain what the problem is with the above code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900