List of usage examples for com.google.common.base Strings nullToEmpty
public static String nullToEmpty(@Nullable String string)
From source file:ec.nbdemetra.ui.tsproviders.DataSourceProviderBuddySupport.java
@Nonnull public IDataSourceProviderBuddy get(@Nullable String providerName) { String tmp = Strings.nullToEmpty(providerName); for (IDataSourceProviderBuddy o : Lookup.getDefault().lookupAll(IDataSourceProviderBuddy.class)) { if (o.getProviderName().equals(tmp)) { return o; }/* w w w . j a v a 2s . c om*/ } return getFallback(tmp); }
From source file:com.qcadoo.mes.cmmsMachineParts.hooks.MaintenanceEventHooks.java
public void onSave(final DataDefinition eventDD, final Entity event) { if (event.getBelongsToField(MaintenanceEventFields.PERSON_RECEIVING) != null) { String person = Strings .nullToEmpty(event.getBelongsToField(MaintenanceEventFields.PERSON_RECEIVING) .getStringField(StaffFields.NAME)) + " " + Strings.nullToEmpty(event.getBelongsToField(MaintenanceEventFields.PERSON_RECEIVING) .getStringField(StaffFields.SURNAME)); event.setField(MaintenanceEventFields.PERSON_RECEIVING_NAME, person); }// w ww .j a v a2 s. com }
From source file:eu.interedition.text.lmnl.ClixRangeAnnotationGenerator.java
@Override public boolean accept(XMLStreamReader reader) { if (reader.isStartElement()) { String startId = null;/* ww w . j av a 2 s .com*/ String endId = null; for (int a = 0, ac = reader.getAttributeCount(); a < ac; a++) { final String localName = reader.getAttributeLocalName(a); final String ns = Strings.nullToEmpty(reader.getAttributeNamespace(a)); if (!ns.isEmpty() && !ns.equals(NamespaceMapping.CLIX_NS_URI)) { continue; } if (CLIX_START_ATTR_NAME.equals(localName)) { startId = reader.getAttributeValue(a); } else if (CLIX_END_ATTR_NAME.equals(localName)) { endId = reader.getAttributeValue(a); } } if (startId == null && endId == null) { clixElements.push(false); return true; } if (startId != null) { final ObjectNode attributes = objectMapper.createObjectNode(); for (int a = 0, ac = reader.getAttributeCount(); a < ac; a++) { final QName name = reader.getAttributeName(a); final String ns = Strings.nullToEmpty(name.getNamespaceURI()); final String ln = name.getLocalPart(); if ((ns.isEmpty() || ns.equals(NamespaceMapping.CLIX_NS_URI)) && (CLIX_START_ATTR_NAME.equals(ln) || CLIX_END_ATTR_NAME.equals(ln))) { continue; } attributes.put(converter().name(name), reader.getAttributeValue(a)); } final ObjectNode data = objectMapper.createObjectNode(); data.put(converter().name(XML_ELEMENT_NAME), converter().name(reader.getName())); if (attributes.size() > 0) { data.put(converter().name(XML_ELEMENT_ATTRS), attributes); } annotations.put(startId, data); startOffsets.put(startId, converter().offset()); converter().annotationsStarts(data); } if (endId != null) { final ObjectNode data = annotations.remove(endId); final Integer start = startOffsets.remove(endId); if (data != null && start != null) { converter().annotationEnds(start, data); } } clixElements.push(true); return false; } else if (reader.isEndElement()) { return !clixElements.pop(); } return true; }
From source file:org.apache.sentry.provider.file.WildcardPermission.java
public WildcardPermission(String wildcardString) { wildcardString = Strings.nullToEmpty(wildcardString).trim(); if (wildcardString.isEmpty()) { throw new IllegalArgumentException("Wildcard string cannot be null or empty."); }/* ww w . j a va 2 s . c om*/ List<KeyValue> parts = Lists.newArrayList(); for (String authorizable : AUTHORIZABLE_SPLITTER.trimResults().split(wildcardString)) { if (authorizable.isEmpty()) { throw new IllegalArgumentException("Privilege '" + wildcardString + "' has an empty section"); } parts.add(new KeyValue(authorizable)); } if (parts.isEmpty()) { throw new AssertionError("Should never occur: " + wildcardString); } this.parts = ImmutableList.copyOf(parts); }
From source file:com.arcbees.staging.TomcatStagingPropertiesProcessor.java
private boolean isEmptyOrSpaces(String value) { return Strings.nullToEmpty(value).trim().isEmpty(); }
From source file:io.druid.query.extraction.UpperExtractionFn.java
@Override public byte[] getCacheKey() { byte[] localeBytes = StringUtils.toUtf8(Strings.nullToEmpty(localeString)); return ByteBuffer.allocate(2 + localeBytes.length).put(ExtractionCacheHelper.CACHE_TYPE_ID_UPPER) .put((byte) 0XFF).put(localeBytes).array(); }
From source file:io.druid.query.extraction.LowerExtractionFn.java
@Override public byte[] getCacheKey() { byte[] localeBytes = StringUtils.toUtf8(Strings.nullToEmpty(localeString)); return ByteBuffer.allocate(2 + localeBytes.length).put(ExtractionCacheHelper.CACHE_TYPE_ID_LOWER) .put((byte) 0XFF).put(localeBytes).array(); }
From source file:org.apache.impala.analysis.CreateTableDataSrcStmt.java
public CreateTableDataSrcStmt(CreateTableStmt createTableStmt, String dataSourceName, String initString) { super(createTableStmt); Preconditions.checkNotNull(dataSourceName); getTblProperties().put(TBL_PROP_DATA_SRC_NAME, dataSourceName.toLowerCase()); getTblProperties().put(TBL_PROP_INIT_STRING, Strings.nullToEmpty(initString)); }
From source file:com.googlesource.gerrit.plugins.its.base.workflow.AddStandardComment.java
private String getValueFromMap(Map<String, String> map, String keyPrefix, String... keyOptions) { for (String key : keyOptions) { String ret = Strings.nullToEmpty(map.get(keyPrefix + key)); if (!ret.isEmpty()) { return ret; }/*from www .j a v a 2 s. com*/ } return ""; }
From source file:com.zimbra.soap.admin.type.Names.java
public Iterable<String> getListOfNames() { return COMMA_SPLITTER.split(Strings.nullToEmpty(names)); }