[英]Is there any boolean true or throw error helper method in java
In Java 8+, is there any helper method which checks if boolean statement is TRUE, ok, otherwise, throw specified error.在 Java 8+ 中,是否有任何辅助方法检查 boolean 语句是否为 TRUE,好的,否则,抛出指定的错误。
Something like:就像是:
Optional.of(myFalseReturningMethod).orElseThrow(() -> new ValidationException("Check request"));
What's wrong with:有什么问题:
if (!myFalseReturningMethod) throw new ValidationException("Check request");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.