List of usage examples for com.google.common.base Strings emptyToNull
@Nullable public static String emptyToNull(@Nullable String string)
From source file:org.n52.shetland.w3c.xlink.Reference.java
public Reference setRole(String role) { this.role = Optional.ofNullable(Strings.emptyToNull(role)); return this; }
From source file:org.openepics.discs.ccdb.core.dl.common.ExcelImportFileReader.java
/** * This method returns the contents of the first worksheet found in the * Excel workbook file.//from w w w .j a v a2s .c o m * * @param inputStream * the Excel file to parse. Only Excel file version >=12.0 * supported (.xslx). * @param dataStartIndex * the index of the row where to start parsing the import data. * @param dataRowLength * the length of each row if it contains all the data. This length is usually defined by the Excel * template. * @return Only the lines from the first worksheet that contain a string * value. Lines with the empty first cell are not part of the return * set. Each row is represented as a pair of the row number and a list of columns. */ public static List<Pair<Integer, List<String>>> importExcelFile(InputStream inputStream, int dataStartIndex, final int dataRowLength) { final List<Pair<Integer, List<String>>> result = new ArrayList<>(); try { final XSSFWorkbook workbook = new XSSFWorkbook(inputStream); final XSSFSheet sheet = workbook.getSheetAt(0); for (Row excelRow : sheet) { if (excelRow.getRowNum() < dataStartIndex) { continue; } final String firstColumnValue = Strings .emptyToNull(ExcelCell.asStringOrNull(excelRow.getCell(0), workbook)); if (firstColumnValue != null && !firstColumnValue.trim().isEmpty()) { final List<String> row = new ArrayList<>(); final int rowNumber = excelRow.getRowNum() + 1; final int lastCellIndex = dataRowLength > excelRow.getLastCellNum() ? dataRowLength : excelRow.getLastCellNum(); for (int i = 0; i < lastCellIndex; i++) { row.add(ExcelCell.asStringOrNull(excelRow.getCell(i), workbook)); } result.add(new ImmutablePair<Integer, List<String>>(rowNumber, row)); } } } catch (IOException e) { throw new RuntimeException(e); } return result; }
From source file:org.apache.druid.common.config.NullHandling.java
@Nullable public static String emptyToNullIfNeeded(@Nullable String value) { //CHECKSTYLE.OFF: Regexp return replaceWithDefault() ? Strings.emptyToNull(value) : value; //CHECKSTYLE.ON: Regexp }
From source file:it.anyplace.sync.core.beans.FileInfo.java
private FileInfo(String folder, FileType type, String path, @Nullable Long size, @Nullable Date lastModified, @Nullable String hash, @Nullable List<Version> versionList, boolean deleted) { checkNotNull(Strings.emptyToNull(folder)); checkNotNull(path);//allow empty for 'fake' root path checkNotNull(type);/*from w w w .j a v a 2 s . c om*/ this.folder = folder; this.type = type; this.path = path; if (PathUtils.isParent(path)) { this.fileName = PARENT_PATH; this.parent = ROOT_PATH; } else { this.fileName = PathUtils.getFileName(path); this.parent = PathUtils.isRoot(path) ? ROOT_PATH : PathUtils.getParentPath(path); } this.lastModified = MoreObjects.firstNonNull(lastModified, new Date(0)); if (type.equals(FileType.DIRECTORY)) { this.size = null; this.hash = null; } else { checkNotNull(size); checkNotNull(emptyToNull(hash)); this.size = size; this.hash = hash; } this.versionList = Collections .unmodifiableList(MoreObjects.firstNonNull(versionList, Collections.<Version>emptyList())); this.deleted = deleted; }
From source file:fathom.realm.windows.WindowsRealm.java
@Override public void setup(Config config) { super.setup(config); String os = System.getProperty("os.name").toLowerCase(); Preconditions.checkState(os.startsWith("windows"), "Windows authentication is not supported on '{}'", os); if (config.hasPath("defaultDomain")) { defaultDomain = Strings.emptyToNull(config.getString("defaultDomain")); }//from w ww.j av a 2 s. c o m if (config.hasPath("allowGuests")) { allowGuests = config.getBoolean("allowGuests"); } adminGroups = Arrays.asList("BUILTIN\\Administrators"); if (config.hasPath("adminGroups")) { adminGroups = config.getStringList("adminGroups"); } waffle = new WindowsAuthProviderImpl(); }
From source file:org.n52.wps.util.XMLBeansHelper.java
/** * Registers a prefix for a namespace to be used in responses. * * @param namespace the XML namespace//from w ww. ja va2 s.co m * @param prefix the prefix */ public static void registerPrefix(String namespace, String prefix) { PREFIXES.put(Preconditions.checkNotNull(Strings.emptyToNull(namespace)), Preconditions.checkNotNull(Strings.emptyToNull(prefix))); }
From source file:io.druid.segment.column.SimpleDictionaryEncodedColumn.java
@Override public String lookupName(int id) { //Empty to Null will ensure that null and empty are equivalent for extraction function return Strings.emptyToNull(cachedLookups.get(id)); }
From source file:io.druid.server.namespace.KafkaExtractionNamespaceFactory.java
@Override public Function<String, String> build(KafkaExtractionNamespace extractionNamespace, final Map<String, String> cache) { return new Function<String, String>() { @Nullable/*from w w w . j a va2 s .c om*/ @Override public String apply(String input) { if (Strings.isNullOrEmpty(input)) { return null; } return Strings.emptyToNull(cache.get(input)); } }; }
From source file:org.sonar.server.user.UserSession.java
UserSession setLogin(@Nullable String s) { this.login = Strings.emptyToNull(s); return this; }
From source file:org.xacml4j.v30.spi.pip.AttributeResolverDescriptorBuilder.java
private AttributeResolverDescriptorBuilder(String id, String name, String issuer, CategoryId category) { Preconditions.checkNotNull(id);/* w w w . java 2 s. c o m*/ Preconditions.checkNotNull(name); Preconditions.checkNotNull(category); this.name = name; this.issuer = Strings.emptyToNull(issuer); // JMX friendly name this.id = id.replace(":", "."); this.category = category; this.attributesById = new LinkedHashMap<String, AttributeDescriptor>(); this.attributesByKey = new LinkedHashMap<AttributeDesignatorKey, AttributeDescriptor>(); this.keys = new LinkedList<AttributeReferenceKey>(); }