List of usage examples for com.google.common.base Strings nullToEmpty
public static String nullToEmpty(@Nullable String string)
From source file:org.splevo.diffing.util.NormalizationUtil.java
/** * Apply a set of normalizations patterns to a string. The patterns to apply are provided as a * map, linked to a string the pattern should be replaced with in case of a match. * * @param original/* ww w . j a v a 2 s.c o m*/ * The string to normalize. * @param normalizations * The map of normalization patterns and according replacements. * @return The normalized string. If null was submitted, an empty string will be returned. */ public static String normalize(String original, Map<Pattern, String> normalizations) { String renamed = Strings.nullToEmpty(original); for (Pattern pattern : normalizations.keySet()) { String replaceString = normalizations.get(pattern); renamed = pattern.matcher(renamed).replaceAll(replaceString); } return renamed; }
From source file:com.google.gerrit.extensions.api.changes.DeleteCommentInput.java
public DeleteCommentInput(String reason) { this.reason = Strings.nullToEmpty(reason); }
From source file:uk.ac.cam.cl.dtg.picky.client.ui.CheckTreeViewPersistenceUtil.java
public static void restore(CheckTreeView<String> tree, String settings) { List<String> items = Arrays.asList(Strings.nullToEmpty(settings).split("(?<!\\\\);")); for (String itemString : items) { List<String> path = Arrays.asList(itemString.split("(?<!\\\\)/")); TreeItem<String> parent = tree.getRoot(); path = path.stream().map(s -> s.replaceAll("\\\\;", ";").replaceAll("\\\\/", "/")) .collect(Collectors.toList()); for (int i = 0; i < path.size(); i++) { parent = findItem(parent, path.get(i)); }/*from w ww .ja v a 2 s. com*/ if (parent != null) tree.getCheckModel().check(parent); } }
From source file:org.eclipse.che.ApiEndpointProvider.java
@Override public String get() { return Strings.nullToEmpty(System.getenv(API_ENDPOINT_URL_VARIABLE)); }
From source file:com.google.gerrit.server.project.GetDescription.java
@Override public Object apply(ProjectResource resource) { Project project = resource.getControl().getProject(); return Strings.nullToEmpty(project.getDescription()); }
From source file:com.passwordboss.android.helper.SecureItemSubTitle.java
@Nullable public String get() { ItemType itemType = ItemType.from(mSecureItem); if (null == itemType) return null; switch (itemType) { case Address: return getValue(SecureItemData.Identifier.ADDRESS1); case BankAccount: return getValue(SecureItemData.Identifier.BANK_NAME); case CreditCard: String cardNumber = Strings.nullToEmpty(getValue(SecureItemData.Identifier.CARD_NUMBER)); if (cardNumber.length() >= 4) { cardNumber = cardNumber.substring(cardNumber.length() - 4); }/*from ww w. j a v a 2 s . c om*/ return "####-" + cardNumber; case DriversLicense: return getValue(SecureItemData.Identifier.DRIVER_LICENSE_NUMBER); case Email: return getValue(SecureItemData.Identifier.EMAIL); case EmailAccount: case InstantMessenger: case Server: case Website: return getValue(SecureItemData.Identifier.USERNAME); case FrequentFlyer: return getValue(SecureItemData.Identifier.FREQUENT_FLYER_NUMBER); case HealthInsurance: return getValue(SecureItemData.Identifier.MEMBER_ID); case HotelRewards: return getValue(SecureItemData.Identifier.MEMBERSHIP_NUMBER); case Insurance: return getValue(SecureItemData.Identifier.POLICY_NUMBER); case MemberId: return getValue(SecureItemData.Identifier.MEMBER_ID); case Passport: return getValue(SecureItemData.Identifier.PASSPORT_NUMBER); case Phone: return getValue(SecureItemData.Identifier.PHONE_NUMBER); case Prescription: return getValue(SecureItemData.Identifier.PRESCRIPTION_NUMBER); case SocialSecurity: return getValue(SecureItemData.Identifier.SOCIAL_SECURITY_NUMBER); case SshKey: return getValue(SecureItemData.Identifier.SERVER_ADDRESS); case WiFi: return getValue(SecureItemData.Identifier.SSID); default: return null; } }
From source file:tech.aroma.data.performance.Operations.java
public static <T> T logLatency(@Required Operation<T> operation, String operationName) throws TException { checkThat(operation).is(notNull());/* w w w . ja v a 2 s . co m*/ operationName = Strings.nullToEmpty(operationName); long start = System.currentTimeMillis(); try { return operation.call(); } finally { long end = System.currentTimeMillis(); LOG.debug("{} Operation took {} ms", operationName, end - start); } }
From source file:br.com.objectos.jabuticava.debs.SerieConverter.java
@Override protected String convert(String text) { text = Strings.nullToEmpty(text); return br.com.objectos.core.lang.Strings.accentsToAscii(text).alphanum().toString(); }
From source file:jflex.maven.plugin.jflex.ClassInfo.java
ClassInfo(String className, @Nullable String packageName) { this.className = className; this.packageName = Strings.nullToEmpty(packageName); }
From source file:pl.llp.aircasting.helper.MetadataHelper.java
public String getPhoneModel() { return Strings.nullToEmpty(Build.MODEL).replace(' ', '-'); }