org.apache.logging.log4j.util.Strings.isBlank()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(10.2k)|赞(0)|评价(0)|浏览(148)

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

Strings.isBlank介绍

[英]Checks if a String is blank. A blank string is one that is null, empty, or when trimmed using String#trim() is empty.
[中]检查字符串是否为空。空字符串是指空字符串,或者使用字符串#trim()进行修剪时为空字符串。

代码示例

代码示例来源:origin: org.apache.logging.log4j/log4j-api

/**
 * Checks if a String is not blank. The opposite of {@link #isBlank(String)}.
 *
 * @param s the String to check, may be {@code null}
 * @return {@code true} if the String is non-{@code null} and has content after being trimmed.
 */
public static boolean isNotBlank(final String s) {
  return !isBlank(s);
}

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

public static <T extends Hook> List<T> readHooksFromConf(HiveConf conf, HiveConf.ConfVars hookConfVar)
   throws InstantiationException, IllegalAccessException, ClassNotFoundException {
  String csHooks = conf.getVar(hookConfVar);
  List<T> hooks = new ArrayList<>();
  if (Strings.isBlank(csHooks)) {
   return hooks;
  }
  String[] hookClasses = csHooks.split(",");
  for (String hookClass : hookClasses) {
   T hook = (T) Class.forName(hookClass.trim(), true, Utilities.getSessionSpecifiedClassLoader()).newInstance();
   hooks.add(hook);
  }
  return hooks;
 }
}

代码示例来源:origin: spring-cloud/spring-cloud-gateway

private List<String> extractXForwardedValues(ServerWebExchange exchange) {
    List<String> xForwardedValues = exchange.getRequest().getHeaders()
        .get(X_FORWARDED_FOR);
    if (xForwardedValues == null || xForwardedValues.isEmpty()) {
      return Collections.emptyList();
    }
    if (xForwardedValues.size() > 1) {
      log.warn("Multiple X-Forwarded-For headers found, discarding all");
      return Collections.emptyList();
    }
    List<String> values = Arrays.asList(xForwardedValues.get(0).split(", "));
    if (values.size() == 1 && Strings.isBlank(values.get(0))) {
      return Collections.emptyList();
    }
    return values;
  }
}

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

/**
  * a convenience method to get the name of the member this function executes on. call this
  * function once in your function execution to avoid performance issues.
  *
  * @return member name or id if name is blank
  */
 default String getMemberName() {
  DistributedMember member = getCache().getDistributedSystem().getDistributedMember();

  // if this member has name, use it, otherwise, use the id
  String memberName = member.getName();
  if (!Strings.isBlank(memberName)) {
   return memberName;
  }

  return member.getId();
 }
}

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

String keyStorePath = hiveConf.getVar(
 ConfVars.HIVE_SERVER2_WEBUI_SSL_KEYSTORE_PATH);
