/** * 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); }
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; } }
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; } }
/** * 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(); } }
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 + "/" +
ReproduceErrorMessageBuilder appendProperties(String... properties) { for (String sysPropName : properties) { if (!Strings.isBlank(System.getProperty(sysPropName))) { appendOpt(sysPropName, System.getProperty(sysPropName)); } } return this; }
/** * 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; }
@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); } }
@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); } }
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; }
/** * 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); }
/** * 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); }
ReproduceErrorMessageBuilder appendProperties(String... properties) { for (String sysPropName : properties) { if (!Strings.isBlank(System.getProperty(sysPropName))) { appendOpt(sysPropName, System.getProperty(sysPropName)); } } return this; }
@Override public void setId(String id) { this.id = Strings.isBlank(id) || Strings.isEmpty(id) ? null : new ObjectId(id); }
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 "(???)"; }
/** * 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); }
/** * 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; }
if (Strings.isBlank(pkg)) {
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 + "/" +