本文整理了Java中org.apache.shiro.util.Assert.state()
方法的一些代码示例,展示了Assert.state()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.state()
方法的具体详情如下:
包路径:org.apache.shiro.util.Assert
类名称:Assert
方法名:state
[英]Assert a boolean expression, throwing IllegalStateExceptionif the test result is false
.
Call #isTrue(boolean) if you wish to throw IllegalArgumentException on an assertion failure.
Assert.state(id == null);
[中]断言一个布尔表达式,如果测试结果为false
,则抛出IllegalStateException。
如果希望在断言失败时抛出IllegalArgumentException,请调用#isTrue(布尔值)。
Assert.state(id == null);
代码示例来源:origin: apache/shiro
/**
* Assert a boolean expression, throwing {@link IllegalStateException}
* if the test result is <code>false</code>.
* <p>Call {@link #isTrue(boolean)} if you wish to
* throw {@link IllegalArgumentException} on an assertion failure.
* <pre class="code">Assert.state(id == null);</pre>
* @param expression a boolean expression
* @throws IllegalStateException if the supplied expression is <code>false</code>
*/
public static void state(boolean expression) {
state(expression, "[Assertion failed] - this state invariant must be true");
}
代码示例来源:origin: apache/shiro
@SuppressWarnings({"unchecked"})
public <T> T getBean(String id, Class<T> requiredType) {
if (requiredType == null) {
throw new NullPointerException("requiredType argument cannot be null.");
}
Object bean = getBean(id);
if (bean == null) {
return null;
}
Assert.state(requiredType.isAssignableFrom(bean.getClass()),
"Bean with id [" + id + "] is not of the required type [" + requiredType.getName() + "].");
return (T) bean;
}
代码示例来源:origin: org.apache.shiro/shiro-lang
/**
* Assert a boolean expression, throwing {@link IllegalStateException}
* if the test result is <code>false</code>.
* <p>Call {@link #isTrue(boolean)} if you wish to
* throw {@link IllegalArgumentException} on an assertion failure.
* <pre class="code">Assert.state(id == null);</pre>
* @param expression a boolean expression
* @throws IllegalStateException if the supplied expression is <code>false</code>
*/
public static void state(boolean expression) {
state(expression, "[Assertion failed] - this state invariant must be true");
}
代码示例来源:origin: org.apache.shiro/shiro-config-ogdl
@SuppressWarnings({"unchecked"})
public <T> T getBean(String id, Class<T> requiredType) {
if (requiredType == null) {
throw new NullPointerException("requiredType argument cannot be null.");
}
Object bean = getBean(id);
if (bean == null) {
return null;
}
Assert.state(requiredType.isAssignableFrom(bean.getClass()),
"Bean with id [" + id + "] is not of the required type [" + requiredType.getName() + "].");
return (T) bean;
}
内容来源于网络,如有侵权,请联系作者删除!