Example usage for org.springframework.util Assert hasLength

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

Introduction

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

Prototype

public static void hasLength(@Nullable String text, Supplier<String> messageSupplier) 

Source Link

Document

Assert that the given String is not empty; that is, it must not be null and not the empty String.

Usage

From source file:org.jdbcluster.clustertype.ClusterTypeFactory.java

/**
 * creates ClusterType objects depending on the ClusterType name which is passed as
 * an argument//  ww w  . j  a va 2 s  . c  o m
 * @param <T> is a template which extends the interface ClusterType
 * @param clusterTypeName the ClusterType's name as a String
 * @return clusterType the ClusterType object
 * @throws ClusterTypeException
 */
@SuppressWarnings("unchecked")
static public <T extends ClusterType> T newInstance(String clusterTypeName) throws ClusterTypeException {

    Assert.notNull(clusterTypeName, "clusterTypeName  may not be null");
    Assert.hasLength(clusterTypeName, "clusterTypeName  may not have zero length");

    //get the classname of the object
    String className = ClusterTypeBase.getClusterTypeConfig().getClusterClassName(clusterTypeName);
    //if no name was defined, throw an exception
    if (className == null) {
        throw new ClusterTypeException("No ClusterType of type " + clusterTypeName + " found!",
                new Throwable());
    }

    ClusterTypeBase clusterType = new ClusterTypeImpl();

    //save the name
    clusterType.setName(clusterTypeName);
    return (T) clusterType;
}

From source file:com.frank.search.solr.core.query.result.SimpleGroupResult.java

public SimpleGroupResult(int matches, Integer groupsCount, String name, Page<GroupEntry<T>> groupEntries) {
    Assert.isTrue(matches >= 0, "matches must be >= 0");
    Assert.hasLength(name, "group result name must be not empty");
    Assert.notNull(groupEntries, "groupEntries must be not null");
    this.matches = matches;
    this.groupsCount = groupsCount;
    this.name = name;
    this.groupEntries = groupEntries;
}

From source file:grails.plugin.springsecurity.web.authentication.FilterProcessUrlRequestMatcher.java

public FilterProcessUrlRequestMatcher(String filterProcessesUrl) {
    Assert.hasLength(filterProcessesUrl, "filterProcessesUrl must be specified");
    Assert.isTrue(UrlUtils.isValidRedirectUrl(filterProcessesUrl),
            filterProcessesUrl + " isn't a valid redirect URL");
    this.filterProcessesUrl = filterProcessesUrl;
}

From source file:org.mitre.openid.connect.filter.MultiUrlRequestMatcher.java

public MultiUrlRequestMatcher(Set<String> filterProcessesUrls) {
    for (String filterProcessesUrl : filterProcessesUrls) {
        Assert.hasLength(filterProcessesUrl, "filterProcessesUrl must be specified");
        Assert.isTrue(UrlUtils.isValidRedirectUrl(filterProcessesUrl),
                filterProcessesUrl + " isn't a valid redirect URL");
    }/*from ww  w. ja v  a  2s  .c  o  m*/
    this.filterProcessesUrls = ImmutableSet.copyOf(filterProcessesUrls);
}

From source file:org.mule.module.spel.ExpressionFactory.java

public Expression create(String expression) {
    Assert.hasLength(expression, "Expression cannot be null or empty");

    Expression exp = expressions.get(expression);
    if (exp == null) {
        exp = PARSER.parseExpression(expression);
        expressions.put(expression, exp);
    }//www.j ava2s .c  o  m

    return exp;
}

From source file:org.codehaus.groovy.grails.scaffolding.view.ScaffoldedGroovyPageView.java

public ScaffoldedGroovyPageView(String uri, String contents) {
    Assert.hasLength(contents, "Argument [contents] cannot be blank or null");
    Assert.hasLength(uri, "Argument [uri] cannot be blank or null");

    this.contents = contents;
    setUrl(uri);/*from   w w  w. ja  v  a2s. co m*/
}

From source file:org.vbossica.azurebox.storage.CloudStorageAccountFactoryBean.java

@Override
public void afterPropertiesSet() throws Exception {
    Assert.hasLength(protocol, "protocol must be set!");
    Assert.hasLength(account, "account must be set");
    Assert.hasLength(accountKey, "accountKey must be set");
}

From source file:nl.surfnet.coin.api.saml.SAMLProvisioner.java

@Override
public UserDetails provisionUser(Assertion assertion) {
    String userId = getValueFromAttributeStatements(assertion, uuidAttribute);
    Assert.hasLength(userId, "SAML assertion does not contain required personId (" + uuidAttribute + ")");
    return new User(userId, "N/A", Collections.singletonList(new SimpleAuthority("USER")));
}

From source file:jails.http.client.support.ProxyFactoryBean.java

public void afterPropertiesSet() throws IllegalArgumentException {
    Assert.notNull(type, "'type' must not be null");
    Assert.hasLength(hostname, "'hostname' must not be empty");
    Assert.isTrue(port >= 0 && port <= 65535, "'port' out of range: " + port);

    SocketAddress socketAddress = new InetSocketAddress(hostname, port);
    this.proxy = new Proxy(type, socketAddress);

}