org.apache.commons.lang3.StringUtils.isAnyBlank()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(10.0k)|赞(0)|评价(0)|浏览(770)

本文整理了Java中org.apache.commons.lang3.StringUtils.isAnyBlank()方法的一些代码示例,展示了StringUtils.isAnyBlank()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringUtils.isAnyBlank()方法的具体详情如下:
包路径:org.apache.commons.lang3.StringUtils
类名称:StringUtils
方法名:isAnyBlank

StringUtils.isAnyBlank介绍

[英]Checks if any of the CharSequences are empty ("") or null or whitespace only.

Whitespace is defined by Character#isWhitespace(char).

StringUtils.isAnyBlank((String) null)    = true 
StringUtils.isAnyBlank((String[]) null)  = false 
StringUtils.isAnyBlank(null, "foo")      = true 
StringUtils.isAnyBlank(null, null)       = true 
StringUtils.isAnyBlank("", "bar")        = true 
StringUtils.isAnyBlank("bob", "")        = true 
StringUtils.isAnyBlank("  bob  ", null)  = true 
StringUtils.isAnyBlank(" ", "bar")       = true 
StringUtils.isAnyBlank(new String[] {})  = false 
StringUtils.isAnyBlank(new String[]{""}) = true 
StringUtils.isAnyBlank("foo", "bar")     = false

[中]检查是否有任何字符序列为空(“”)、空或仅为空白。
空格由字符#isWhitespace(char)定义。

StringUtils.isAnyBlank((String) null)    = true 
StringUtils.isAnyBlank((String[]) null)  = false 
StringUtils.isAnyBlank(null, "foo")      = true 
StringUtils.isAnyBlank(null, null)       = true 
StringUtils.isAnyBlank("", "bar")        = true 
StringUtils.isAnyBlank("bob", "")        = true 
StringUtils.isAnyBlank("  bob  ", null)  = true 
StringUtils.isAnyBlank(" ", "bar")       = true 
StringUtils.isAnyBlank(new String[] {})  = false 
StringUtils.isAnyBlank(new String[]{""}) = true 
StringUtils.isAnyBlank("foo", "bar")     = false

代码示例

代码示例来源:origin: org.apache.commons/commons-lang3

/**
 * <p>Checks if none of the CharSequences are empty (""), null or whitespace only.</p>
 *
 * <p>Whitespace is defined by {@link Character#isWhitespace(char)}.</p>
 *
 * <pre>
 * StringUtils.isNoneBlank((String) null)    = false
 * StringUtils.isNoneBlank((String[]) null)  = true
 * StringUtils.isNoneBlank(null, "foo")      = false
 * StringUtils.isNoneBlank(null, null)       = false
 * StringUtils.isNoneBlank("", "bar")        = false
 * StringUtils.isNoneBlank("bob", "")        = false
 * StringUtils.isNoneBlank("  bob  ", null)  = false
 * StringUtils.isNoneBlank(" ", "bar")       = false
 * StringUtils.isNoneBlank(new String[] {})  = true
 * StringUtils.isNoneBlank(new String[]{""}) = false
 * StringUtils.isNoneBlank("foo", "bar")     = true
 * </pre>
 *
 * @param css  the CharSequences to check, may be null or empty
 * @return {@code true} if none of the CharSequences are empty or null or whitespace only
 * @since 3.2
 */
public static boolean isNoneBlank(final CharSequence... css) {
 return !isAnyBlank(css);
}

代码示例来源:origin: apache/kylin

private void checkOverrideProps(ProjectInstance prj) throws IOException {
  LinkedHashMap<String, String> overrideProps = prj.getOverrideKylinProps();
  if (overrideProps != null) {
    Iterator<Map.Entry<String, String>> iterator = overrideProps.entrySet().iterator();
    while (iterator.hasNext()) {
      Map.Entry<String, String> entry = iterator.next();
      if (StringUtils.isAnyBlank(entry.getKey(), entry.getValue())) {
        throw new IllegalStateException("Property key/value must not be blank");
      }
    }
  }
}

代码示例来源:origin: org.apache.commons/commons-lang3

