New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch: Clean up logic #513
Comments
-1 |
it's a harmless change that tests for object equality and then if objects don't equal check for String representation equality. Plus it cleans up a mess of ==null != null logic. Current code: if ((caseComponent.getValue() == null && this.getValue() != null)
|| (this.getValue() == null && caseComponent.getValue() != null)) {
continue;
}
if ((caseComponent.getValue() == null && this.getValue() == null)
|| caseComponent.getValue().equals(this.getValue())) {
caseToRender = caseComponent;
// mustn't break, because need to set rendered=false to other cases (e.g. for visitTree correctness)
} New code (cleaner and catches this enum case): Object evaluate = this.getValue();
Object caseValue = caseComponent.getValue();
if (ObjectUtils.equals(evaluate, caseValue)
|| StringUtils.equalsIgnoreCase(String.valueOf(evaluate), String.valueOf(caseValue))) {
caseToRender = caseComponent;
// must not break, because need to set rendered=false to other cases (e.g. for visitTree correctness)
} |
I wouldnt do it personally. A string is not a enum, i introduced importEnum long time ago for this cases. |
OK I can live with that. I switched it to just this which does exactly the same as the original code with 1 line of code and not confusing "continue" statement etc. final Object evaluate = this.getValue();
final Object caseValue = caseComponent.getValue();
// TODO: switch this to Objects.equals in Java7
if (ObjectUtils.equals(evaluate, caseValue))) {
caseToRender = caseComponent;
} |
Reported on the forums: https://forum.primefaces.org/viewtopic.php?f=14&t=39806
The text was updated successfully, but these errors were encountered: