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.tpg.tmjug.springdata.demo.jpa.entities.Address.java

public Address(Long id, String street, String city, String country) {

    super(id);//from ww w.j  a  v a2s. com

    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.street = street;
    this.city = city;
    this.country = country;
}

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

/** Protected constructor. */
protected BasicPermission(final String name) {
    super();// w ww.j a  v  a 2 s  .c o m

    Assert.hasText(name, "NO name provided !");

    this.name = name;
}

From source file:org.cloudfoundry.identity.uaa.test.NullSafeSystemProfileValueSource.java

@Override
public String get(String key) {
    Assert.hasText(key, "'key' must not be empty");
    return System.getProperty(key, "");
}

From source file:gov.nyc.doitt.gis.geoclient.parser.Input.java

public Input(String id, String inputString) {
    super();/*w w w.  ja  v a2  s . com*/
    Assert.hasText(id, "id argument cannot be empty or null.");
    this.id = id;
    Assert.hasText(inputString, "inputString argument cannot be empty or null.");
    this.unsanitizedValue = inputString;
    this.value = TextUtils.sanitize(this.unsanitizedValue);
    Assert.hasText(this.value, "inputString cannot be empty or null after sanitization.");
}

From source file:com.gs.config.CustomFilterLogin.java

@Override
public void afterPropertiesSet() throws Exception {
    Assert.hasText(expiredUrl, "ExpiredUrl required");
}

From source file:com.crossover.trial.weather.domain.IATA.java

public static IATA valueOf(String code) {
    Assert.hasText(code, "iata code is required");
    Assert.isTrue(code.matches("[a-zA-Z]{3}"), "iata must be a 3-letter code");
    return new IATA(code);
}

From source file:Main.java

/**
 * Checks in under a given root element whether it can find a child element
 * which matches the XPath expression supplied. The {@link Element} must
 * exist. Returns {@link Element} if exists.
 * /*from www  .ja v a  2s  .c  o m*/
 * Please note that the XPath parser used is NOT namespace aware. So if you
 * want to find a element <beans><sec:http> you need to use the following
 * XPath expression '/beans/http'.
 * 
 * @param xPathExpression the xPathExpression (required)
 * @param root the parent DOM element (required)
 * 
 * @return the Element if discovered (never null; an exception is thrown if
 *         cannot be found)
 */
public static Element findRequiredElement(String xPathExpression, Element root) {
    Assert.hasText(xPathExpression, "XPath expression required");
    Assert.notNull(root, "Root element required");
    Element element = findFirstElement(xPathExpression, root);
    Assert.notNull(element,
            "Unable to obtain required element '" + xPathExpression + "' from element '" + root + "'");
    return element;
}

From source file:org.opencredo.cloud.storage.azure.model.Blob.java

public Blob(String name) {
    Assert.hasText(name, "Blob name must be specified.");
    this.name = name;
}

From source file:org.springmodules.validation.valang.javascript.taglib.ValangJavaScriptTagUtils.java

/**
 * Inserts the valang validator from the provided controller into the model using the controller's name as the
 * validation rule's key.//from www  .ja va2 s. c o m
 * 
 * @param controller
 *            the controller that will provide the command name and validator
 * @param model
 *            the model into which the validation rules will be placed
 * @throws IllegalArgumentException
 *             if the controller does not specify a command name
 * @throws IllegalArgumentException
 *             if the controller's validator is not an instance of
 *             {@link org.springmodules.validation.valang.ValangValidator}
 */
public static void addValangRulesToModel(BaseCommandController controller, Map model) {
    Assert.hasText(controller.getCommandName(), "controller must define a command name");
    Validator validator = controller.getValidator();
    Assert.isInstanceOf(ValangValidator.class, validator,
            "controller's validator of class '"
                    + (validator != null ? validator.getClass().getName() : "[null]")
                    + "' must be an instance of 'ValangValidator'");
    ValangValidator vv = (ValangValidator) validator;
    addValangRulesToModel(controller.getCommandName(), vv.getRules(), model);
}

From source file:org.opencredo.twitter.si.TwitterCredentials.java

public TwitterCredentials(String screenName, String password) {
    Assert.hasText(screenName, "screenName must contain text");
    Assert.hasText(password, "password must contain text");

    this.screenName = screenName;
    this.password = password;
}