@Test
public void testIsAnyBlank() {
  assertTrue(StringUtils.isAnyBlank((String) null));
  assertFalse(StringUtils.isAnyBlank((String[]) null));
  assertTrue(StringUtils.isAnyBlank(null, "foo"));
  assertTrue(StringUtils.isAnyBlank(null, null));
  assertTrue(StringUtils.isAnyBlank("", "bar"));
  assertTrue(StringUtils.isAnyBlank("bob", ""));
  assertTrue(StringUtils.isAnyBlank("  bob  ", null));
  assertTrue(StringUtils.isAnyBlank(" ", "bar"));
  assertFalse(StringUtils.isAnyBlank("foo", "bar"));
}

代码示例来源:origin: wxyyxc1992/Backend-Boilerplates

@Override
public User findUser(String username, String domain) {
  if (StringUtils.isAnyBlank(username, domain)) {
    return null;
  } else {
    Collection<? extends GrantedAuthority> authorities = new ArrayList<>();
    User user =  new User(username, domain, 
      "$2a$10$U3GhSMpsMSOE8Kqsbn58/edxDBKlVuYMh7qk/7ErApYFjJzi2VG5K", true, 
      true, true, true, authorities);
    return user;
  }
}

代码示例来源:origin: wxyyxc1992/Backend-Boilerplates

@Override
public User findUser(String username, String domain) {
  if (StringUtils.isAnyBlank(username, domain)) {
    return null;
  } else {
    Collection<? extends GrantedAuthority> authorities = new ArrayList<>();
    User user =  new User(username, domain, 
      "$2a$10$U3GhSMpsMSOE8Kqsbn58/edxDBKlVuYMh7qk/7ErApYFjJzi2VG5K", true, 
      true, true, true, authorities);
    return user;
  }
}

代码示例来源:origin: jtalks-org/jcommune

private void addCredentialsIfAny(ClientResource clientResource){
    if (!StringUtils.isAnyBlank(login, password))
      clientResource.setChallengeResponse(ChallengeScheme.HTTP_BASIC, login, password);
  }
}

代码示例来源:origin: vakinge/jeesuite-libs

@Override
public void afterPropertiesSet() throws Exception {
  if(jedisPoolConfig == null)throw new Exception("jedisPoolConfig Not config ??");
  if(org.apache.commons.lang3.StringUtils.isAnyBlank(mode,servers)){
    throw new Exception("type or servers is empty??");
  }
  registerRedisProvier(); 
}

代码示例来源:origin: liuweijw/fw-cloud-framework

@GetMapping(produces = "text/plain;charset=utf-8")
public String authGet(@RequestParam(name = "signature", required = false) String signature,
    @RequestParam(name = "timestamp", required = false) String timestamp,
    @RequestParam(name = "nonce", required = false) String nonce,
    @RequestParam(name = "echostr", required = false) String echostr) {
  this.logger
      .info("\n接收到来自微信服务器的认证消息:[{}, {}, {}, {}]", signature, timestamp, nonce, echostr);
  if (StringUtils.isAnyBlank(signature, timestamp, nonce, echostr)) { throw new IllegalArgumentException(
      "请求参数非法,请核实!"); }
  if (this.wxService.checkSignature(timestamp, nonce, signature)) { return echostr; }
  return "非法请求";
}

代码示例来源:origin: ustcwudi/springboot-seed

@GetMapping(produces = "text/plain;charset=utf-8" )
public String authGet(@RequestParam(name = "signature", required = false) String signature,
           @RequestParam(name = "timestamp", required = false) String timestamp,
           @RequestParam(name = "nonce", required = false) String nonce,
           @RequestParam(name = "echostr", required = false) String echostr) {
  if (StringUtils.isAnyBlank(signature, timestamp, nonce, echostr)) {
    throw new IllegalArgumentException("invalid argument" );
  }
  if (this.wxService.checkSignature(timestamp, nonce, signature)) {
    return echostr;
  }
  return "非法请求";
}

代码示例来源:origin: org.apache.kylin/kylin-core-metadata

