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:lab.mage.spring.cassandra.connector.core.TenantAwareCassandraMapperProvider.java

@Nonnull
public <T> Mapper<T> getMapper(@Nonnull final String identifier, @Nonnull final Class<T> type) {
    Assert.notNull(identifier, "A tenant identifier must be given!");
    Assert.hasText(identifier, "A tenant identifier must be given!");
    Assert.notNull(type, "A type must be given!");

    this.managerCache.computeIfAbsent(identifier, (key) -> {
        this.logger.info("Create new mapping mapper for tenant [" + identifier + "] and type ["
                + type.getSimpleName() + "].");
        final Session session = this.cassandraSessionProvider.getTenantSession(identifier);

        final MappingManager mappingManager = new MappingManager(session);

        final Mapper<T> typedMapper = mappingManager.mapper(type);
        typedMapper.setDefaultDeleteOptions(OptionProvider.deleteConsistencyLevel(this.env));
        typedMapper.setDefaultGetOptions(OptionProvider.readConsistencyLevel(this.env));
        typedMapper.setDefaultSaveOptions(OptionProvider.writeConsistencyLevel(this.env));

        return mappingManager;
    });//from  w w  w. j a  va  2s  .  co  m

    return this.managerCache.get(identifier).mapper(type);
}

From source file:fr.acxio.tools.agia.expression.StandardDataExpressionResolver.java

/**
 * Set the prefix that an expression string starts with. The default is
 * "@{".//from  ww w  .ja  va  2s  .c om
 * 
 * @see #DEFAULT_EXPRESSION_PREFIX
 */
public void setExpressionPrefix(String expressionPrefix) {
    Assert.hasText(expressionPrefix, "Expression prefix must not be empty");
    this.expressionPrefix = expressionPrefix;
}

From source file:io.galeb.core.entity.Farm.java

public Farm setDomain(String domain) {
    Assert.hasText(domain,
            "[Assertion failed] - this String argument must have text; it must not be null, empty, or blank");
    updateHash();/*from  w  ww . j ava2 s. c  o  m*/
    this.domain = domain;
    return this;
}

From source file:com.kuba.skateagramclient.domain.Link.java

/**
 * Creates a new Link from the given {@link UriTemplate} and rel.
 *
 * @param template must not be {@literal null}.
 * @param rel must not be {@literal null} or empty.
 *///from w w w. j  a  va 2  s  .  com
public Link(UriTemplate template, String rel) {

    Assert.notNull(template, "UriTempalte must not be null!");
    Assert.hasText(rel, "Rel must not be null or empty!");

    this.template = template;
    this.href = template.toString();
    this.rel = rel;
}

From source file:com.dosport.system.utils.ReflectionUtils.java

/**
 * ?, ?DeclaredField, ?./*from  w  ww .  j a va  2  s .c o  m*/
 * 
 * ?Object?, null.
 */
public static Field getAccessibleField(final Object obj, final String fieldName) {
    Assert.notNull(obj, "object?");
    Assert.hasText(fieldName, "fieldName");
    for (Class<?> superClass = obj.getClass(); superClass != Object.class; superClass = superClass
            .getSuperclass()) {
        try {
            Field field = superClass.getDeclaredField(fieldName);
            field.setAccessible(true);
            return field;
        } catch (NoSuchFieldException e) {// NOSONAR
            // Field??,?
        }
    }
    return null;
}

From source file:lab.mage.spring.cassandra.connector.core.CassandraSessionProvider.java

public void setAdminContactPoints(@Nonnull final String adminContactPoints) {
    Assert.notNull(adminContactPoints, "At least one contact point must be given!");
    Assert.hasText(adminContactPoints, "At least one contact point must be given!");
    this.adminContactPoints = adminContactPoints;
}

From source file:com.abssh.util.ReflectionUtils.java

/**
 * ?, ?DeclaredField.//ww  w.jav a 2  s  .c  o m
 * 
 * ?Object?, null.
 */
protected static Field getDeclaredField(final Object object, final String fieldName) {
    Assert.notNull(object, "object?");
    Assert.hasText(fieldName, "fieldName");
    for (Class<?> superClass = object.getClass(); superClass != Object.class; superClass = superClass
            .getSuperclass()) {
        try {
            return superClass.getDeclaredField(fieldName);
        } catch (NoSuchFieldException e) {
            // Field??,?
        }
    }
    return null;
}

