Is there a way to reduce this lengthy if
condition:
if(
statusCode.equals( NO_ERRORS_NO_WARNINGS ) ||
statusCode.equals( HAS_ERRORS_NO_WARNINGS ) ||
statusCode.equals( HAS_ERRORS_HAS_WARNINGS ) ||
statusCode.equals( NO_ERRORS_HAS_WARNINGS )
){
//do something
}
The purpose of it is to see if there is a status code set within a log file. So the String statusCode
could be a null value, one of the 4 status codes above or an unpredicatable String
.
statusCode
may be null...have you null checked before this statement? \$\endgroup\$HAS_ERRORS_HAS_WARNINGS
in there twice? It looks like thatstatusCode
holds teh state of two boolean flag ("errors" and "warning"). It may make sense to create to boolean fields (or atleast temporary variables) to hold the two boolean flags. \$\endgroup\$