Both methods are used to avoid Null Pointer Exception .
GetterUtil internally returns the default type and does the listing too. Therefore, if someone passed a null value, it will return the default value for this type.
Example:
Suppose you have a String value of "true" and you expect it to always be of type boolean . So you are using GetterUtil.getBoolean("true") , which internally casts for boolen and returns the value as boolean-true . If someone skips garbage characters such as "tr" , he will be converted to boolean-false .
As mentioned, ParamUtil does the same processing with request parameters. ParamUtil internally uses GetterUtil to have the above behavior. First, it extracts the parameter (which will always be a string), and then passes it to the GetterUtil.getType() method and, in turn, returns the correct type.
Sandeep nair
source share