本文整理了Java中com.stormpath.sdk.lang.Assert.isTrue()
方法的一些代码示例,展示了Assert.isTrue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.isTrue()
方法的具体详情如下:
包路径:com.stormpath.sdk.lang.Assert
类名称:Assert
方法名:isTrue
[英]Assert a boolean expression, throwing IllegalArgumentException
if the test result is false
.
Assert.isTrue(i > 0);
[中]断言一个布尔表达式,如果测试结果为false
,则抛出IllegalArgumentException
Assert.isTrue(i > 0);
代码示例来源:origin: stormpath/stormpath-sdk-java
/**
* Assert a boolean expression, throwing <code>IllegalArgumentException</code>
* if the test result is <code>false</code>.
* <pre class="code">Assert.isTrue(i > 0);</pre>
* @param expression a boolean expression
* @throws IllegalArgumentException if expression is <code>false</code>
*/
public static void isTrue(boolean expression) {
isTrue(expression, "[Assertion failed] - this expression must be true");
}
代码示例来源:origin: stormpath/stormpath-sdk-java
public Map<String, String> createReference(Map map) {
Assert.isTrue(!map.isEmpty() && map.containsKey(AbstractResource.HREF_PROP_NAME),
"Reference resource must have an 'href' property.");
String href = String.valueOf(map.get(AbstractResource.HREF_PROP_NAME));
Map<String, String> reference = new HashMap<>(1);
reference.put(AbstractResource.HREF_PROP_NAME, href);
return reference;
}
代码示例来源:origin: com.stormpath.sdk/stormpath-sdk-impl
public Map<String, String> createReference(String resourceName, Map map) {
Assert.isTrue(!map.isEmpty() && map.containsKey(AbstractResource.HREF_PROP_NAME),
"'" + resourceName + "' resource must have an 'href' property.");
String href = String.valueOf(map.get(AbstractResource.HREF_PROP_NAME));
Map<String, String> reference = new HashMap<>(1);
reference.put(AbstractResource.HREF_PROP_NAME, href);
return reference;
}
代码示例来源:origin: stormpath/stormpath-sdk-java
@Override
public PasswordStrength setMinLength(int minLength) {
Assert.isTrue(minLength > 0 && minLength <= 1024, "minLength cannot be less than 1 or larger than 1024.");
setProperty(MIN_LENGTH, minLength);
return this;
}
代码示例来源:origin: stormpath/stormpath-sdk-java
@Override
public PasswordStrength setMinLowerCase(int minLowerCase) {
Assert.isTrue(minLowerCase >= 0, "minLowerCase cannot be a negative number.");
setProperty(MIN_LOWERCASE, minLowerCase);
return this;
}
代码示例来源:origin: com.stormpath.sdk/stormpath-sdk-impl
@Override
public PasswordPolicy setResetTokenTtlHours(int resetTokenTtl) {
Assert.isTrue(resetTokenTtl > 0, "resetTokenTtl must be a positive integer.");
setProperty(RESET_TOKEN_TTL, resetTokenTtl);
return this;
}
代码示例来源:origin: com.stormpath.sdk/stormpath-sdk-impl
@Override
public PasswordStrength setMinDiacritic(int minDiacritic) {
Assert.isTrue(minDiacritic >= 0, "minDiacritic cannot be a negative number.");
setProperty(MIN_DIACRITIC, minDiacritic);
return this;
}
代码示例来源:origin: com.stormpath.sdk/stormpath-sdk-impl
@Override
public PasswordStrength setMinLength(int minLength) {
Assert.isTrue(minLength > 0 && minLength <= 1024, "minLength cannot be less than 1 or larger than 1024.");
setProperty(MIN_LENGTH, minLength);
return this;
}
代码示例来源:origin: com.stormpath.sdk/stormpath-sdk-impl
@Override
public ClientBuilder setConnectionTimeout(int timeout) {
Assert.isTrue(timeout >= 0, "Timeout cannot be a negative number.");
this.clientConfig.setConnectionTimeout(timeout);
return this;
}
代码示例来源:origin: stormpath/stormpath-sdk-java
@Override
public PasswordPolicy setResetTokenTtlHours(int resetTokenTtl) {
Assert.isTrue(resetTokenTtl > 0, "resetTokenTtl must be a positive integer.");
setProperty(RESET_TOKEN_TTL, resetTokenTtl);
return this;
}
代码示例来源:origin: com.stormpath.sdk/stormpath-sdk-impl
@Override
public PasswordStrength setMinNumeric(int minNumeric) {
Assert.isTrue(minNumeric >= 0, "minNumeric cannot be a negative number.");
setProperty(MIN_NUMERIC, minNumeric);
return this;
}
代码示例来源:origin: stormpath/stormpath-sdk-java
protected static void assertTtl(Duration ttl) throws IllegalArgumentException {
if (ttl != null) {
Assert.isTrue(ttl.getValue() > 0, "timeToLive duration must be greater than zero");
}
}
代码示例来源:origin: com.stormpath.sdk/stormpath-sdk-impl
@Override
public Criterion in(Date begin, Date end) {
Assert.notNull(begin, "begin needs to be a valid Date object");
Assert.notNull(end, "end needs to be a valid Date object");
Assert.isTrue(begin.before(end), "begin date needs to be earlier than end date");
DateTime beginDateTime = new DateTime(begin);
DateTime endDateTime = new DateTime(end);
String value = INCLUSIVE_OPENING + beginDateTime.toString() + COMMA + endDateTime.toString() + EXCLUSIVE_CLOSING;
return new SimpleExpression(propertyName, value, Operator.EQUALS);
}
代码示例来源:origin: stormpath/stormpath-sdk-java
public CollectionExpansion(String name, int limit, int offset) {
super(name);
Assert.isTrue(limit > 0 || offset > 0, "Either a limit or offset (or both) must be specified.");
this.limit = Pagination.sanitizeLimit(limit);
this.offset = Pagination.sanitizeOffset(offset);
}
代码示例来源:origin: com.stormpath.sdk/stormpath-sdk-impl
public CollectionExpansion(String name, int limit, int offset) {
super(name);
Assert.isTrue(limit > 0 || offset > 0, "Either a limit or offset (or both) must be specified.");
this.limit = Pagination.sanitizeLimit(limit);
this.offset = Pagination.sanitizeOffset(offset);
}
代码示例来源:origin: stormpath/stormpath-sdk-java
@Override
public String decryptBase64String(String base64EncryptedValue) {
Assert.hasText(base64EncryptedValue);
Assert.isTrue(Base64.isBase64(base64EncryptedValue.getBytes()), "encryptedValue argument must be Base64.");
byte[] encryptedValue = Base64.decodeBase64(base64EncryptedValue);
return new String(decrypt(encryptedValue), UTF_8);
}
代码示例来源:origin: stormpath/stormpath-sdk-java
@SuppressWarnings("unchecked")
public AuthenticationRequest createTokenRequest(HttpRequest request) {
Assert.isTrue(Classes.isAvailable(BASIC_OAUTH_REQUEST_FQCN), OAUTH_REQUEST_NOT_AVAILABLE_MSG);
Class<AuthenticationRequest> clazz = Classes.forName(BASIC_OAUTH_REQUEST_FQCN);
Constructor<AuthenticationRequest> constructor = Classes.getConstructor(clazz, HttpRequest.class);
return instantiate(constructor, request);
}
代码示例来源:origin: stormpath/stormpath-sdk-java
@Override
public void save() {
Assert.isTrue(getMaxLength() >= getMinLength(), "minLength cannot be greater than maxLength.");
Assert.isTrue(getMinSymbol() + getMinDiacritic() + getMinUpperCase() + getMinLowerCase() + getMinNumeric() <= getMaxLength(), "maxLength is not large enough to hold all the minimum conditions specified.");
super.save();
}
}
代码示例来源:origin: com.stormpath.sdk/stormpath-sdk-servlet
@Override
public Filter build() throws ServletException {
Assert.isTrue(this.instance != null || this.filterClass != null,
"Either a filter instance or a filterClass must be specified.");
Assert.notNull(this.servletContext, "servletContext must be specified.");
Assert.notNull(this.name, "A non-null/non-empty name must be specified.");
Filter filter = instance != null ? instance : Classes.newInstance(this.filterClass);
FilterConfig filterConfig = new DefaultFilterConfig(this.servletContext, this.name, this.initParams);
filter.init(filterConfig);
return filter;
}
}
代码示例来源:origin: com.stormpath.sdk/stormpath-sdk-servlet
void validateCsrfToken(HttpServletRequest request, HttpServletResponse response, Form form) throws IllegalArgumentException {
if (isCsrfProtectionEnabled() && !isJsonPreferred(request, response)) {
String csrfToken = form.getFieldValue(csrfTokenManager.getTokenName());
Assert.isTrue(csrfTokenManager.isValidCsrfToken(request, response, csrfToken), "Invalid CSRF token");
form.getField(csrfTokenManager.getTokenName()).setValue(csrfTokenManager.createCsrfToken(request, response));
}
}
内容来源于网络,如有侵权,请联系作者删除!