if (Strings.isBlank(keyStorePath)) {
 throw new IllegalArgumentException(
  ConfVars.HIVE_SERVER2_WEBUI_SSL_KEYSTORE_PATH.varname
String spnegoKeytab = hiveConf.getVar(
  ConfVars.HIVE_SERVER2_WEBUI_SPNEGO_KEYTAB);
if (Strings.isBlank(spnegoPrincipal) || Strings.isBlank(spnegoKeytab)) {
 throw new IllegalArgumentException(
  ConfVars.HIVE_SERVER2_WEBUI_SPNEGO_PRINCIPAL.varname
String allowedMethods = hiveConf.getVar(ConfVars.HIVE_SERVER2_WEBUI_CORS_ALLOWED_METHODS);
String allowedHeaders = hiveConf.getVar(ConfVars.HIVE_SERVER2_WEBUI_CORS_ALLOWED_HEADERS);
if (Strings.isBlank(allowedOrigins) || Strings.isBlank(allowedMethods) || Strings.isBlank(allowedHeaders)) {
 throw new IllegalArgumentException("CORS enabled. But " +
  ConfVars.HIVE_SERVER2_WEBUI_CORS_ALLOWED_ORIGINS.varname + "/" +

代码示例来源:origin: dadoonet/fscrawler

ReproduceErrorMessageBuilder appendProperties(String... properties) {
  for (String sysPropName : properties) {
    if (!Strings.isBlank(System.getProperty(sysPropName))) {
      appendOpt(sysPropName, System.getProperty(sysPropName));
    }
  }
  return this;
}

代码示例来源:origin: dadoonet/fscrawler

/**
 * Append a single VM option.
 */
@Override
public ReproduceErrorMessageBuilder appendOpt(String sysPropName, String value) {
  if (sysPropName.equals(SYSPROP_ITERATIONS())) { // we don't want the iters to be in there!
    return this;
  }
  if (sysPropName.equals(SYSPROP_TESTMETHOD())) {
    //don't print out the test method, we print it ourselves in appendAllOpts
    //without filtering out the parameters (needed for REST tests)
    return this;
  }
  if (sysPropName.equals(SYSPROP_PREFIX())) {
    // we always use the default prefix
    return this;
  }
  if (!Strings.isBlank(value)) {
    if (value.indexOf(' ') >= 0) {
      return super.appendOpt(sysPropName, '"' + value + '"');
    }
    return super.appendOpt(sysPropName, value);
  }
  return this;
}

代码示例来源:origin: FlowCI/flow-platform

@Override
public void exec(Plugin plugin) {
  log.trace("Push tags to local");
  if (!Strings.isBlank(plugin.getPluginDetail().getImage()) && !Strings
    .isBlank(plugin.getPluginDetail().getBuild())) {
    return;
  }
  try {
    // put from cache to local git workspace
    Path cachePath = gitCachePath(plugin);
    String latestGitTag = plugin.getTag();
    JGitUtil.push(cachePath, LOCAL_REMOTE, latestGitTag);
    // set currentTag latestTag
    plugin.setCurrentTag(latestGitTag);
    updatePluginStatus(plugin, INSTALLED);
  } catch (GitException e) {
    log.error("Git Push", e);
    throw new PluginException("Git Push", e);
  }
}

代码示例来源:origin: FlowCI/flow-platform

@Override
public void exec(Plugin plugin) {
  try {
    // only build and image all in value to pull image
    if (!Strings.isBlank(plugin.getPluginDetail().getBuild()) && !Strings
      .isBlank(plugin.getPluginDetail().getImage())) {
      log.trace("Start build code");
      // put from cache to local git workspace
      Path cachePath = gitCachePath(plugin);
      String latestGitTag = plugin.getTag();
      JGitUtil.checkout(cachePath, latestGitTag);
      // first pull image and build
      if (!runInDocker) {
        dockerPullAndBuild(plugin);
      } else {
        // if run in docker only build
        build(plugin);
      }
      // second detect outputs
      detectBuildArtifacts(plugin);
      // third push outputs to localRepo
      pushArtifactsToLocalRepo(plugin);
      log.trace("Finish build code");
    }
  } catch (Throwable e) {
    log.error("Git Build", e);
    throw new PluginException("Git Build", e);
  }
}

代码示例来源:origin: com.vlkan.log4j2/log4j2-redis-appender

private RedisThrottlerConfig(Builder builder) {
  this.bufferSize = builder.bufferSize;
  this.batchSize = builder.batchSize;
  this.flushPeriodMillis = builder.flushPeriodMillis;
  this.maxEventCountPerSecond = builder.maxEventCountPerSecond;
  this.maxByteCountPerSecond = builder.maxByteCountPerSecond;
  this.jmxBeanName = isBlank(builder.jmxBeanName) ? null : builder.jmxBeanName;
}

代码示例来源:origin: ops4j/org.ops4j.pax.logging

/**
 * Checks if a String is not blank. The opposite of {@link #isBlank(String)}.
 *
 * @param s the String to check, may be {@code null}
 * @return {@code true} if the String is non-{@code null} and has content after being trimmed.
 */
public static boolean isNotBlank(final String s) {
  return !isBlank(s);
}

代码示例来源:origin: ops4j/org.ops4j.pax.logging

/**
 * Adds a package name to be scanned for plugins. Must be invoked prior to plugins being collected.
 * 
 * @param p The package name. Ignored if {@code null} or empty.
 */
public static void addPackage(final String p) {
  if (Strings.isBlank(p)) {
    return;
  }
  PACKAGES.addIfAbsent(p);
}

代码示例来源:origin: fr.pilato.elasticsearch.crawler/fscrawler-test-framework

ReproduceErrorMessageBuilder appendProperties(String... properties) {
  for (String sysPropName : properties) {
    if (!Strings.isBlank(System.getProperty(sysPropName))) {
      appendOpt(sysPropName, System.getProperty(sysPropName));
    }
  }
  return this;
}

代码示例来源:origin: io.toast-tk/toast-tk-dao

@Override
public void setId(String id) {
  this.id = Strings.isBlank(id) || Strings.isEmpty(id) ? null : new ObjectId(id);
}

代码示例来源:origin: SleepyTrousers/EnderIO

public static @Nonnull String block2Modname(IForgeRegistryEntry<?> block) {
 if (block != null) {
  final ResourceLocation registryName = block.getRegistryName();
  if (registryName != null) {
   final String modid = registryName.getResourceDomain();
   if (!Strings.isBlank(modid)) {
    final ModContainer modContainer = Loader.instance().getIndexedModList().get(modid);
    if (modContainer != null) {
     String name = modContainer.getName();
     if (name != null && !name.trim().isEmpty()) {
      return name;
     }
    }
   }
  }
 }
 return "(???)";
}

代码示例来源:origin: ops4j/org.ops4j.pax.logging

/**
 * Initializes the Logging Context.
 * @param name The Context name.
 * @param loader The ClassLoader for the Context (or null).
 * @param configLocation The configuration for the logging context (or null, or blank).
 * @param externalContext The external context to be attached to the LoggerContext
 * @return The LoggerContext or null if an error occurred (check the status logger).
 */
public static LoggerContext initialize(final String name, final ClassLoader loader, final String configLocation,
    final Object externalContext) {
  if (Strings.isBlank(configLocation)) {
    return initialize(name, loader, (URI) null, externalContext);
  }
  if (configLocation.contains(",")) {
    final String[] parts = configLocation.split(",");
    String scheme = null;
    final List<URI> uris = new ArrayList<>(parts.length);
    for (final String part : parts) {
      final URI uri = NetUtils.toURI(scheme != null ? scheme + ":" + part.trim() : part.trim());
      if (scheme == null && uri.getScheme() != null) {
        scheme = uri.getScheme();
      }
      uris.add(uri);
    }
    return initialize(name, loader, uris, externalContext);
  }
  return initialize(name, loader, NetUtils.toURI(configLocation), externalContext);
}

代码示例来源:origin: fr.pilato.elasticsearch.crawler/fscrawler-test-framework

/**
 * Append a single VM option.
 */
@Override
public ReproduceErrorMessageBuilder appendOpt(String sysPropName, String value) {
  if (sysPropName.equals(SYSPROP_ITERATIONS())) { // we don't want the iters to be in there!
    return this;
  }
  if (sysPropName.equals(SYSPROP_TESTMETHOD())) {
    //don't print out the test method, we print it ourselves in appendAllOpts
    //without filtering out the parameters (needed for REST tests)
    return this;
  }
  if (sysPropName.equals(SYSPROP_PREFIX())) {
    // we always use the default prefix
    return this;
  }
  if (!Strings.isBlank(value)) {
    if (value.indexOf(' ') >= 0) {
      return super.appendOpt(sysPropName, '"' + value + '"');
    }
    return super.appendOpt(sysPropName, value);
  }
  return this;
}

代码示例来源:origin: ops4j/org.ops4j.pax.logging

if (Strings.isBlank(pkg)) {

代码示例来源:origin: org.apache.hive/hive-service

String keyStorePath = hiveConf.getVar(
 ConfVars.HIVE_SERVER2_WEBUI_SSL_KEYSTORE_PATH);
if (Strings.isBlank(keyStorePath)) {
 throw new IllegalArgumentException(
  ConfVars.HIVE_SERVER2_WEBUI_SSL_KEYSTORE_PATH.varname
String spnegoKeytab = hiveConf.getVar(
  ConfVars.HIVE_SERVER2_WEBUI_SPNEGO_KEYTAB);
if (Strings.isBlank(spnegoPrincipal) || Strings.isBlank(spnegoKeytab)) {
 throw new IllegalArgumentException(
  ConfVars.HIVE_SERVER2_WEBUI_SPNEGO_PRINCIPAL.varname
String allowedMethods = hiveConf.getVar(ConfVars.HIVE_SERVER2_WEBUI_CORS_ALLOWED_METHODS);
String allowedHeaders = hiveConf.getVar(ConfVars.HIVE_SERVER2_WEBUI_CORS_ALLOWED_HEADERS);
if (Strings.isBlank(allowedOrigins) || Strings.isBlank(allowedMethods) || Strings.isBlank(allowedHeaders)) {
 throw new IllegalArgumentException("CORS enabled. But " +
  ConfVars.HIVE_SERVER2_WEBUI_CORS_ALLOWED_ORIGINS.varname + "/" +

相关文章