what's the difference between resource.adaptTo(ValueMap.class) and resource.getValueMap()?
what's the difference between resource.adaptTo(ValueMap.class) and resource.getValueMap()?
what's the difference between resource.adaptTo(ValueMap.class) and resource.getValueMap()?
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:
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.