From source file:cat.albirar.framework.sets.SetUtils.java

/**
 * Check if path is correct for the indicated model.
 * @param model The model/*w w  w .j a v  a  2  s  .  c  o  m*/
 * @param propertyPath The property path, required
 * @return true if correct and false if not
 * @throws IllegalArgumentException If model is null or if the property path is null or empty or only whitespace or not correct format
 */
public static boolean checkPathForModel(Class<?> model, String propertyPath) {
    StringTokenizer stk;
    ModelDescriptor pathFollower;
    PropertyDescriptor pdesc;
    String ppath;

    Assert.hasText(propertyPath, "The property path is required and cannot be empty or only whitespace");

    // Check pattern
    if (!pathPattern.matcher(propertyPath).matches()) {
        throw new IllegalArgumentException(String.format("The property path '%s' is incorrect!", propertyPath));
    }
    stk = new StringTokenizer(propertyPath, ".");
    pathFollower = new ModelDescriptor(model);
    while (stk.hasMoreTokens()) {
        ppath = stk.nextToken();
        if ((pdesc = pathFollower.getProperties().get(ppath)) != null) {
            if (stk.hasMoreTokens()) {
                pathFollower = new ModelDescriptor(pdesc.getPropertyType());
            }
        } else {
            // Error
            return false;
        }
    }
    return true;
}

From source file:fr.mby.saml2.sp.impl.handler.BasicSamlDataAdaptor.java

@Override
public String buildHttpRedirectBindingUrl(final IOutgoingSaml outgoingData) {
    final String samlMessage = outgoingData.getSamlMessage();
    final String relayState = outgoingData.getRelayState();

    // Encoding//from  ww  w. jav  a2s  . c o  m
    final String httpEncodedMessage;
    final String urlEncodedMessage;
    final String urlEncodedRelayState;
    try {
        Assert.hasText(samlMessage, "SAML message cannot be empty !");
        // HTTP-Redirect encoding
        httpEncodedMessage = SamlHelper.httpRedirectEncode(samlMessage);

        // URL encoding
        urlEncodedMessage = URLEncoder.encode(httpEncodedMessage, "UTF-8");
        if (StringUtils.hasText(relayState)) {
            urlEncodedRelayState = URLEncoder.encode(relayState, "UTF-8");
        } else {
            urlEncodedRelayState = null;
        }
    } catch (Exception e) {
        final String message = "Error while HTTP-Redirect encoding SAML message !";
        BasicSamlDataAdaptor.LOGGER.error(message, e);
        throw new IllegalStateException(message, e);
    }

    StringBuffer redirectUrl = new StringBuffer(2048);
    redirectUrl.append(outgoingData.getEndpointUrl());
    if (StringUtils.hasText(urlEncodedMessage) && StringUtils.hasText(urlEncodedRelayState)) {
        redirectUrl.append("?");
        if (StringUtils.hasText(urlEncodedRelayState)) {
            redirectUrl.append(SamlHelper.RELAY_STATE_PARAM_KEY);
            redirectUrl.append("=");
            redirectUrl.append(urlEncodedRelayState);
            redirectUrl.append("&");
        }
        redirectUrl.append(BasicSamlDataAdaptor.getSamlMessageParamName(outgoingData));
        redirectUrl.append("=");
        redirectUrl.append(urlEncodedMessage);
    }

    final String urlRequest = redirectUrl.toString();

    BasicSamlDataAdaptor.LOGGER.debug("Basic HTTP-Redirect URL built: [{}]", urlRequest);

    return urlRequest;
}

From source file:org.cleverbus.core.common.directcall.DirectCallWsRoute.java

/**
 * Sets request header if available./*w  w w  .j a va2s. com*/
 *
 * @param callId Call ID for getting call parameters from {@link DirectCallRegistry}
 * @param exchange Camel exchange
 */
@Handler
public void setHeader(@Header(CALL_ID_HEADER) String callId, Exchange exchange) {
    Assert.hasText(callId, "the callId must not be empty");

    DirectCallParams params = callRegistry.getParams(callId);

    if (params.getHeader() != null) {
        Log.debug("Direct WS call: header=" + params.getHeader());

        exchange.getIn().setHeader(SpringWebserviceConstants.SPRING_WS_SOAP_HEADER, params.getHeader());
    }
}