List of usage examples for com.google.common.base Strings isNullOrEmpty
public static boolean isNullOrEmpty(@Nullable String string)
From source file:org.apache.james.mailbox.store.mail.model.AttachmentId.java
public static AttachmentId from(String id) { Preconditions.checkArgument(!Strings.isNullOrEmpty(id)); return new AttachmentId(id); }
From source file:com.streamsets.pipeline.stage.util.tls.TlsConfigBeanUpgradeUtil.java
public static void upgradeHttpSslConfigBeanToTlsConfigBean(List<Config> configs, String configPrefix) { final String newTrustStorePath = configPrefix + "tlsConfig.trustStoreFilePath"; final String newKeyStorePath = configPrefix + "tlsConfig.keyStoreFilePath"; UpgraderUtils.moveAllTo(configs, configPrefix + "sslConfig.trustStorePath", newTrustStorePath, configPrefix + "sslConfig.trustStorePassword", configPrefix + "tlsConfig.trustStorePassword", configPrefix + "sslConfig.keyStorePath", newKeyStorePath, configPrefix + "sslConfig.keyStorePassword", configPrefix + "tlsConfig.keyStorePassword"); boolean hasKeyStore = false; boolean hasTrustStore = false; for (Config config : configs) { if (newKeyStorePath.equals(config.getName())) { hasKeyStore = !Strings.isNullOrEmpty((String) config.getValue()); } else if (newTrustStorePath.equals(config.getName())) { hasTrustStore = !Strings.isNullOrEmpty((String) config.getValue()); }/*from w w w. ja v a 2 s . c om*/ } configs.add(new Config(configPrefix + "tlsConfig.tlsEnabled", hasTrustStore || hasKeyStore)); }
From source file:org.apache.isis.core.progmodel.facets.object.defaults.annotation.DefaultedFacetAnnotation.java
private static String providerName(final Class<?> annotatedClass, final IsisConfiguration configuration) { final Defaulted annotation = annotatedClass.getAnnotation(Defaulted.class); final String providerName = annotation.defaultsProviderName(); if (!Strings.isNullOrEmpty(providerName)) { return providerName; }/*from www. j a va 2 s. c om*/ return DefaultsProviderUtil.defaultsProviderNameFromConfiguration(annotatedClass, configuration); }
From source file:org.haiku.haikudepotserver.multipage.markup.PlainTextContentTag.java
@Override protected int doStartTagInternal() throws Exception { if (!Strings.isNullOrEmpty(value)) { pageContext.getOut().print(String.join("<br/>\n", Arrays.stream(value.split("[\n\r]")) .map(s -> HtmlEscapers.htmlEscaper().escape(s)).collect(Collectors.toList()))); }//w w w .ja v a 2 s . c o m return SKIP_BODY; }
From source file:com.palantir.docker.compose.connection.Ports.java
public static Ports parseFromDockerComposePs(String psOutput, String dockerMachineIp) { Preconditions.checkArgument(!Strings.isNullOrEmpty(psOutput), "No container found"); Matcher matcher = PORT_PATTERN.matcher(psOutput); List<DockerPort> ports = new ArrayList<>(); while (matcher.find()) { String matchedIpAddress = matcher.group(IP_ADDRESS); String ip = matchedIpAddress.equals(NO_IP_ADDRESS) ? dockerMachineIp : matchedIpAddress; int externalPort = Integer.parseInt(matcher.group(EXTERNAL_PORT)); int internalPort = Integer.parseInt(matcher.group(INTERNAL_PORT)); ports.add(new DockerPort(ip, externalPort, internalPort)); }/*w ww . j a v a 2s .c o m*/ return new Ports(ports); }
From source file:com.cinchapi.concourse.util.Environments.java
/** * Ensure that we return the correct environment with * alphanumeric-char name for the specified {@code env}. * e.g. if {@code env} is null or empty then return the * {@link GlobalState#DEFAULT_ENVIRONMENT}. * /*from w ww. j a v a2 s . co m*/ * @param env * @return the environment name */ public static String sanitize(String env) { env = Strings.isNullOrEmpty(env) ? DEFAULT_ENVIRONMENT : env; Matcher matcher = SANITIZER.matcher(env); env = matcher.replaceAll(""); // ConcourseServer checks to make sure // sanitizing the default environment // won't turn it into an empty string return env; }
From source file:uk.nhs.fhir.util.FhirServerProperties.java
public static Properties parseProperties(String propertiesFile) { if (Strings.isNullOrEmpty(propertiesFile)) { throw new IllegalArgumentException("Null properties File path"); }/*from ww w. java 2 s.com*/ Properties properties = new Properties(); //Load the property values into a local object from the property file. boolean absolute = (propertiesFile.startsWith("/") || (propertiesFile.length() > 1 && propertiesFile.charAt(1) == ':')); if (absolute) { try (FileInputStream in = new FileInputStream(new File(propertiesFile))) { properties.load(in); } catch (Exception ex) { throw new IllegalStateException("Error loading properties from file " + propertiesFile, ex); } } else { try (InputStream in = FhirServerProperties.class.getClassLoader().getResourceAsStream(propertiesFile)) { properties.load(in); } catch (Exception ex) { throw new IllegalStateException("Error loading properties from file " + propertiesFile, ex); } } return properties; }
From source file:com.indeed.imhotep.sql.parser.Preprocessor.java
public static String applyAliases(String clause, Map<String, String> aliases) { if (Strings.isNullOrEmpty(clause)) { return clause; }//from ww w. ja va2 s. co m // tokenize while ignoring quoted strings final List<Token> tokens = tokenizer.parse(clause); // for each token, look up the NameExpression in a map and if found replace with the provided replacement expression for (int i = tokens.size() - 1; i >= 0; i--) { final Token token = tokens.get(i); final String tokenStr = tokenAsString(token); final String replacement = aliases.get(tokenStr); if (replacement != null) { // TODO: optimize? clause = clause.substring(0, token.index()) + replacement + clause.substring(token.index() + token.length()); } } return clause; }
From source file:org.apache.isis.viewer.wicket.ui.util.CssClassAppender.java
/** * Adds CSS class to tag (providing that the class is non-null and non-empty). *//*from w ww.j a v a 2 s . c o m*/ public static void appendCssClassTo(final ComponentTag tag, final String cssClass) { if (Strings.isNullOrEmpty(cssClass)) { return; } tag.append("class", cssClass, " "); }
From source file:ezbake.common.io.ClasspathResources.java
public static URL getResource(String resource) { // no need to attempt to load if (Strings.isNullOrEmpty(resource)) { return null; }//from w ww . j av a 2 s . c o m // First we will do it from class loaders URL retVal = null; try { retVal = Resources.getResource(resource); } catch (IllegalArgumentException ignored) { // We are ignoring this so we can try to load from the runtime classes } retVal = ClasspathResources.class.getClass().getResource(resource); if (retVal == null) { /* Just in case the java.class and ClasspathResources are loaded from differrent class loader then java.lang.class */ retVal = ClasspathResources.class.getResource(resource); } return retVal; }