Skip to content

Instantly share code, notes, and snippets.

@sutra
Created December 30, 2020 06:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sutra/84c31ed063c7d7e31174302e05771fd5 to your computer and use it in GitHub Desktop.
Save sutra/84c31ed063c7d7e31174302e05771fd5 to your computer and use it in GitHub Desktop.
private boolean isValid(String param) {
return param != null && (param.equals("0") || param.equals("1"));
}
private boolean isValid(String... params) {
for (String param : params) {
if (!isValid(param)) {
return false;
}
}
return true;
}
public void hello(String open, String w1, String w2, String w3, String w4, String w5, String w6, String w7) {
if (!isValid(open, w1, w2, w3, w4, w5, w6, w7)) {
throw new IllegalArgumentException("设置项目参数非法!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment