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:fr.mby.portal.coreimpl.session.BasicSession.java

@Override
public void setAttribute(final String name, final Object value) throws IllegalArgumentException {
    Assert.hasText(name, "No property name provided !");

    this.session.put(name, value);
}

From source file:com.afeng.common.dao.orm.HibernateWebUtils.java

/**
 * ?ID?,???./*ww w  .  j  av  a2 s .co m*/
 * <p/>
 * ??????id,??????id?????.
 * ???id??,??id??.
 * ?ID, ??cascade-save-or-update.
 *
 * @param srcObjects ??,.
 * @param checkedIds ?,ID.
 * @param clazz      ?
 * @param idName     ??
 */
public static <T, ID> void mergeByCheckedIds(final Collection<T> srcObjects, final Collection<ID> checkedIds,
        final Class<T> clazz, final String idName) {

    //?
    Assert.notNull(srcObjects, "scrObjects?");
    Assert.hasText(idName, "idName?");
    Assert.notNull(clazz, "clazz?");

    //?,???.
    if (checkedIds == null) {
        srcObjects.clear();
        return;
    }

    //????,id?ID?,.
    //?,???id,?id???id.
    Iterator<T> srcIterator = srcObjects.iterator();
    try {

        while (srcIterator.hasNext()) {
            T element = srcIterator.next();
            Object id;
            id = PropertyUtils.getProperty(element, idName);

            if (!checkedIds.contains(id)) {
                srcIterator.remove();
            } else {
                checkedIds.remove(id);
            }
        }

        //ID??id????,,id??.
        for (ID id : checkedIds) {
            T obj = clazz.newInstance();
            PropertyUtils.setProperty(obj, idName, id);
            srcObjects.add(obj);
        }
    } catch (Exception e) {
        throw ReflectionUtils.convertReflectionExceptionToUnchecked(e);
    }
}

From source file:org.cleverbus.core.alerts.AlertsJdbcDao.java

@Override
public long runQuery(String sql) {
    Assert.hasText(sql, "the sql must not be empty");

    return template.queryForObject(sql, Long.class);
}

From source file:oz.hadoop.yarn.api.core.CommandProcessLauncher.java

/**
 * //from w ww .java  2 s  .com
 * @param command
 * @param containerLivelinesBarrier
 */
public CommandProcessLauncher(String command) {
    super();
    Assert.hasText(command, "'command' must not be null or empty");
    this.command = command;
    this.streamsFinished = new AtomicInteger();
}

From source file:org.springdata.ehcache.config.CacheManagerFactoryBean.java

@Override
public void afterPropertiesSet() throws FileNotFoundException {

    Assert.hasText(configFile, "configFile property must be set");

    if (StringUtils.hasText(terracottaLicenseFile)) {
        System.getProperties().setProperty("com.tc.productkey.path", terracottaLicenseFile);
    }/*from   w  w w  .  j ava 2 s. c  o  m*/

    logger.info("Initializing ehcache ...");
    cacheManager = new CacheManager(configFile);

}

From source file:sipackage.core.SIAdapterUpperPrefixExecutor.java

/**
 * Verifies and sets the parameters. E.g. initializes the to be used
 *///  ww w  .  j  a  va 2s . c  om
public void afterPropertiesSet() {
    Assert.hasText(this.exampleProperty, "exampleProperty must not be empty.");
}

From source file:fr.mby.portal.core.auth.PortalUserAuthentication.java

/**
 * Normal constructor of PortalUserAuthentication.
 * // ww w  . j  a  v  a2s  .c  o  m
 * @param principal
 * @param credentials
 */
public PortalUserAuthentication(final String username, final String password) {
    super();

    Assert.hasText(username, "No username supplied !");
    Assert.hasText(password, "No password supplied !");

    this.principal = new PortalUserPrincipal(username);
    this.credentials = password;
    this.authenticated = false;
}

From source file:org.zalando.crypto.spring.EncryptableProperties.java

public EncryptableProperties(final Properties defaults, final Decrypter decrypter, final String cryptoPrefix) {
    super(defaults);
    Assert.notNull(decrypter, "'decrypter' should never null.");
    Assert.hasText(cryptoPrefix, "'cryptoPrefix' should never be null or empty.");
    this.decrypter = decrypter;
    this.cryptoPrefix = cryptoPrefix;
}

From source file:cat.albirar.framework.sets.registry.impl.NamedSetDefaultImpl.java

/**
 * Constructor.//from w  w w . ja va 2s.  c  om
 * @param modelRoot
 * @param name The name for this set
 */
public NamedSetDefaultImpl(Class<? extends T> modelRoot, String name) {
    super(modelRoot);
    Assert.hasText(name, "The name is a required argument, cannot be null, nor empty nor whitespace!");
    this.name = name;
}

From source file:example.app.model.Person.java

public static Person newPerson(String firstName, String lastName) {
    Assert.hasText(firstName, "firstName is required");
    Assert.hasText(lastName, "lastName is required");

    Person person = new Person();

    person.setFirstName(firstName);/*from  w  w  w . j  a  v  a  2 s  . co m*/
    person.setLastName(lastName);

    return person;
}