There is a method I am writing to validate a response.
validateAccount(myRequest.getCustody(), errors);
private void validateAccount(Custody custody, Errors errors) {
if (null != custody.getCustodyNumber() && StringUtils.isNotBlank(custody.getCustodyNumber().trim())
&& null == custody.getPensionCustody()) {
errors.rejectValue(PAYLOAD_PENSION_CUSTODY, ERR04, ERR04_PENSION_CUSTODY);
}
if (null != custody.getPensionCustody() && custody.getPensionCustody()
&& StringUtils.isBlank(custody.getCommonAccountNumber())) {
errors.rejectValue(PAYLOAD_COMMON_ACCOUNT_NUMBER, ERR003, ERR003_COMMON_ACCOUNT_NUMBER);
}
}
So can we make the validateAccount() method STATIC in this case as object is passed to it being updated there itself in the method. What should be the solution for it for thread safety. Sonar says it should be STATIC but if the object passed in parameter is being updated will it be safe? I am aware that parameter passed should not be updated inside the method, but what is the best solution in this case?