List of usage examples for com.google.common.base Strings isNullOrEmpty
public static boolean isNullOrEmpty(@Nullable String string)
From source file:org.activityinfo.server.util.config.BeanstalkEnvironment.java
public static boolean credentialsArePresent() { return !Strings.isNullOrEmpty(getAccessKeyId()) && !Strings.isNullOrEmpty(getSecretKey()); }
From source file:com.sixt.service.framework.kafka.messaging.Topic.java
public static Topic serviceInbox(@NotNull String serviceName, String inboxName) { StringBuilder topic = new StringBuilder(); topic.append("inbox"); if (!Strings.isNullOrEmpty(inboxName)) { topic.append("_"); topic.append(inboxName);//from w w w . j ava2 s . c om } if (Strings.isNullOrEmpty(serviceName)) { throw new IllegalArgumentException("service name must not be null or empty"); } topic.append("-"); topic.append(serviceName); return new Topic(topic.toString()); }
From source file:net.awairo.mcmod.common.CommonLogic.java
@Nonnull public static String getModId(@Nonnull Object modInstance) { final Mod mod = modInstance.getClass().getAnnotation(Mod.class); if (mod == null || Strings.isNullOrEmpty(mod.modid())) throw new IllegalArgumentException(); return mod.modid(); }
From source file:com.sojw.ahnchangho.core.util.UriUtils.java
/** * Of./* w w w . j a va 2 s. c o m*/ * * @param url the url * @param pathVariables the path variables * @param queryParameters the query parameters * @return the uri */ public static URI of(String url, Map<String, String> pathVariables, Map<String, String> queryParameters) { if (Strings.isNullOrEmpty(url)) { return null; } return UriComponentsBuilder.fromHttpUrl(url).queryParams(multiValueMap(queryParameters)) .buildAndExpand(pathVariables).encode().toUri(); }
From source file:com.epam.ta.reportportal.database.entity.user.UserRole.java
public static Optional<UserRole> findByAuthority(String name) { if (Strings.isNullOrEmpty(name)) { return Optional.empty(); }/* ww w . ja v a2 s . c o m*/ return findByName(StringUtils.substringAfter(name, ROLE_PREFIX)); }
From source file:com.cloudant.sync.sqlite.sqlite4java.QueryBuilder.java
public static String buildUpdateQuery(String table, ContentValues values, String whereClause, String[] whereArgs) {/* w w w. j ava2 s . c om*/ StringBuilder query = new StringBuilder(120); query.append("UPDATE ").append(table).append(" SET "); int i = 0; for (String colName : values.keySet()) { query.append((i > 0) ? "," : ""); query.append(colName); query.append("=?"); i++; } if (!Strings.isNullOrEmpty(whereClause)) { query.append(" WHERE "); query.append(whereClause); } return query.toString(); }
From source file:com.paladin.common.Tools.java
/** * //from ww w . j a va 2 s. co m * * @param str ?? * @return ??? */ public static String compressBlank(String str) { str = str.trim(); if (Strings.isNullOrEmpty(str)) return ""; StringBuilder str_bu = new StringBuilder(); char[] str_arr = str.toCharArray(); for (int i = 0; i < str_arr.length; i++) { if (!isBlank(str_arr[i])) str_bu.append(str_arr[i]); else if (isBlank(str_arr[i]) && i + 1 < str_arr.length && !isBlank(str_arr[i + 1])) str_bu.append((char) 32); } return str_bu.toString(); }
From source file:kungfu.concurrency.threaddump.ThreadUtil.java
public static String threadDump() { String threadDump = _getThreadDumpFromJstack(); if (Strings.isNullOrEmpty(threadDump)) { threadDump = _getThreadDumpFromStackTrace(); }/* w ww . j ava 2 s.co m*/ return "\n\n".concat(threadDump); }
From source file:com.cloudera.impala.extdatasource.ApiVersion.java
/** * Parses the API version from the string. Is case-insensitive. * @return The value of the ApiVersion enum represented by the string or null * if the string is not a valid ApiVersion. *//*from w w w.j ava 2 s. c om*/ public static ApiVersion parseApiVersion(String apiVersionString) { if (Strings.isNullOrEmpty(apiVersionString)) return null; try { return valueOf(apiVersionString.toUpperCase()); } catch (IllegalArgumentException ex) { return null; } }
From source file:com.microsoftopentechnologies.auth.jwt.JWTParser.java
/** * Absolutely basic, bare minimum implementation of JWT parsing as needed * for parsing the ID token returned by Azure Active Directory as * documented here - https://msdn.microsoft.com/en-us/library/azure/dn645542.aspx. * * @param jwtInput The ID token JWT string. * @return The JWT object representing the information encoded in the JWT. * @throws ParseException/*from w ww. j av a 2s . c om*/ */ public static JWT parse(String jwtInput) throws ParseException { if (Strings.isNullOrEmpty(jwtInput)) { throw new ParseException("jwt string is null/empty.", 0); } // split the period delimited string List<String> tokens = Splitter.on('.').omitEmptyStrings().splitToList(jwtInput); // the length of the list MUST be 2 or more if (tokens.size() < 2) { throw new ParseException("Invalid JWT string supplied.", 0); } // parse JWT header and claims JsonParser jsonParser = new JsonParser(); JsonObject header = (JsonObject) jsonParser.parse(stringFromBase64(tokens.get(0))); JsonObject claims = (JsonObject) jsonParser.parse(new String(Base64.decodeBase64(tokens.get(1)))); return JWT.parse(header, claims); }