List of usage examples for com.google.common.base Strings isNullOrEmpty
public static boolean isNullOrEmpty(@Nullable String string)
From source file:org.haiku.haikudepotserver.graphics.bitmap.PngOptimizationServiceFactory.java
@Override public PngOptimizationService getObject() { if (!Strings.isNullOrEmpty(optiPngPath)) { LOGGER.info("will use optipng; {}", optiPngPath); return new OptipngPngOptimizationServiceImpl(optiPngPath); }//from w w w. j a v a2 s .c o m LOGGER.info("will no-op png optimization"); return new NoOpPngOptimizationServiceImpl(); }
From source file:com.marvinformatics.manifestvalidatorplugin.oo.PresentRule.java
@Override public Optional<String> validate(String value, JarFile jar) { if (Strings.isNullOrEmpty(value)) return Optional.of("Expected to be present"); return Optional.empty(); }
From source file:tv.dyndns.kishibe.qmaclone.client.geom.Point.java
/** * ????????????null?//from w ww. j a va2 s.c o m * * @param s * * @return ????????{@code null} */ public static Point fromString(String s) { if (Strings.isNullOrEmpty(s)) { return null; } List<Double> values = Lists.newArrayList(); for (String value : s.split(" ")) { try { values.add(Double.valueOf(value)); } catch (NumberFormatException e) { return null; } } if (values.size() != 2) { return null; } int xx = (int) Math.rint(values.get(0)); int yy = (int) Math.rint(values.get(1)); return new Point(xx, yy); }
From source file:com.b2international.snowowl.snomed.datastore.id.RandomSnomedIdentiferGenerator.java
private static String generateSnomedId(ComponentCategory category) { final String selectedNamespace = ""; final StringBuilder builder = new StringBuilder(); // generate the SCT Item ID builder.append(new RandomItemIdGenerationStrategy().generateItemIds(selectedNamespace, category, 1, 1) .stream().findFirst().get()); // append namespace and the first part of the partition-identifier if (Strings.isNullOrEmpty(selectedNamespace)) { builder.append('0'); } else {//w w w .jav a 2s.co m builder.append(selectedNamespace); builder.append('1'); } // append the second part of the partition-identifier builder.append(category.ordinal()); // calc check-digit builder.append(VerhoeffCheck.calculateChecksum(builder, false)); return builder.toString(); }
From source file:com.demonwav.mcdev.platform.MinecraftModuleType.java
public static void removeOption(@NotNull Module module, @NotNull String option) { final String currentOption = module.getOptionValue(OPTION); if (Strings.isNullOrEmpty(currentOption)) { return;/*from www. j ava2 s . c o m*/ } if (currentOption.contains(option)) { final String[] parts = currentOption.split(","); String newOption = ""; final Iterator<String> partIterator = Arrays.asList(parts).iterator(); while (partIterator.hasNext()) { String part = partIterator.next(); if (part.equals(option)) { continue; } newOption += part; if (partIterator.hasNext()) { newOption += ","; } } module.setOption(OPTION, newOption); } final MinecraftModule minecraftModule = MinecraftModule.getInstance(module); if (minecraftModule != null) { final PlatformType[] types = cleanOption(module); minecraftModule.updateModules(types); } }
From source file:org.opendaylight.controller.cluster.access.concepts.RuntimeRequestException.java
public RuntimeRequestException(final String message, final Throwable cause) { super(message, Preconditions.checkNotNull(cause)); Preconditions.checkArgument(!Strings.isNullOrEmpty(message), "Exception message is mandatory"); }
From source file:com.b2international.index.compat.Highlighting.java
/** * Splits a string to a list of tokens using the specified Lucene analyzer. * /*from ww w . ja va2 s. c om*/ * @param analyzer the analyzer determining token boundaries (may not be {@code null}) * @param s the string to split * @return a list of tokens, or an empty list if {@code s} is {@code null} or empty */ public static List<String> split(Analyzer analyzer, final String s) { checkNotNull(analyzer, "analyzer"); if (Strings.isNullOrEmpty(s)) { return ImmutableList.of(); } final List<String> tokens = Lists.newArrayList(); TokenStream stream = null; try { stream = analyzer.tokenStream(null, new StringReader(s)); stream.reset(); while (stream.incrementToken()) { tokens.add(stream.getAttribute(CharTermAttribute.class).toString()); } } catch (final IOException ignored) { // Should not be thrown when using a string reader } finally { endAndCloseQuietly(stream); } return tokens; }
From source file:org.eclipse.mylyn.wikitext.core.osgi.MockMarkupLanguage.java
public MockMarkupLanguage(String name) { checkArgument(!Strings.isNullOrEmpty(name)); setName(name); }
From source file:org.apache.gobblin.source.jdbc.SqlQueryUtils.java
/** * Add a new predicate(filter condition) to the query. The method will add a "where" clause if * none exists. Otherwise, it will add the condition as a conjunction (and). * * <b>Note that this method is rather limited. It works only if there are no other clauses after * "where"</b>/*from w w w. j av a 2 s . com*/ * * @param query the query string to modify * @param predicateCond the predicate to add to the query * @return query the new query string * @throws IllegalArgumentException if the predicate cannot be added because of additional clauses */ public static String addPredicate(String query, String predicateCond) { if (Strings.isNullOrEmpty(predicateCond)) { return query; } String normalizedQuery = query.toLowerCase().trim(); checkArgument(normalizedQuery.contains(" from "), "query does not contain 'from': " + query); checkArgument(!normalizedQuery.contains(" by "), "query contains 'order by' or 'group by': " + query); checkArgument(!normalizedQuery.contains(" having "), "query contains 'having': " + query); checkArgument(!normalizedQuery.contains(" limit "), "query contains 'limit': " + query); String keyword = " where "; if (normalizedQuery.contains(keyword)) { keyword = " and "; } query = query + keyword + "(" + predicateCond + ")"; return query; }
From source file:org.haiku.haikudepotserver.singlepage.SinglePageTemplateFrequencyMetrics.java
public synchronized void increment(String template) { Preconditions.checkArgument(!Strings.isNullOrEmpty(template), "a template name must be provided"); AtomicLong atomicLong = templateCounter.get(template); if (null == atomicLong) { atomicLong = new AtomicLong(); templateCounter.put(template, atomicLong); }//from w w w . j a v a 2 s .c om atomicLong.incrementAndGet(); sortedTemplates = null; }