List of usage examples for com.google.common.base Strings isNullOrEmpty
public static boolean isNullOrEmpty(@Nullable String string)
From source file:com.google.gerrit.testutil.NoteDbMode.java
public static NoteDbMode get() { String value = System.getenv(ENV_VAR); if (Strings.isNullOrEmpty(value)) { value = System.getProperty(SYS_PROP); }/*from ww w . ja v a 2 s .c om*/ if (Strings.isNullOrEmpty(value)) { return OFF; } value = value.toUpperCase().replace("-", "_"); NoteDbMode mode = Enums.getIfPresent(NoteDbMode.class, value).orNull(); if (!Strings.isNullOrEmpty(System.getenv(ENV_VAR))) { checkArgument(mode != null, "Invalid value for env variable %s: %s", ENV_VAR, System.getenv(ENV_VAR)); } else { checkArgument(mode != null, "Invalid value for system property %s: %s", SYS_PROP, System.getProperty(SYS_PROP)); } return mode; }
From source file:org.easyrec.utils.io.Text.java
/** * This function returns the given string without the last character. * e.g.//from w ww . j a va 2 s .c o m * trimLast("peter")-->"pete" * * @param s * */ public static String removeLast(String s) { if (Strings.isNullOrEmpty(s)) return s; return s.substring(0, s.length() - 1); }
From source file:com.zaradai.kunzite.optimizer.control.OptimizeRequest.java
public static OptimizeRequest newRequest(Class<? extends OptimizerTactic> tactic, String target, boolean lookForMaxima, InputRow start) { Preconditions.checkNotNull(tactic, "Invalid tactic specified"); Preconditions.checkArgument(!Strings.isNullOrEmpty(target), "No target specified"); Preconditions.checkNotNull(start, "No start position specified"); return new OptimizeRequest(tactic, target, lookForMaxima, start); }
From source file:com.github.jcustenborder.kafka.connect.utils.templates.markdown.MarkdownTemplateHelper.java
static void lengths(List<Integer> lengths, List<List<String>> rows) { if (lengths.isEmpty()) { for (int i = 0; i < rows.get(0).size(); i++) { lengths.add(0);/*from w w w. j a v a 2s . c o m*/ } } for (List<String> row : rows) { for (int i = 0; i < row.size(); i++) { int previous = lengths.get(i); int current; if (Strings.isNullOrEmpty(row.get(i))) { current = 0; } else { current = row.get(i).length(); } int value = Math.max(current, previous); lengths.set(i, value); } } }
From source file:monasca.api.infrastructure.persistence.DimensionQueries.java
public static void bindDimensionsToQuery(Query<?> query, Map<String, String> dimensions) { if (dimensions != null) { int i = 0; for (Iterator<Map.Entry<String, String>> it = dimensions.entrySet().iterator(); it.hasNext(); i++) { Map.Entry<String, String> entry = it.next(); query.bind("dname" + i, entry.getKey()); if (!Strings.isNullOrEmpty(entry.getValue())) { List<String> values = Splitter.on('|').splitToList(entry.getValue()); int j = 0; for (String value : values) { query.bind("dvalue" + i + '_' + j, value); j++;/*from w ww . ja v a 2 s. c om*/ } } } } }
From source file:br.com.tecsinapse.exporter.converter.LocalTimeTableCellConverter.java
@Override public LocalTime apply(String input) { return Strings.isNullOrEmpty(input) ? null : LocalTime.parse(input); }
From source file:org.eclipse.che.ide.ext.openshift.client.util.OpenshiftValidator.java
/** * Checks whether name matches OpenShift project naming rules. * * @param name// w w w .ja v a 2 s . com * OpenShift project name * @return true if project name is valid, false otherwise */ public static boolean isProjectNameValid(String name) { return !(Strings.isNullOrEmpty(name) || name.length() > 63 || name.length() < 2 || !name.matches(PROJECT_NAME)); }
From source file:org.apache.atlas.authorize.AtlasAuthorizationUtils.java
public static String parse(String fullPath, String subPath) { String api = null;/* w w w . java 2s .c o m*/ if (!Strings.isNullOrEmpty(fullPath)) { api = fullPath.substring(subPath.length(), fullPath.length()); } if (isDebugEnabled) { LOG.debug("Extracted " + api + " from path : " + fullPath); } return api; }
From source file:com.htmlhifive.pitalium.core.selenium.UrlUtils.java
/** * BaseURL?path?URL???????{@code path}?http?https????BaseURL??path???????? * /*from ww w.j a v a2 s . co m*/ * @param baseUrl URL * @param path * @return URL */ static String getTargetUrl(String baseUrl, String path) { boolean baseUrlIsEmpty = Strings.isNullOrEmpty(baseUrl); boolean pathIsEmpty = Strings.isNullOrEmpty(path); if (baseUrlIsEmpty && pathIsEmpty) { String message = "Both \"baseUrl\" and \"path\" are empty."; LOG.error(message); throw new TestRuntimeException(message); } if (baseUrlIsEmpty) { return path; } if (pathIsEmpty) { return baseUrl; } // path? http:// ??? https:// ????path?????? if (HTTP_PREFIX_PATTERN.matcher(path).find()) { return path; } return baseUrl + path; }
From source file:com.conductor.s3.S3HadoopUtils.java
/** * Extracts the AWS key and secret from the conf, and returns a new S3 client. * //from w ww .j a v a 2 s. c om * @param conf * job conf * @return an S3 client. * @throws java.lang.IllegalArgumentException * if it cannot find key/id in the conf. */ public static AmazonS3 getS3Client(final Configuration conf) { final String accessKey = conf.get("fs.s3n.awsAccessKeyId", conf.get("fs.s3.awsAccessKeyId")); checkArgument(!Strings.isNullOrEmpty(accessKey), "Missing fs.s3/n.awsAccessKeyId conf."); final String secretKey = conf.get("fs.s3n.awsSecretAccessKey", conf.get("fs.s3.awsSecretAccessKey")); checkArgument(!Strings.isNullOrEmpty(secretKey), "Missing fs.s3/n.awsSecretAccessKey conf."); return new AmazonS3Client(new BasicAWSCredentials(accessKey, secretKey)); }