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.miko.demo.mongo.model.EntityC.java

@PersistenceConstructor
public EntityC(String name, BigDecimal value) {

    Assert.hasText(name, "Name can not be empty");
    Assert.isTrue(BigDecimal.ZERO.compareTo(value) < 0, "Value must be greater than zero!");

    this.name = name;
    this.value = value;
}

From source file:org.springframework.data.examples.domain.Address.java

/**
 * //from  w  ww . java 2 s . c  o m
 * @param address1
 * @param address2
 * @param city
 * @param country
 * @param postalcode
 */
public Address(String address1, String address2, String city, String state, String country, String postalCode) {

    Assert.hasText(address1, "Address line 1 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.address1 = address1;
    this.address2 = address2;
    this.state = state;
    this.city = city;
    this.country = country;
    this.postalCode = postalCode;
}

From source file:cz.jirutka.spring.http.client.cache.SynchronizedLruCache.java

public SynchronizedLruCache(String name, int capacity, int initialCapacity, float loadFactory) {
    Assert.hasText(name, "name should not be blank");
    Assert.isTrue(capacity > 0, "capacity must be greater then 0");

    this.name = name;
    this.capacity = capacity;

    this.store = new LinkedHashMap<Object, ValueWrapper>(initialCapacity, loadFactory, true) {
        protected boolean removeEldestEntry(Map.Entry eldest) {
            return this.size() > SynchronizedLruCache.this.capacity;
        }//  w ww  .j  a  va 2 s  . c  o m
    };
}

From source file:fr.acxio.tools.agia.transform.FieldSetFieldFilterProcessor.java

public void afterPropertiesSet() {
    Assert.hasText(fieldName, "You must provide a field name.");
    Assert.notEmpty(fieldValues, "You must provide at least one value.");
}

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

/**
 * Only meant to be used if not created as a Spring bean because if it was a Spring bean the name would be overridden by the Spring bean name later on.
 * //from  w  w  w  . java2 s . c o m
 * @param name
 */
public CommandSupport(final String name) {
    Assert.hasText(name, "name is required");
    this.name = name;
}

From source file:fr.mby.portal.coreimpl.app.UserAppStore.java

@Override
public IApp retrieveApp(final HttpServletRequest request) {
    final String appSignature = this.appSigner.retrieveSignature(request);

    Assert.hasText(appSignature, "No App signature found in Http request !");

    return this.userAppStore.get(appSignature);
}

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

public static Contact newContact(Person person, String email) {
    Assert.notNull(person, "Person is required");
    Assert.hasText(email, "Email is required");

    Contact contact = new Contact();

    contact.setPerson(person);/*  ww  w .j  a  v a 2  s . c om*/
    contact.setEmail(email);

    return contact;
}

From source file:com.oreilly.springdata.mongodb.core.Product.java

/**
 * Creates a new {@link Product} from the given name and description.
 * /*from  w  ww.  j  a v a2  s  .c  o  m*/
 * @param name must not be {@literal null} or empty.
 * @param price must not be {@literal null} or less than or equal to zero.
 * @param description
 */
@PersistenceConstructor
public Product(String name, BigDecimal price, String description) {

    Assert.hasText(name, "Name must not be null or empty!");
    Assert.isTrue(BigDecimal.ZERO.compareTo(price) < 0, "Price must be greater than zero!");

    this.name = name;
    this.price = price;
    this.description = description;
}

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

/**
 * Copy constructor.//from  w  ww. jav a 2s  . c o  m
 * @param origin The origin, required
 * @param name The name for this set
 */
public NamedSetDefaultImpl(ISet<T> origin, String name) {
    super(origin);
    Assert.hasText(name, "The name is a required argument, cannot be null, nor empty nor whitespace!");
    this.name = name;
}