what's the difference between resource.adaptTo(ValueMap.class) and resource.getValueMap()?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @Keerthi0555,
The main difference is that adaptTo can return null, so you will have to make sure to implement some null check while using it, to avoid NPE.
getValueMap() method is null safe and will return empty ValueMap in worst case.
In terms of getting ValueMap, you can also check ResourceUtil.getValueMap(resource) that will return empty ValueMap even in the scenario when give resource is null.
Some links for reference:
Hi @Keerthi0555,
The main difference is that adaptTo can return null, so you will have to make sure to implement some null check while using it, to avoid NPE.
getValueMap() method is null safe and will return empty ValueMap in worst case.
In terms of getting ValueMap, you can also check ResourceUtil.getValueMap(resource) that will return empty ValueMap even in the scenario when give resource is null.
Some links for reference:
Thank you .
Views
Likes
Replies