List of usage examples for com.google.common.base Strings nullToEmpty
public static String nullToEmpty(@Nullable String string)
From source file:com.zimbra.doc.soap.Command.java
public String getDescription() { return Strings.nullToEmpty(this.description); }
From source file:ec.tss.TsCollection.java
TsCollection(@Nullable String name) { m_name = Strings.nullToEmpty(name); m_moniker = new TsMoniker(); m_metadata = null;// w ww. j a va 2 s. c om m_ts = new ArrayList<>(); m_info = TsInformationType.UserDefined; m_set = null; m_invalidDataCause = null; }
From source file:org.kegbot.kegboard.KegboardHelloMessage.java
public String getSerialNumber() { return Strings.nullToEmpty(readTagAsString(TAG_SERIAL_NUMBER)); }
From source file:io.druid.query.dimension.RegexFilteredDimensionSpec.java
@Override public DimensionSelector decorate(final DimensionSelector selector) { if (selector == null) { return selector; }//from w w w . j a v a 2s . c om int count = 0; final Map<Integer, Integer> forwardMapping = new HashMap<>(); final int selectorCardinality = selector.getValueCardinality(); if (selectorCardinality < 0) { throw new UnsupportedOperationException("Cannot decorate a selector with no dictionary"); } for (int i = 0; i < selectorCardinality; i++) { if (compiledRegex.matcher(Strings.nullToEmpty(selector.lookupName(i))).matches()) { forwardMapping.put(i, count++); } } final int[] reverseMapping = new int[forwardMapping.size()]; for (Map.Entry<Integer, Integer> e : forwardMapping.entrySet()) { reverseMapping[e.getValue().intValue()] = e.getKey().intValue(); } return BaseFilteredDimensionSpec.decorate(selector, forwardMapping, reverseMapping); }
From source file:org.glowroot.plugin.servlet.HttpSessions.java
private static void captureAllSessionAttributes(HttpSession session, Map<String, String> captureMap) { Enumeration<?> e = session.getAttributeNames(); if (e == null) { return;/*from w w w . j a v a2s. c o m*/ } while (e.hasMoreElements()) { String attributeName = (String) e.nextElement(); if (attributeName == null) { // null check to be safe in case this is a very strange servlet container continue; } Object value = session.getAttribute(attributeName); // value shouldn't be null, but its (remotely) possible that a concurrent // request for the same session just removed the attribute String valueString = value == null ? "" : value.toString(); // taking no chances on value.toString() possibly returning null captureMap.put(attributeName, Strings.nullToEmpty(valueString)); } }
From source file:io.sarl.lang.ui.validation.SARLUIValidator.java
@Check @Override/* ww w .jav a 2 s. co m*/ public void checkFileNamingConventions(XtendFile sarlFile) { // // The wrong package is a warning in SARL (an error in Xtend). // String expectedPackage = Strings.nullToEmpty(getExpectedPackageName(sarlFile)); String declaredPackage = Strings.nullToEmpty(sarlFile.getPackage()); if (!Objects.equal(expectedPackage, declaredPackage)) { if (expectedPackage.isEmpty()) { warning(Messages.SARLUIValidator_0, sarlFile, XtendPackage.Literals.XTEND_FILE__PACKAGE, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, IssueCodes.WRONG_PACKAGE, expectedPackage); } else { warning(MessageFormat.format(Messages.SARLUIValidator_1, expectedPackage), sarlFile, XtendPackage.Literals.XTEND_FILE__PACKAGE, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, IssueCodes.WRONG_PACKAGE, expectedPackage); } } }
From source file:com.b2international.snowowl.server.console.CommandLineAuthenticator.java
private String readUsername() { BufferedReader reader = null; String reply = null;// w w w.j av a 2 s .c om try { reader = new BufferedReader(new InputStreamReader(System.in)); reply = reader.readLine(); } catch (final IOException e) { System.out.println("Error while reading username."); } finally { //intentionally not closed } return Strings.nullToEmpty(reply); }
From source file:org.sonar.plugins.scm.tfs.TfsConfiguration.java
public String username() { return Strings.nullToEmpty(settings.getString(USERNAME_PROPERTY_KEY)); }
From source file:ealvatag.tag.id3.valuepair.ReceivedAsTypes.java
@Override public String getValue(final int key) { if (!containsKey(key)) { return ""; }//from w ww. ja va 2 s. com return Strings.nullToEmpty(values[key]); }
From source file:com.opengamma.strata.report.framework.format.AsciiTable.java
private static void writeDataLine(StringBuilder buf, int[] colLengths, List<AsciiTableAlignment> alignments, List<String> values) { for (int colIdx = 0; colIdx < colLengths.length; colIdx++) { String value = Strings.nullToEmpty(values.get(colIdx)); buf.append('|').append(' ').append(formatValue(buf, colLengths[colIdx], alignments.get(colIdx), value)) .append(' '); }//from w ww . j av a 2 s . co m buf.append('|').append(LINE_SEPARATOR); }