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:com.framework.infrastructure.utils.HibernateUtils.java

/**
 * ID,.//from w  ww . j  a  va 2  s  . c  o m
 * 
 * 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;
    }

    // ,idID,.
    // ,id,idid.
    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);
            }
        }

        // IDid,,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.opencredo.cloud.storage.si.filter.internal.PatternMatchingBlobNameFilter.java

/**
 * @param pattern//w  ww. j a  va2 s.  c  o m
 */
public PatternMatchingBlobNameFilter(String regex) {
    Assert.hasText(regex, "'regex' must not be null");
    this.pattern = Pattern.compile(regex);
}

From source file:com.acme.PayloadValueCounterHandler.java

public PayloadValueCounterHandler(FieldValueCounterRepository fieldValueCounterRepository, String name) {
    Assert.hasText(name, "must have a name");
    Assert.notNull(fieldValueCounterRepository, "cannot be null");
    this.name = name;
    this.fieldValueCounterRepository = fieldValueCounterRepository;
}

From source file:fr.mby.portal.coreimpl.acl.BasicPermissionFactory.java

@Override
public IPermission build(final String name) {
    Assert.hasText(name, "No name provided !");

    IPermission newPermission = this.permissionsCache.get(name);

    if (newPermission == null) {
        newPermission = new BasicPermission(name);
        this.permissionsCache.put(name, newPermission);
    }/*w  w  w.j  a v a 2  s . c o  m*/

    return newPermission;
}

From source file:com.autentia.wuija.widget.Link.java

Link(String labelId, boolean immediate) {
    Assert.hasText(labelId, "labelId cannot be empty");
    this.labelId = labelId;
    this.immediate = immediate;
}

From source file:de.itsvs.cwtrpc.controller.RemoteServiceModuleConfig.java

public void setName(String name) {
    Assert.hasText(name, "'name' must contain a valid text");
    this.name = name;
}

From source file:org.cleverbus.modules.ErrorEnum.java

/**
 * Creates new error code with specified description.
 *
 * @param errDesc the error description//from  ww  w  . j a va2 s  .  co  m
 */
private ErrorEnum(String errDesc) {
    Assert.hasText(errDesc, "the errDesc must not be empty");

    this.errDesc = errDesc;
}

From source file:com.autentia.wuija.widget.DinamicLink.java

DinamicLink(String labelId, boolean immediate) {
    Assert.hasText(labelId, "labelId cannot be empty");
    this.labelId = labelId;
    this.immediate = immediate;
}

From source file:org.personal.mason.addressbook.app.command.CreateContactCommand.java

public CreateContactCommand(ContactId contactId, String newContactName) {
    super(contactId);
    Assert.hasText(newContactName, "Name for new contact must contain text");
    this.newContactName = newContactName;
}

From source file:com.bootcamp.utils.config.Global.java

/**
 * ?CKFinder/*w w w .j av  a 2 s  .  c om*/
 * @return
 */
public static String getCkBaseDir() {
    String dir = getConfig("userfiles.basedir");
    Assert.hasText(dir, "??userfiles.basedir");
    if (!dir.endsWith("/")) {
        dir += "/";
    }
    return dir;
}