Example usage for org.apache.commons.lang3 StringUtils isEmpty

List of usage examples for org.apache.commons.lang3 StringUtils isEmpty

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils isEmpty.

Prototype

public static boolean isEmpty(final CharSequence cs) 

Source Link

Document

Checks if a CharSequence is empty ("") or null.

 StringUtils.isEmpty(null)      = true StringUtils.isEmpty("")        = true StringUtils.isEmpty(" ")       = false StringUtils.isEmpty("bob")     = false StringUtils.isEmpty("  bob  ") = false 

NOTE: This method changed in Lang version 2.0.

Usage

From source file:com.github.rvesse.airline.restrictions.common.NotEmptyRestriction.java

@Override
protected boolean isValid(String value) {
    return !StringUtils.isEmpty(value);
}

From source file:eml.studio.shared.util.Aes.java

/** 
 * Base 64 decode // www  .j a  v  a  2s. co m
 * 
 * @param base64Code 
 * @return 
 * @throws Exception 
 */
public static byte[] base64Decode(String base64Code) throws Exception {
    return StringUtils.isEmpty(base64Code) ? null : new BASE64Decoder().decodeBuffer(base64Code);
}

From source file:com.netflix.spinnaker.halyard.config.validate.v1.security.LdapRoleProviderValidator.java

@Override
public void validate(ConfigProblemSetBuilder p, LdapRoleProvider l) {
    if (l.getUrl() == null) {
        p.addProblem(Severity.ERROR, "No url specified.");
    }//w w w  .  j a v  a2s.c o m
    if (StringUtils.isEmpty(l.getManagerDn()) && !StringUtils.isEmpty(l.getManagerPassword())) {
        p.addProblem(Problem.Severity.ERROR, "No manager dn specified.");
    }
    if (StringUtils.isEmpty(l.getManagerPassword()) && !StringUtils.isEmpty(l.getManagerDn())) {
        p.addProblem(Problem.Severity.ERROR, "No manager password specified.");
    }
}

From source file:com.webbfontaine.valuewebb.model.validators.TemplateValidator.java

@Override
public void validate(FacesContext facesContext, UIComponent uiComponent, Object value)
        throws ValidatorException {
    LOGGER.debug("Starting to execute validator");

    CharSequence enteredValue = (CharSequence) value;
    Pd pd = (Pd) Component.getInstance("pdInstance", ScopeType.EVENT, true);

    if (!StringUtils.isEmpty(pd.getHsCodeF()) && StringUtils.isEmpty(enteredValue)) {
        TemplateSpec templateSpec = pd.getFtemplate().getSpec();
        String id = uiComponent.getId();
        if (TemplateSpec.checkRequired(templateSpec.getField(id), pd.getHsCodeF())) {
            ErrorHandling.addFacesMessageError(uiComponent.getClientId(facesContext),
                    Messages.VALUE_IS_REQUIRED);
        }/* w ww.j  a v  a  2 s. c o  m*/
    }
}

From source file:io.cloudslang.content.utils.CollectionUtilities.java

/**
 * Splits the stringArray by the delimiter into an array of strings ignoring the escaped delimiters
 *
 * @param stringArray the string to be split
 * @param delimiter   the delimiter by which to split the stringArray
 * @return an array of Strings//from w  w  w  . ja v a 2  s . c  om
 */
@NotNull
public static String[] toArray(@Nullable final String stringArray, @NotNull final String delimiter) {
    if (StringUtils.isEmpty(stringArray)) {
        return new String[0];
    }
    final String regex = "(?<!\\\\)" + Pattern.quote(delimiter);
    return stringArray.split(regex);
}

From source file:ch.cyberduck.core.manta.MantaHomeFinderFeatureTest.java

@Test
public void testHomeFeature() throws BackgroundException {
    final Path drive = new MantaHomeFinderFeature(session).find();
    assertNotNull(drive);/*from   w  w w. ja  v a 2 s  .co m*/
    assertFalse(drive.isRoot());
    assertTrue(drive.isPlaceholder());
    assertNotEquals("null", drive.getName());
    assertFalse(StringUtils.isEmpty(drive.getName()));
}

From source file:com.renlg.user.controller.UserController.java

/**
 * /*from www  .ja  v a  2  s .  c  o  m*/
 * @param user
 * @return
 */
@RequestMapping("create")
@ResponseBody
public JsonResult create(User user) {
    JsonResult result = new JsonResult();
    if (StringUtils.isEmpty(user.getUserName()) || StringUtils.isEmpty(user.getNickName())) {
        result.setSuccess(false);
        result.setMessage("??");
    } else {
        userService.create(user);
    }
    return result;
}

From source file:info.novatec.testit.livingdoc.util.NameUtils.java

/**
 * Tries to convert <code>string</code> to a Java class name by following a
 * few simple steps:/*from   ww  w .j  ava2 s .  c  o  m*/
 * <p>
 * <p>
 * <ul>
 * <li>First of all, <code>string</code> gets <i>camel cased</i>, the usual
 * Java class naming convention.
 * <li>Secondly, any whitespace, by virtue of
 * <code>Character.isWhitespace()</code> is removed from the camel cased
 * <code>string</code>.
 * <li>Third, all accented characters (diacritis) are replaced by their
 * non-accented equivalent (ex: \u00e9 -&gt; e)</li>
 * <li>Fourth, all non java identifier characters are removed</li>
 * </ul>
 * <p>
 * The only exception to executing these two steps is when
 * <code>string</code> represents a fully-qualified class name. To check if
 * <code>string</code> represents a fully-qualified class name, a simple
 * validation of the existence of the '.' character is made on
 * <code>string</code>.
 * 
 * @param s The String that may represent a Java class name
 * @return The input string converted by following the documented steps
 */
public static String toClassName(String s) {
    if (StringUtils.isEmpty(s) || s.contains(".")) {
        return s;
    }
    return removeNonJavaIdentifierCharacters(
            StringUtils.stripAccents(StringUtils.deleteWhitespace(WordUtils.capitalizeFully(s))));
}

From source file:ext.usercenter.UserAuthService.java

/**
 * ??UId<br>// w  w  w. j  a v a  2  s  .  c o m
 * null
 * 
 * @param session ?nullHTTP Session
 * @return uidnull
 */
public static String getLoginUid(Session session) {
    if (null == session) {
        throw new IllegalArgumentException("illegal method input param. params: session=" + session);
    }

    String token = session.get(LOGIN_TOKEN_SESSION_KEY);
    if (StringUtils.isEmpty(token)) {
        return null;
    }

    String uid = getTokenUidLocalCache(token);

    // ???
    if (null == uid) {
        UCResult<UCUser> ucResult = UCClient.queryUserInfoByToken(token);
        if (ucResult.isSuccess()) {
            uid = ucResult.data.uid;
            setTokenUidLocalCache(uid, token);
        } else if (!ucResult.noMatchData()) {
            LOGGER.error("queryUserInfoByToken error: " + ucResult);
        }
    }

    return uid;
}

From source file:com.netflix.spinnaker.fiat.model.resources.Role.java

public Role setName(String name) {
    if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException("name cannot be null or empty");
    }/*from   w ww  .  ja  v  a  2 s .  c om*/
    this.name = name.toLowerCase();
    return this;
}