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.spring.data.gemfire.config.RegionPutAllBeanPostProcessor.java

public void setTargetBeanName(final String targetBeanName) {
    Assert.hasText(targetBeanName, "The target Spring context bean name must be specified!");
    this.targetBeanName = targetBeanName;
}

From source file:de.zalando.spring.cloud.config.aws.kms.KmsTextEncryptor.java

@Override
public String encrypt(final String text) {
    Assert.hasText(kmsKeyId, "kmsKeyId must not be blank");
    if (text == null || text.isEmpty()) {
        return EMPTY_STRING;
    } else {/*from w ww.j  ava 2s . co  m*/
        final EncryptRequest encryptRequest = new EncryptRequest().withKeyId(kmsKeyId) //
                .withPlaintext(ByteBuffer.wrap(text.getBytes()));

        final ByteBuffer encryptedBytes = kms.encrypt(encryptRequest).getCiphertextBlob();

        return extractString(ByteBuffer.wrap(Base64.encode(encryptedBytes.array())));
    }
}

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

/**
 * Gets route ID for asynchronous outbound routes, specific for extension routes.
 *
 * @param service       the service name
 * @param operationName the operation name
 * @return route ID/*from   w w w.ja  v  a  2 s  .  com*/
 * @see #getOutRouteId(ServiceExtEnum, String)
 */
public static String getExtOutRouteId(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_OUT_ROUTE_SUFFIX;
}

From source file:org.sharetask.utility.log.ErrorInterceptor.java

/**
 * Set the template used for method exception log messages.
 * This template can contain any of the following placeholders:
 * <ul>/*from   www  .j a  v  a 2 s .co  m*/
 * <li>{@code $[targetClassName]}</li>
 * <li>{@code $[targetClassShortName]}</li>
 * <li>{@code $[argumentTypes]}</li>
 * <li>{@code $[arguments]}</li>
 * <li>{@code $[exception]}</li>
 * </ul>
 */
@Override
public void setExceptionMessage(final String exceptionMessage) {
    Assert.hasText(exceptionMessage, "'exceptionMessage' must not be empty");
    Assert.doesNotContain(exceptionMessage, PLACEHOLDER_RETURN_VALUE,
            "exceptionMessage cannot contain placeholder [" + PLACEHOLDER_RETURN_VALUE + "]");
    Assert.doesNotContain(exceptionMessage, PLACEHOLDER_INVOCATION_TIME,
            "exceptionMessage cannot contain placeholder [" + PLACEHOLDER_INVOCATION_TIME + "]");
    this.exceptionMessage = exceptionMessage;
}

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

/**
 * Adds a group request for a {@link Field}.
 * /*from  w w w.  j  a va 2 s  . c om*/
 * @param field
 * @return
 */
public GroupOptions addGroupByField(Field field) {

    Assert.notNull(field, "Field for grouping must not be null.");
    Assert.hasText(field.getName(), "Field.name for grouping must not be null/empty.");
    groupByFields.add(field);
    return this;
}

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

public HttpServiceConfig(final String name, final Handler httpRequestHandler,
        final ExecutorService requestExcecutor, final int port) {
    Assert.hasText(name, "name is required");
    Assert.notNull(httpRequestHandler, "httpRequestHandler is required");
    this.name = name;
    this.httpRequestHandler = httpRequestHandler;
    Assert.notNull(requestExcecutor, "requestExcecutor is required");
    Assert.isTrue(port > 0, "port must be > 0");
    requestExcecutorService = requestExcecutor;
    this.port = port;
}

From source file:org.cleverbus.core.common.dao.RequestResponseDaoJpaImpl.java

@Nullable
@Override// w  ww.  j  av  a 2s .c o m
public Request findLastRequest(String uri, String responseJoinId) {
    Assert.hasText(uri, "the uri must not be empty");
    Assert.hasText(responseJoinId, "the responseJoinId must not be empty");

    String jSql = "SELECT r " + "FROM " + Request.class.getName() + " r "
            + "WHERE r.responseJoinId = :responseJoinId AND r.uri = :uri " + "ORDER BY r.reqTimestamp";

    TypedQuery<Request> q = em.createQuery(jSql, Request.class);
    q.setParameter("responseJoinId", responseJoinId);
    q.setParameter("uri", uri);

    // we search by unique key - it's not possible to have more records
    List<Request> requests = q.getResultList();
    if (requests.isEmpty()) {
        return null;
    } else {
        return requests.get(0); // if find more items then return first one only
    }
}

From source file:org.zalando.stups.oauth2.spring.client.StupsTokensAccessTokenProvider.java

public StupsTokensAccessTokenProvider(String tokenId, AccessTokens tokens) {
    Assert.hasText(tokenId, "tokenId cannot be left blank");
    Assert.notNull(tokens, "tokens must not be null");
    this.tokenId = tokenId;
    this.tokens = tokens;
}

From source file:com.oembedler.moon.graphql.engine.GraphQLSchemaConfig.java

public GraphQLSchemaConfig setClientMutationIdName(String clientMutationIdName) {
    Assert.hasText(clientMutationIdName, "Client mutation identity value can not be null!");
    this.clientMutationIdName = clientMutationIdName;
    return this;
}

From source file:de.coderebell.failsafeactuator.service.CircuitBreakerRegistry.java

/**
 * Will put the {@link CircuitBreaker} into the registry. There is no check which avoids overwriting
 * of identifiers. Therefore be sure that your identifiers are unique, or you want to overwrite the
 * current {@link CircuitBreaker} which is registered with this identifier.
 *
 * @param breaker Which should be added//from w  ww .  ja  va2 s.c o  m
 * @param name    Which is used to identify the CircuitBreaker
 */
void registerCircuitBreaker(final CircuitBreaker breaker, final String name) {
    Assert.hasText(name, "Name for circuitbreaker needs to be set");
    Assert.notNull(breaker, "Circuitbreaker to add, can't be null");

    CircuitBreaker replaced = concurrentBreakerMap.put(name, breaker);
    Assert.isNull(replaced, "There was an Circuit-Breaker registered already with name : " + name);
}