我可以像这样重构吗,这些是等价的,因此更简单的代码版本是首选吗?
重构前:
if (!matcher.matches() && !matcher2.matches() && !matcher3.matches()
&& !matcher4.matches() && !matcher5.matches()
&& !matcher6.matches() && !matcher7.matches()
&& !matcher8.matches()) {
return true;
} else
return false;
重构后:
return (matcher.matches() || matcher2.matches() || matcher3.matches()
|| matcher4.matches() || matcher5.matches()
|| matcher6.matches() || matcher7.matches()
|| matcher8.matches())