Example usage for org.springframework.util Assert isTrue

List of usage examples for org.springframework.util Assert isTrue

Introduction

In this page you can find the example usage for org.springframework.util Assert isTrue.

Prototype

public static void isTrue(boolean expression, Supplier<String> messageSupplier) 

Source Link

Document

Assert a boolean expression, throwing an IllegalArgumentException if the expression evaluates to false .

Usage

From source file:com.thero.framework.util.AntPathStringMatcher.java

/**
 * Main entry point./*  w w w . java2 s.c o m*/
 *
 * @return <code>true</code> if the string matches against the pattern, or <code>false</code> otherwise.
 */
public boolean matchStrings() {
    Matcher matcher = pattern.matcher(str);
    if (matcher.matches()) {
        if (uriTemplateVariables != null) {
            // SPR-8455
            Assert.isTrue(variableNames.size() == matcher.groupCount(),
                    "The number of capturing groups in the pattern segment " + pattern
                            + " does not match the number of URI template variables it defines, which can occur if "
                            + " capturing groups are used in a URI template regex. Use non-capturing groups instead.");
            for (int i = 1; i <= matcher.groupCount(); i++) {
                String name = this.variableNames.get(i - 1);
                String value = matcher.group(i);
                uriTemplateVariables.put(name, value);
            }
        }
        return true;
    } else {
        return false;
    }
}

From source file:pt.webdetails.browserid.spring.BrowserIdProcessingFilter.java

@Override
public void afterPropertiesSet() throws Exception {
    super.afterPropertiesSet();
    //request parameters
    Assert.hasLength(getAssertionParameterName(), "assertionParameterName cannot be empty.");
    //    Assert.hasLength(getAudienceParameterName(), "audienceParameterName cannot be empty.");

    //check URL/*from   w  w w  . jav a2  s.c  o m*/
    Assert.hasLength(getVerificationServiceUrl());
    try {
        HttpHost host = new HttpHost(new URI(getVerificationServiceUrl(), false));
        Assert.isTrue(host.getProtocol().isSecure(), "verificationServiceUrl does not use a secure protocol");
    } catch (URIException e) {
        throw new IllegalArgumentException("verificationServiceUrl is not a valid URI", e);
    }
}