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.juiser.spring.security.core.userdetails.ForwardedUserDetails.java

public ForwardedUserDetails(User user, Collection<? extends GrantedAuthority> grantedAuthorities) {
    Assert.notNull(user, "User argument cannot be null.");
    Assert.hasText(user.getUsername(), "User username cannot be null or empty.");
    this.user = user;
    if (CollectionUtils.isEmpty(grantedAuthorities)) {
        this.grantedAuthorities = java.util.Collections.emptyList();
    } else {/*  w  w  w .jav  a 2s  . co m*/
        this.grantedAuthorities = java.util.Collections.unmodifiableCollection(grantedAuthorities);
    }
}

From source file:io.pivotal.strepsirrhini.chaoslemur.Member.java

/**
 * Creates an instance/*from w w  w .  j av  a2 s  .c  o m*/
 *
 * @param id         the ID of the {@link Member}
 * @param deployment the deployment the {@link Member} belongs to
 * @param job        the job the {@link Member} belongs to
 * @param name       the name of the {@link Member}
 */
public Member(String id, String deployment, String job, String name) {
    Assert.hasText(id, "id must have text");
    Assert.hasText(deployment, "deployment must have text");
    Assert.hasText(job, "job must have text");
    Assert.hasText(name, "name must have text");

    this.id = id;
    this.deployment = deployment;
    this.job = job;
    this.name = name;
}

From source file:org.axonframework.sample.app.api.ChangeContactNameCommand.java

/**
 * Provide the new name for the existing contact. An error is thrown if the provided name is empty
 *
 * @param contactNewName String containing the new name for the contact
 *///from  w  w  w. j  a  va2s .  co m
public void setContactNewName(String contactNewName) {
    Assert.hasText(contactNewName, "New name for contact should contain text");
    this.contactNewName = contactNewName;
}

From source file:cn.designthoughts.sample.axon.sfav.customer.entry.AddressEntry.java

/**
 * Creates a new {@link AddressEntry} from the given street, city and country.
 * /*  ww  w.  j a v  a 2 s.c  o  m*/
 * @param building must not be {@literal null} or empty.
 * @param street must not be {@literal null} or empty.
 * @param city must not be {@literal null} or empty.
 * @param country must not be {@literal null} or empty.
 */
public AddressEntry(String building, String street, String city, String country) {

    Assert.hasText(building, "Building must not be null or empty!");
    Assert.hasText(street, "Street must not be null or empty!");
    Assert.hasText(city, "City must not be null or empty!");
    Assert.hasText(country, "Country must not be null or empty!");

    this.building = building;
    this.street = street;
    this.city = city;
    this.country = country;
}

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

/**
 * Create new {@link CurrencyFunction} using ISO-4217 currencyCode representing
 * {@code currency(fieldname,currencyCode)}
 * //from   w w  w.  j  a va2 s  . c  o m
 * @param fieldname
 * @param currencyCode
 * @return
 */
public static CurrencyFunction currency(String fieldname, String currencyCode) {
    Assert.hasText(fieldname, "Fieldname for currency function must not be 'empty'.");

    CurrencyFunction function = new CurrencyFunction(fieldname);
    if (StringUtils.hasText(currencyCode)) {
        function.addArgument(currencyCode);
    }
    return function;
}

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

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

    String sinkFactory = element.getAttribute("sink-factory");
    Assert.hasText(sinkFactory, "the 'sink-factory' attribute is required");
    builder.addPropertyReference("sinkFactory", sinkFactory);

    String outputType = element.getAttribute("output-type");
    Assert.hasText(outputType, "the 'output-type' attribute is required");
    builder.addPropertyValue("outputType", outputType);

}

From source file:org.jasig.cas.monitor.AbstractNamedMonitor.java

/**
 * @param n Monitor name./*from  w  w w  .  j  a  va  2s .  co m*/
 */
public void setName(final String n) {
    Assert.hasText(n, "Monitor name cannot be null or empty.");
    this.name = n;
}

From source file:com.azaptree.services.security.Credential.java

public Credential(final String name, final Object credential, final Date expiresOn) {
    Assert.hasText(name, "name is required");
    Assert.notNull(credential, "credential is required");
    Assert.notNull(expiresOn, "expiresOn is required");
    this.name = name;
    this.credential = credential;
    this.expiresOn = expiresOn;
}

From source file:slina.mb.smb.DefaultSmbSessionFactory.java

@Override
public Session getSession() {
    Assert.notNull(this.domain, "domain must not be null");
    Assert.hasText(this.user, "user must not be empty");
    Assert.isTrue(StringUtils.hasText(this.password), "password is required");
    try {//from   w  w  w.  java2  s .c om
        NtlmPasswordAuthentication ntlmAuth = new NtlmPasswordAuthentication(domain, user, password);
        Session smbSession = new SmbSessionImpl(ntlmAuth);
        return smbSession;
    } catch (Exception e) {
        throw new IllegalStateException("failed to create SMB Session", e);
    }
}

From source file:org.cleverbus.core.common.route.SpringWsUriBuilder.java

@Override
public String getOutWsUri(String connectionUri, String messageSenderRef, String soapAction) {
    Assert.hasText(connectionUri, "the connectionUri must not be empty");
    Assert.hasText(messageSenderRef, "the messageSenderRef must not be empty");

    String wsUri = "spring-ws:" + connectionUri + "?messageSender=#" + messageSenderRef + "&messageFactory=#"
            + MESSAGE_FACTORY_SOAP11;/*from   w  ww .  j  a v  a2s.co  m*/

    if (StringUtils.isNotEmpty(soapAction)) {
        wsUri += "&soapAction=" + soapAction;
    }

    return wsUri;
}