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

@Deprecated
public static void hasText(@Nullable String text) 

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:io.twipple.springframework.data.clusterpoint.convert.ClusterpointDocumentPropertyAccessor.java

/**
 * It can always read from those properties.
 *
 * @param context the evaluation context.
 * @param target  the target object./*from  w  ww .  j  a v  a2  s.  c o m*/
 * @param name    the name of the property.
 * @return always true.
 */
@Override
public boolean canRead(@NotNull EvaluationContext context, @NotNull Object target, @NotNull String name) {

    Assert.notNull(context);
    Assert.notNull(target);
    Assert.isInstanceOf(ClusterpointDocument.class, target);
    Assert.hasText(name);

    ClusterpointDocument source = (ClusterpointDocument) target;

    return source.canRead(context, name);
}

From source file:com.iterzp.momo.utils.WebUtils.java

/**
 * ?cookie//from w  ww . ja va2 s  .  c  o m
 * 
 * @param request
 *            HttpServletRequest
 * @param name
 *            cookie??
 * @return ?null
 */
public static String getCookie(HttpServletRequest request, String name) {
    Assert.notNull(request);
    Assert.hasText(name);
    Cookie[] cookies = request.getCookies();
    if (cookies != null) {
        try {
            name = URLEncoder.encode(name, "UTF-8");
            for (Cookie cookie : cookies) {
                if (name.equals(cookie.getName())) {
                    return URLDecoder.decode(cookie.getValue(), "UTF-8");
                }
            }
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    }
    return null;
}

From source file:com.emc.ecs.sync.target.CasTarget.java

@Override
public void configure(SyncSource source, Iterator<SyncFilter> filters, SyncTarget target) {
    if (!(source instanceof CasSource))
        throw new ConfigurationException("CasTarget is currently only compatible with CasSource");

    Assert.hasText(connectionString);

    try {/*w w w.j  a  v  a 2s.com*/
        FPPool.RegisterApplication(APPLICATION_NAME, APPLICATION_VERSION);

        // Check connection
        pool = new FPPool(connectionString);
        FPPool.PoolInfo info = pool.getPoolInfo();
        log.info("Connected to target: {} ({}) using CAS v.{}", info.getClusterName(), info.getClusterID(),
                info.getVersion());

        // verify we have appropriate privileges
        if (pool.getCapability(FPLibraryConstants.FP_WRITE, FPLibraryConstants.FP_ALLOWED).equals("False"))
            throw new IllegalArgumentException("WRITE is not supported for this pool connection");
    } catch (FPLibraryException e) {
        throw new RuntimeException("error creating pool: " + CasUtil.summarizeError(e), e);
    }
}

From source file:org.cloudfoundry.identity.uaa.api.group.impl.UaaGroupOperationsImpl.java

public void deleteGroup(String groupId) {
    Assert.hasText(groupId);

    helper.delete("/Groups/{id}", OBJ_REF, groupId);
}

From source file:cat.albirar.framework.sets.impl.SetBuilderDefaultImpl.java

/**
 * {@inheritDocs}/*from w  w w .  j  av  a2 s  .  co  m*/
 */
@Override
public ISetBuilder<T> pushPropertyPath(String propertyPath) {
    StringTokenizer stk;
    String spath;
    PropertyDescriptor pdesc;

    // Verify propertyPath
    Assert.hasText(propertyPath);
    stk = new StringTokenizer(propertyPath, ".");
    while (stk.hasMoreTokens()) {
        spath = stk.nextToken();
        if ((pdesc = currentModelDescriptor.getProperties().get(spath)) != null) {
            currentModelDescriptor = new ModelDescriptor(resolvePath(spath), propertyPath,
                    pdesc.getPropertyType());
        } else {
            throw new IllegalArgumentException(
                    "The path denoted by '" + propertyPath + "' at '" + getCurrentPathOrRoot() + "' for model '"
                            + rootModel.getName() + "' doesn't exists. Cannot be pushed!");
        }
    }
    pathStack.push(currentModelDescriptor);
    return this;
}

From source file:com.tcz.api.config.captcha.CaptchaEngine.java

/**
 * ?/* www .ja  v  a2  s. c om*/
 */
public void afterPropertiesSet() throws Exception {
    Assert.state(imageWidth > 0);
    Assert.state(imageHeight > 0);
    Assert.state(minFontSize > 0);
    Assert.state(maxFontSize > 0);
    Assert.state(minWordLength > 0);
    Assert.state(maxWordLength > 0);
    Assert.hasText(charString);

    Font[] fonts = new Font[] { new Font("Arial", Font.BOLD, maxFontSize),
            new Font("Bell", Font.BOLD, maxFontSize), new Font("Credit", Font.BOLD, maxFontSize),
            new Font("Impact", Font.BOLD, maxFontSize) };
    FontGenerator fontGenerator = new RandomFontGenerator(minFontSize, maxFontSize, fonts);
    BackgroundGenerator backgroundGenerator = StringUtils.isNotEmpty(backgroundImagePath)
            ? new FileReaderRandomBackgroundGenerator(imageWidth, imageHeight,
                    servletContext.getRealPath(backgroundImagePath))
            : new FunkyBackgroundGenerator(imageWidth, imageHeight);
    TextPaster textPaster = new RandomTextPaster(minWordLength, maxWordLength, Color.LIGHT_GRAY);
    CaptchaFactory[] captchaFactories = new CaptchaFactory[] {
            new GimpyFactory(new RandomWordGenerator(charString),
                    new ComposedWordToImage(fontGenerator, backgroundGenerator, textPaster)) };
    super.setFactories(captchaFactories);
}

From source file:org.synyx.hera.si.PluginRegistryAwareMessageHandler.java

/**
 * Creates a new {@link PluginRegistryAwareMessageHandler} for the given {@link PluginRegistry}, pluginType and a
 * method name to call./*from   w  w w .j  a va 2s. c  o  m*/
 * 
 * @param registry
 * @param pluginType
 * @param serviceMethodName
 */
@SuppressWarnings("unchecked")
public PluginRegistryAwareMessageHandler(PluginRegistry<? extends Plugin<?>, ?> registry,
        Class<? extends Plugin<?>> pluginType, String serviceMethodName) {

    Assert.notNull(registry);
    Assert.notNull(pluginType);
    Assert.hasText(serviceMethodName);

    this.registry = (PluginRegistry<? extends Plugin<?>, Object>) registry;
    this.serviceMethodName = serviceMethodName;
    this.pluginType = pluginType;
    this.delimiterType = GenericTypeResolver.resolveTypeArgument(pluginType, Plugin.class);

    verify();
}

From source file:org.synyx.hades.dao.query.QueryUtils.java

/**
 * Adds {@literal order by} clause to the JPQL query.
 * /*from   www.j a  v  a2  s .com*/
 * @param query
 * @param sort
 * @param alias
 * @return
 */
public static String applySorting(String query, Sort sort, String alias) {

    if (null == sort) {
        return query;
    }

    Assert.hasText(alias);

    StringBuilder builder = new StringBuilder(query);
    builder.append(" order by");

    for (Property property : sort) {
        builder.append(String.format(" %s.", alias));
        builder.append(property.getName());
        builder.append(" ");
        builder.append(property.getOrder().getJpaValue());
        builder.append(",");
    }

    builder.deleteCharAt(builder.length() - 1);

    return builder.toString();
}

From source file:org.cloudfoundry.identity.uaa.api.group.impl.UaaGroupOperationsImpl.java

public ScimGroupExternalMember createGroupMapping(ScimGroupExternalMemberType type, String identifier,
        String externalGroupDn) {
    Assert.notNull(type);//from w w w . j a va 2 s .c o m
    Assert.hasText(identifier);
    Assert.hasText(externalGroupDn);

    Map<String, Object> request = new LinkedHashMap<String, Object>(3);

    request.put("schemas", SCHEMAS);
    request.put(type.toString(), identifier);
    request.put("externalGroup", externalGroupDn);

    return helper.post("/Groups/External", request, EXT_GROUP_REF);
}

From source file:io.twipple.springframework.data.clusterpoint.convert.ClusterpointDocumentPropertyAccessor.java

/**
 * Read the value from the property.// w ww  .  j  a va 2s  .  c o  m
 *
 * @param context the evaluation context.
 * @param target  the target object.
 * @param name    the name of the property.
 * @return the typed value of the content to be read.
 */
@Override
public TypedValue read(@NotNull EvaluationContext context, @NotNull Object target, @NotNull String name) {

    Assert.notNull(context);
    Assert.notNull(target);
    Assert.isInstanceOf(ClusterpointDocument.class, target);
    Assert.hasText(name);

    ClusterpointDocument source = (ClusterpointDocument) target;

    Object value = source.read(context, name);
    return value == null ? TypedValue.NULL : new TypedValue(value);
}