Example usage for org.springframework.util Assert hasText

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

Introduction

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

Prototype

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

Source Link

Document

Assert that the given String contains valid text content; that is, it must not be null and must contain at least one non-whitespace character.

Usage

From source file:org.synyx.hades.dao.query.QueryUtils.java

/**
 * Returns the query string for the given class name.
 * /*from  w  w w  . ja  v a2 s .  c o m*/
 * @param template
 * @param clazzName
 * @return
 */
public static String getQueryString(String template, String clazzName) {

    Assert.hasText(clazzName, "Classname must not be null or empty!");

    return String.format(template, clazzName);
}

From source file:lab.mage.spring.cassandra.connector.core.CassandraSessionProvider.java

public void setAdminClusterName(@Nonnull final String adminClusterName) {
    Assert.notNull(adminClusterName, "A cluster name must be given!");
    Assert.hasText(adminClusterName, "A cluster name must be given!");
    this.adminClusterName = adminClusterName;
}

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

/**
 * Adds a facet on field to the statistics to be requested.
 * //from  www .j  a v a  2s . com
 * @param fieldName
 * @return
 */
public StatsOptions addFacet(String fieldName) {

    Assert.hasText(fieldName, "Fieldname for facet statistics must not be blank.");

    return addFacet(new SimpleField(fieldName));
}

From source file:org.cleverbus.core.common.contextcall.ContextCallRegistryMemoryImpl.java

@Override
public void addResponse(String callId, Object res) {
    Assert.hasText(callId, "the callId must not be empty");
    Assert.notNull(res, "the res must not be null");

    if (responseRegistry.get(callId) != null) {
        throw new IllegalStateException("there is already call response with call ID = " + callId);
    }/* ww  w.ja v a 2s  . co m*/

    responseRegistry.put(callId, res);

    Log.debug("Call response with callId=" + callId + " added to registry: " + res);
}

From source file:ReflectionUtils.java

/**
 * ,DeclaredField./*  w ww .  ja v a2 s. c  o m*/
 */
protected static Field getDeclaredField(final Object object, final String fieldName) {
    Assert.notNull(object, "object");
    Assert.hasText(fieldName, "fieldName");
    for (Class<?> superClass = object.getClass(); superClass != Object.class; superClass = superClass
            .getSuperclass()) {
        // System.out.println("class:" + superClass);
        try {
            return superClass.getDeclaredField(fieldName);
        } catch (NoSuchFieldException e) {
            // Field,
            // e.printStackTrace();
            // continue;
        }
    }
    return null;
}

From source file:se.vgregion.urlservice.stats.piwik.DefaultPiwikClient.java

public void track(String url, String referrer, String title, String userAgent) {
    Assert.hasText(url, "url must be provided");
    Assert.hasText(referrer, "referrer must be provided");
    Assert.hasText(title, "title must be provided");

    Hit hit = new Hit(url, referrer, title, userAgent);

    // offer this hit to the queue, should the queue be full, 
    // this hit will be dropped. This is as not to flood the queue
    // in the case of much traffic. Handling redirects are more important
    // than the stats
    hits.offer(hit);//ww  w .j  av  a 2s  .c o  m
}

From source file:io.pivotal.receptor.events.EventDispatcher.java

public EventDispatcher(String url) {
    Assert.hasText(url, "URL is required");
    this.url = url;
    this.backgroundExecutor = Executors
            .newSingleThreadExecutor(new CustomizableThreadFactory("receptor-event-subscriber-"));
    this.dispatchingExecutor = Executors
            .newCachedThreadPool(new CustomizableThreadFactory("receptor-event-dispatcher-"));
}

From source file:biz.c24.io.spring.integration.config.XPathSelectorParser.java

@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {

    String evaluationType = element.getAttribute("evaluation-result-type");

    String expression = element.getAttribute("xpath-statement");
    String expressionRef = element.getAttribute("xpath-statement-ref");

    boolean hasRef = StringUtils.hasText(expressionRef);
    Assert.isTrue(hasRef ^ StringUtils.hasText(expression),
            "Exactly one of the 'xpath-statement' or 'xpath-statement-ref' attributes is required.");
    if (hasRef) {
        builder.addConstructorArgReference(expressionRef);
    } else {/*from  w ww .  j  a v  a  2  s . c om*/
        builder.addConstructorArgValue(expression);
    }

    String stringTestValue = element.getAttribute("string-test-value");

    if (evaluationType.equals("boolean")) {
        builder.getBeanDefinition()
                .setBeanClass(biz.c24.io.spring.integration.selector.C24BooleanTestXPathMessageSelector.class);
        Assert.state(!StringUtils.hasText(stringTestValue),
                "'string-test-value' should not be specified when 'evaluation-result-type' is boolean");
    } else if (evaluationType.equals("string")) {
        Assert.hasText(stringTestValue,
                "'string-test-value' must be specified when 'evaluation-result-type' is string");
        builder.addPropertyValue("valueToTestFor", stringTestValue);
        builder.getBeanDefinition().setBeanClass(
                biz.c24.io.spring.integration.selector.C24StringValueTestXPathMessageSelector.class);
    } else {
        throw new IllegalArgumentException("Unsupported value [" + evaluationType
                + "] for 'evaluation-result-type', expected boolean or string.");
    }
}

From source file:org.openwms.core.uaa.Email.java

/**
 * Create a new {@code Email} with an {@code username} and an {@code emailAddress}.
 *
 * @param username The name of the User//from  w w  w .  j a  va  2 s  .  c  o m
 * @param emailAddress The email address of the User
 * @throws IllegalArgumentException when userName or emailAddress is {@literal null} or empty
 */
public Email(String username, String emailAddress) {
    Assert.hasText(username, "Username must not be null or empty");
    Assert.hasText(emailAddress, "EmailAddress must not be null or empty");
    this.username = username;
    this.emailAddress = emailAddress;
}