private void checkOverrideProps(ProjectInstance prj) throws IOException {
  LinkedHashMap<String, String> overrideProps = prj.getOverrideKylinProps();
  if (overrideProps != null) {
    Iterator<Map.Entry<String, String>> iterator = overrideProps.entrySet().iterator();
    while (iterator.hasNext()) {
      Map.Entry<String, String> entry = iterator.next();
      if (StringUtils.isAnyBlank(entry.getKey(), entry.getValue())) {
        throw new IllegalStateException("Property key/value must not be blank");
      }
    }
  }
}

代码示例来源:origin: wxyyxc1992/Backend-Boilerplates

@Override
  public UserDetails loadUserByUsernameAndDomain(String username, String domain) throws UsernameNotFoundException {
    if (StringUtils.isAnyBlank(username, domain)) {
      throw new UsernameNotFoundException("Username and domain must be provided");
    }
    User user = userRepository.findUser(username, domain);
    if (user == null) {
      throw new UsernameNotFoundException(
        String.format("Username not found for domain, username=%s, domain=%s", 
          username, domain));
    }
    return user;
  }
}

代码示例来源:origin: vakinge/jeesuite-libs

public String getCallbackRuleAsJson(){
  if(StringUtils.isAnyBlank(callbackBody,callbackHost,callbackUrl))return null;
  Map<String, String> map = new HashMap<>(4);
  map.put("callbackBody", callbackBody);
  map.put("callbackHost", callbackHost);
  map.put("callbackUrl", callbackUrl);
  map.put("callbackBodyType", getCallbackBodyType());
  return JsonUtils.toJson(map);
}

代码示例来源:origin: com.blackducksoftware.integration/integration-rest

@Override
protected void validate(final BuilderStatus builderStatus) {
  if (StringUtils.isAnyBlank(username, password) && !StringUtils.isAllBlank(username, password)) {
    builderStatus.addErrorMessage("The username and password must both be populated or both be empty.");
  }
}

代码示例来源:origin: com.norconex.collectors/norconex-importer

@Override
  public void validateProperties() throws ImporterHandlerException {
    if (StringUtils.isAnyBlank(getApiKey())) {
      throw new ImporterHandlerException(
          "apiKey must be specified.");
    }
  }
});

代码示例来源:origin: com.norconex.collectors/norconex-importer

@Override
  public void validateProperties() throws ImporterHandlerException {
    if (StringUtils.isAnyBlank(getUserKey())) {
      throw new ImporterHandlerException(
          "userKey must be specified.");
    }
  }
});

代码示例来源:origin: com.norconex.collectors/norconex-importer

@Override
  public void validateProperties() throws ImporterHandlerException {
    if (StringUtils.isAnyBlank(getApiKey())) {
      throw new ImporterHandlerException(
          "apiKey must be specified.");
    }
  }
});

代码示例来源:origin: kamax-matrix/mxhsd

public Homeserver(GlobalStateHolder state) {
  if (StringUtils.isAnyBlank(state.getAppName(), state.getAppVersion())) {
    throw new IllegalArgumentException("Application name and version must be set");
  }
  this.state = state;
  log.info("Homeserver is {}/{}", state.getAppName(), state.getAppVersion());
}

代码示例来源:origin: com.norconex.collectors/norconex-importer

@Override
  public void validateProperties() throws ImporterHandlerException {
    if (StringUtils.isAnyBlank(getClientId(), getClientSecret())) {
      throw new ImporterHandlerException(
          "Both clientId and clientSecret must be specified.");
    }
  }
});

代码示例来源:origin: com.norconex.collectors/norconex-importer

@Override
  public void validateProperties() throws ImporterHandlerException {
    if (StringUtils.isAnyBlank(getSmtPath(), getScriptPath())) {
      throw new ImporterHandlerException(
          "Both smtPath and scriptPath must be specified.");
    }
  }
});

代码示例来源:origin: WeBankFinTech/FATE

@Override
  public Dtable load(StoreInfo key) throws Exception {
    if (StringUtils.isAnyBlank(key.getNameSpace(), key.getTableName())) {
      throw new StorageNotExistsException(key);
    }
    Dtable result = storageMetaClient.getTable(key.getNameSpace(), key.getTableName());
    return result;
  }
});

相关文章

StringUtils类方法