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:de.olivergierke.whoops.customer.CustomerServiceImpl.java

public Customer createCustomer(String firstname, String lastname) {

    Assert.hasText(firstname, "Firstname must not be null or empty!");
    Assert.hasText(lastname, "Lastname must not be null or empty!");

    CustomerNumber number = generator.generateCustomerNumber();
    Customer customer = new Customer(firstname, lastname, number);

    return repository.save(customer);
}

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

public CommandCatalogImpl(final String name, final Command... commands) {
    Assert.hasText(name, "name is required");
    Assert.notEmpty(commands, "commands are required");
    checkCommandNamesAreUnique(commands);

    this.name = name;

    final ImmutableMap.Builder<String, org.apache.commons.chain.Command> mapBuilder = ImmutableMap.<String, org.apache.commons.chain.Command>builder();
    for (final Command command : commands) {
        Assert.hasText(command.getName(), "command.name is required");
        mapBuilder.put(command.getName(), command);
    }//from w  w  w  .j  av a2  s  .co  m
    this.commands = mapBuilder.build();
}

From source file:com.excilys.ebi.spring.dbunit.test.MyEntityDao.java

@Override
public MyEntity getById(String id) {
    Assert.hasText(id, "id required");
    return getHibernateTemplate().get(MyEntity.class, id);
}

From source file:eu.trentorise.smartcampus.ac.provider.filters.AcProviderFilter.java

public void setPrincipalRequestHeader(String principalRequestHeader) {
    Assert.hasText(principalRequestHeader, "principalRequestHeader must not be empty or null");
    this.principalRequestHeader = principalRequestHeader;
}

From source file:com.azaptree.services.http.HttpServiceConfig.java

/**
 * //w w  w.ja  va 2 s.c  om
 * @param name
 *            REQUIRED
 * @param httpRequestHandler
 *            REQUIRED
 */
public HttpServiceConfig(final String name, final Handler httpRequestHandler) {
    Assert.hasText(name, "name is required");
    Assert.notNull(httpRequestHandler, "httpRequestHandler is required");
    this.name = name;
    this.httpRequestHandler = httpRequestHandler;
    requestExcecutorService = Executors.newCachedThreadPool();
    port = 8080;
}

From source file:com.epam.cme.facades.blockablecustomer.impl.DefaultBlockableCustomerFacade.java

@Override
public void register(final CmeRegisterData cmeRegisterData)
        throws DuplicateUidException, UnknownIdentifierException, IllegalArgumentException {
    validateParameterNotNullStandardMessage("cmeRegisterData", cmeRegisterData);
    Assert.hasText(cmeRegisterData.getFirstName(), "The field [FirstName] cannot be empty");
    Assert.hasText(cmeRegisterData.getLastName(), "The field [LastName] cannot be empty");
    Assert.hasText(cmeRegisterData.getLogin(), "The field [Login] cannot be empty");
    Assert.notNull(cmeRegisterData.getOrganizationsIds(), "The field [Organizations] cannot be empty");
    final BlockableCustomerModel newCustomer = getModelService().create(BlockableCustomerModel.class);
    newCustomer.setName(/*from   w  ww  .j a  va 2  s .com*/
            getCustomerNameStrategy().getName(cmeRegisterData.getFirstName(), cmeRegisterData.getLastName()));
    newCustomer
            .setOrganizations(organizationService.getOrganizationsByIds(cmeRegisterData.getOrganizationsIds()));
    if (StringUtils.isNotBlank(cmeRegisterData.getFirstName())
            && StringUtils.isNotBlank(cmeRegisterData.getLastName())) {
        newCustomer.setName(getCustomerNameStrategy().getName(cmeRegisterData.getFirstName(),
                cmeRegisterData.getLastName()));
    }
    final TitleModel title = getUserService().getTitleForCode(cmeRegisterData.getTitleCode());
    newCustomer.setTitle(title);
    setUidForRegister(cmeRegisterData, newCustomer);
    newCustomer.setSessionLanguage(getCommonI18NService().getCurrentLanguage());
    newCustomer.setSessionCurrency(getCommonI18NService().getCurrentCurrency());
    getCustomerAccountService().register(newCustomer, cmeRegisterData.getPassword());
}

From source file:org.openscada.spring.client.value.ItemEventValueSource.java

@Override
public void afterPropertiesSet() throws Exception {
    Assert.notNull(this.connection, "'connection' must not be null");
    Assert.hasText(this.itemName, "'itemName' must be set");

    this.dataItem = new DataItem(this.itemName, this.connection.getItemManager());
}

From source file:io.curly.bloodhound.query.SearchTranspiler.java

/**
 * Execute the steps to change the query into a multi map, if there is no key the
 * full text search parameter will take place.
 *
 * @param query the user input query/*from   ww  w  . ja  va 2s.  co m*/
 * @return MultiMap with query items and its values
 */
@Override
public MultiValueMap<String, String> execute(String query) {
    Assert.hasText(query, "A query must have text!");
    if (QueryUtils.isParametrized(query)) {
        MultiValueMap<String, String> parameter = QueryParser.resolveMultiParameter(query);
        return resolver.resolve(parameter);
    } else if (QueryUtils.isFullText(query)) {
        MultiValueMap<String, String> fullTextMap = new LinkedMultiValueMap<>(1);
        fullTextMap.add("text", query);
        return fullTextMap;
    }
    return new LinkedMultiValueMap<>();
}

From source file:nl.surfnet.coin.eb.EngineBlockImpl.java

@Override
public String getUserUUID(String identifier) {
    Assert.hasText(identifier, "Not allowed to provide a null or empty identifier");
    String sql = "SELECT user_uuid FROM saml_persistent_id WHERE persistent_id =  ?";
    LOG.debug("Executing query with identifier {}: {}", identifier, sql);
    List<String> results = ebJdbcTemplate.query(sql, new String[] { identifier }, new RowMapper<String>() {
        @Override/*from   ww  w  .j a v a2s.c  om*/
        public String mapRow(ResultSet rs, int rowNum) throws SQLException {
            return rs.getString(1);
        }
    });
    if (CollectionUtils.isEmpty(results)) {
        throw new RuntimeException("No persistent_id found for user_uuid(" + identifier + ")");
    }
    LOG.debug("Numer of results from query: {}", results.size());
    return results.get(0);
}

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

@Override
public IRole initializeRole(final String name, final Set<IPermission> permissions, final Set<IRole> subRoles) {
    Assert.hasText(name, "No name provided !");

    final BasicRole newRole = new BasicRole(name);

    if (permissions != null) {
        newRole.setPermissions(Collections.unmodifiableSet(permissions));
    } else {//from  w  w  w .  j av  a2  s. c o  m
        newRole.setPermissions(Collections.<IPermission>emptySet());
    }

    if (subRoles != null) {
        newRole.setSubRoles(Collections.unmodifiableSet(subRoles));
    } else {
        newRole.setSubRoles(Collections.<IRole>emptySet());
    }

    this.rolesCache.put(name, newRole);

    return newRole;
}