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.red5.server.script.groovy.GroovyScriptFactory.java

/**
 * Create a new GroovyScriptFactory for the given script source.
 * <p>We don't need to specify script interfaces here, since
 * a Groovy script defines its Java interfaces itself.
 * @param scriptSourceLocator a locator that points to the source of the script.
 * Interpreted by the post-processor that actually creates the script.
 *//*w w  w  . j a  v a 2s. c o  m*/
public GroovyScriptFactory(String scriptSourceLocator) {
    Assert.hasText(scriptSourceLocator, "'scriptSourceLocator' must not be empty");
    this.scriptSourceLocator = scriptSourceLocator;
    this.groovyObjectCustomizer = null;
    //      this(scriptSourceLocator, null);
}

From source file:com.google.code.ssm.json.ClassAliasTypeResolverBuilder.java

/**
 * Registers mappings between classes and aliases (ids).
 * /*from  ww w .ja  v  a2 s . c o  m*/
 * @param classToId
 */
public void setClassToId(final Map<Class<?>, String> classToId) {

    Map<String, Class<?>> reverseMap = new HashMap<String, Class<?>>();
    for (Map.Entry<Class<?>, String> entry : classToId.entrySet()) {
        Assert.notNull(entry.getKey(), "Class cannot be null: " + entry);
        Assert.hasText(entry.getValue(), "Alias (id) cannot be null or contain only whitespaces" + entry);

        if (reverseMap.put(entry.getValue(), entry.getKey()) != null) {
            throw new IllegalArgumentException(
                    "Two or more classes with the same alias (id): " + entry.getValue());
        }
    }

    this.classToId = classToId;
    this.idToClass = reverseMap;
}

From source file:com.azaptree.services.command.impl.CommandCatalogImpl.java

@Override
public synchronized void addCommand(final String name, final org.apache.commons.chain.Command command) {
    Assert.hasText(name, "name is required");
    Assert.notNull(command, "command is required");
    if (getCommand(name) != null) {
        throw new IllegalArgumentException(
                String.format("Command names must be unique within a catalog: %s", name));
    }//  w  ww.j  a  va 2 s  .c om
    commands = ImmutableMap.<String, org.apache.commons.chain.Command>builder().putAll(commands)
            .put(name, command).build();
}

From source file:fr.mby.opa.picsimpl.service.BasicProposalService.java

@Override
public ProposalBag createBag(final String name, final String description, final long branchId) {
    Assert.hasText(name, "No name supplied !");

    final ProposalBag bag = new ProposalBag();
    bag.setCreationTime(new Timestamp(System.currentTimeMillis()));
    bag.setName(name);//w  ww  .ja  v a  2s.co  m
    bag.setDescription(description);
    bag.setCommited(false);

    final ProposalBag createdBag = this.proposalDao.createBag(bag, branchId);

    return createdBag;
}

From source file:org.agatom.springatom.data.vin.model.VinNumber.java

private VinNumber(final String vinNumber) throws VinNumberServiceException {
    try {/*from   w  w  w.j  av  a  2 s . c om*/
        Assert.hasText(vinNumber, "VinNumber must not be empty or null");
        Assert.isTrue(vinNumber.length() == 17, "VinNumber must have correct length");
    } catch (Exception exp) {
        throw new VinNumberServiceException("VinNumber is either null or has insufficient length 17", exp);
    }
    this.vinNumber = vinNumber;
    this.splitVinNumber();
}

From source file:org.opencredo.esper.integration.config.xml.EsperWireTapParser.java

private void setSourceId(Element element, BeanDefinitionBuilder builder) {

    String sourceId = element.getAttribute("sourceId");
    Assert.hasText(sourceId, "sourceId attribute is required");
    builder.addConstructorArgValue(sourceId);

}

From source file:com.azaptree.services.security.impl.SecurityServiceImpl.java

@Override
public UUID getHashServiceId(final String name) throws SecurityServiceException {
    Assert.hasText(name, "name is required");
    return hashServiceConfigurationDAO.lookupIdByName(name);
}

From source file:com.kuprowski.redis.security.core.session.RedisSessionRegistry.java

@Override
public SessionInformation getSessionInformation(String sessionId) {
    Assert.hasText(sessionId, "SessionId required as per interface contract");
    return sessionIdsTemplate.opsForValue().get(buildSessionIdsKey(sessionId));
}

From source file:org.esco.portlet.changeetab.dao.impl.LdapEtablissementDao.java

@Override
public void afterPropertiesSet() throws Exception {
    Assert.notNull(this.ldapTemplate, "No LdapTemplate configured !");
    Assert.hasText(this.etablissementBase, "No etablissement Ldap base configured !");

    Assert.hasText(this.allEtabsFilter, "No 'all etabs' Ldap filter configured !");
    Assert.hasText(this.etabIdLdapAttr, "No etablissement Id Ldap attribute configured !");
    Assert.hasText(this.etabNameLdapAttr, "No etablissement Name Ldap attribute configured !");
    Assert.hasText(this.etabDescriptionLdapAttr, "No etablissement Description Ldap attribute configured !");
}

From source file:org.zalando.failsafeactuator.service.CircuitBreakerRegistry.java

/**
 * Checks if a {@link CircuitBreaker} with the given name was already registered.
 *
 * @param name That should be checked//w w  w .  ja v  a2s.  c  o  m
 * @return <code>true</code> if a CircuitBreaker was already registered, <code>false</code> otherwise
 */
boolean contains(final String name) {
    Assert.hasText(name, "Name for circuit breaker needs to be set");
    return concurrentBreakerMap.containsKey(name);
}