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.eryansky.common.orm.core.PropertyFilters.java

/**
 * ?/*from w  w w . j ava 2 s .c o m*/
 * <p>
 *    
 * </p>
 * <code>
 *    PropertyFilters.get("EQS_propertyName","maurice")
 * </code>
 * 
 * @param expression ?
 * @param matchValue 
 * 
 * @return {@link PropertyFilter}
 */
@SuppressWarnings("static-access")
public static PropertyFilter get(String expression, String matchValue) {

    Assert.hasText(expression, "??");

    String restrictionsNameAndClassType = StringUtils.substringBefore(expression, "_");

    String restrictionsName = StringUtils.substring(restrictionsNameAndClassType, 0,
            restrictionsNameAndClassType.length() - 1);
    String classType = StringUtils.substring(restrictionsNameAndClassType,
            restrictionsNameAndClassType.length() - 1, restrictionsNameAndClassType.length());

    FieldType FieldType = null;
    try {
        FieldType = FieldType.valueOf(classType);
    } catch (Exception e) {
        throw new IllegalAccessError(
                "[" + expression + "]??,?:" + classType);
    }

    String[] propertyNames = null;

    if (StringUtils.contains(expression, "_OR_")) {
        String temp = StringUtils.substringAfter(expression, restrictionsNameAndClassType + "_");
        propertyNames = StringUtils.splitByWholeSeparator(temp, "_OR_");
    } else {
        propertyNames = new String[1];
        propertyNames[0] = StringUtils.substringAfterLast(expression, "_");
    }

    return new PropertyFilter(restrictionsName, FieldType, propertyNames, matchValue);
}

From source file:com.github.dactiv.orm.core.PropertyFilters.java

/**
 * ?/*from w w w  .  ja  v a 2s  .c om*/
 * <p>
 *    
 * </p>
 * <code>
 *    PropertyFilters.build("EQS_propertyName","maurice")
 * </code>
 * 
 * @param expression ?
 * @param matchValue 
 * 
 * @return {@link PropertyFilter}
 */
@SuppressWarnings("static-access")
public static PropertyFilter build(String expression, String matchValue) {

    Assert.hasText(expression, "??");

    String restrictionsNameAndClassType = StringUtils.substringBefore(expression, "_");

    String restrictionsName = StringUtils.substring(restrictionsNameAndClassType, 0,
            restrictionsNameAndClassType.length() - 1);
    String classType = StringUtils.substring(restrictionsNameAndClassType,
            restrictionsNameAndClassType.length() - 1, restrictionsNameAndClassType.length());

    FieldType FieldType = null;
    try {
        FieldType = FieldType.valueOf(classType);
    } catch (Exception e) {
        throw new IllegalAccessError(
                "[" + expression + "]??,?:" + classType);
    }

    String[] propertyNames = null;

    if (StringUtils.contains(expression, "_OR_")) {
        String temp = StringUtils.substringAfter(expression, restrictionsNameAndClassType + "_");
        propertyNames = StringUtils.splitByWholeSeparator(temp, "_OR_");
    } else {
        propertyNames = new String[1];
        propertyNames[0] = StringUtils.substringAfterLast(expression, "_");
    }

    return new PropertyFilter(restrictionsName, FieldType, propertyNames, matchValue);
}

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

/**
 * creates new {@link DivideFunction.Builder} for dividing value in field with given name
 *
 * @param fieldname must not be empty/*  w ww.  j  a  v  a2s .  c  om*/
 * @return
 */
public static Builder divide(String fieldname) {
    Assert.hasText(fieldname, "Fieldname cannot be 'empty' for divide function.");

    return new Builder(fieldname);
}

From source file:com.acuityph.commons.jpa.JpaUtils.java

/**
 * For an entity named "MyEntity", returns a string of the form
 * "SELECT myEntity FROM MyEntity myEntity".
 *
 * @param entityName//from   w w  w  .  j  ava 2s.  co m
 *        the entity name
 * @return the 'listAll' JPQL query string
 */
public static String constructSelectAllQuery(final String entityName) {
    Assert.hasText(entityName, "Invalid entity name \"" + entityName + "\"!");
    return format(SELECT_ALL_FORMAT, entityName, StringUtility.decapitalize(entityName));
}

From source file:net.paslavsky.springrest.SpringRestClientFactoryBean.java

private static Class<?> getClientClass(String clientClassName) {
    Assert.hasText(clientClassName,
            "Argument 'clientClassName' must be a name of the class from default classpath");
    try {/*from  w ww  .java 2 s .c  o  m*/
        return ClassUtils.forName(clientClassName, ClassUtils.getDefaultClassLoader());
    } catch (ClassNotFoundException e) {
        throw new SpringRestClientConfigurationException("Wrong class name of the REST client", e);
    }
}

From source file:org.cleverbus.api.route.AbstractExtRoute.java

/**
 * Gets route ID for synchronous routes, specific for extension routes.
 *
 * @param service       the service name
 * @param operationName the operation name
 * @return route ID//from  www  .  java  2  s. c om
 * @see #getRouteId(ServiceExtEnum, String)
 */
public static String getExtRouteId(ServiceExtEnum service, String operationName) {
    Assert.notNull(service, "the service must not be null");
    Assert.hasText(operationName, "the operationName must not be empty");

    return service.getServiceName() + "_" + operationName + EXT_ROUTE_SUFFIX;
}

From source file:com.azaptree.services.domain.entity.dao.SortField.java

public SortField(final String fieldName, final boolean ascending) {
    Assert.hasText(fieldName, "fieldName is required");
    this.fieldName = fieldName;
    this.ascending = ascending;
}

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

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

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

public ChangeContactNameCommand(ContactId contactId, String contactNewName) {
    super(contactId);
    Assert.hasText(contactNewName, "New name for contact should contain text");
    this.contactNewName = contactNewName;
}

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

public void setContactId(String contactId) {
    Assert.hasText(contactId, "Cannot remove a contact with an empty id");
    this.contactId = contactId;
}