List of usage examples for com.google.common.base Strings isNullOrEmpty
public static boolean isNullOrEmpty(@Nullable String string)
From source file:org.jboss.hal.dmr.ResourceAddress.java
/** Creates a new resource address from the specified string. */ public static ResourceAddress from(String address) { if (Strings.isNullOrEmpty(address)) { throw new IllegalArgumentException("Address must not be null or empty"); }// w w w .ja v a 2s . co m String safeAddress = address.startsWith("/") ? address.substring(1) : address; ResourceAddress ra = new ResourceAddress(); Map<String, String> segments = Splitter.on('/').omitEmptyStrings().withKeyValueSeparator('=') .split(safeAddress); for (Map.Entry<String, String> entry : segments.entrySet()) { ra.add(entry.getKey(), entry.getValue()); } return ra; }
From source file:org.libreoffice.ci.gerrit.buildbot.servlets.RenderType.java
public static RenderType getFormatType(HttpServletRequest req) { RenderType result = (RenderType) req.getAttribute(FORMAT_TYPE_ATTRIBUTE); if (result != null) { return result; }//from www . j ava2 s . c om String format = req.getParameter("format"); if (format != null) { for (RenderType type : RenderType.values()) { if (format.equalsIgnoreCase(type.name())) { return set(req, type); } } throw new IllegalArgumentException("Invalid format " + format); } String accept = req.getHeader(HttpHeaders.ACCEPT); if (Strings.isNullOrEmpty(accept)) { return set(req, DEFAULT); } for (String p : accept.split("[ ,;][ ,;]*")) { for (RenderType type : RenderType.values()) { if (p.equals(type.mimeType)) { return set(req, type != HTML ? type : DEFAULT); } } } return set(req, DEFAULT); }
From source file:org.apache.isis.viewer.wicket.ui.util.CssIdAppender.java
/** * Adds CSS id to tag (providing that the id is non-null and non-empty). *//* w ww . jav a 2 s . c o m*/ public static void appendCssIdTo(final ComponentTag tag, final String cssId) { if (Strings.isNullOrEmpty(cssId)) { return; } tag.append("id", cssId, " "); }
From source file:org.apache.isis.core.metamodel.facets.object.parseable.annotcfg.ParseableFacetAnnotation.java
private static String parserName(final Class<?> annotatedClass, final IsisConfiguration configuration) { final Parseable annotation = annotatedClass.getAnnotation(Parseable.class); final String parserName = annotation.parserName(); if (!Strings.isNullOrEmpty(parserName)) { return parserName; }/*from ww w . j a v a 2 s . c o m*/ return ParserUtil.parserNameFromConfiguration(annotatedClass, configuration); }
From source file:uapi.common.StringHelper.java
public static String makeString(final String str, Object... args) { if (Strings.isNullOrEmpty(str)) { return str; }/*from w ww. j av a 2 s .c o m*/ if (args == null) { args = CollectionHelper.EMPTY_ARRAY; } StringBuilder buffer = new StringBuilder(); boolean foundVarStart = false; int idxVar = 0; int tmpIdx = -1; for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); if (c == VAR_START) { foundVarStart = true; } else if (c == VAR_END) { if (foundVarStart) { if (tmpIdx != -1 && tmpIdx < args.length) { buffer.append(args[tmpIdx] == null ? "" : args[tmpIdx]); } else if (idxVar < args.length) { buffer.append(args[idxVar] == null ? "" : args[idxVar]); } else { buffer.append(VAR_START).append(tmpIdx == -1 ? "" : tmpIdx).append(VAR_END); } foundVarStart = false; idxVar++; tmpIdx = -1; } else { buffer.append(c); } } else { if (foundVarStart) { if (c >= '0' && c <= '9') { if (tmpIdx == -1) { tmpIdx = 0; } tmpIdx = tmpIdx * 10 + Character.getNumericValue(c); } else { buffer.append(VAR_START); if (tmpIdx != -1) { buffer.append(tmpIdx); tmpIdx = -1; } buffer.append(c); foundVarStart = false; } } else { buffer.append(c); } } } if (foundVarStart) { buffer.append(VAR_START).append(tmpIdx == -1 ? "" : tmpIdx); } return buffer.toString(); }
From source file:org.locationtech.geogig.repository.LocalRemoteRefSpec.java
public static List<LocalRemoteRefSpec> parse(final String remoteName, final String refspecs) { Preconditions.checkArgument(!Strings.isNullOrEmpty(remoteName)); Preconditions.checkArgument(!Strings.isNullOrEmpty(remoteName.trim())); Preconditions.checkArgument(!Strings.isNullOrEmpty(refspecs), "no refspecs provided"); Preconditions.checkArgument(!Strings.isNullOrEmpty(refspecs.trim()), "no refspecs provided"); List<String> refs = Splitter.on(';').omitEmptyStrings().trimResults().splitToList(refspecs); return refs.stream().map(spec -> LocalRemoteRefSpec.parseSingle(remoteName, spec)) .collect(Collectors.toList()); }
From source file:de.aikiit.fotorenamer.image.ImageFilenameFilter.java
private static boolean isSuffixExifExtractable(final String name) { if (!Strings.isNullOrEmpty(name)) { String file = name.trim().toLowerCase(); for (String suffix : EXTENSIONS) { if (file.endsWith("." + suffix)) { return true; }/* w w w . java 2 s .c o m*/ } } return false; }
From source file:org.n52.janmayen.Times.java
public static String encodeDateTime(DateTime dateTime, String dateFormat) { if (Strings.isNullOrEmpty(dateFormat)) { return encodeDateTime(dateTime); } else if (dateTime == null) { return ZERO.toString(DateTimeFormat.forPattern(dateFormat)); } else {/*from w w w. j a v a2s . c om*/ return dateTime.toString(DateTimeFormat.forPattern(dateFormat)).replace(Z, UTC_OFFSET); } }
From source file:com.google.cloud.tools.appengine.operations.cloudsdk.internal.args.Args.java
/** * Produces the flag form of a string value, separated with an equals character. * * @return {@code [--name=value]} or {@code []} if value is null. *///from w ww .j av a2 s . co m static List<String> stringWithEq(String name, @Nullable String value) { if (!Strings.isNullOrEmpty(value)) { return Collections.singletonList("--" + name + "=" + value); } return Collections.emptyList(); }
From source file:org.apache.kylin.metrics.property.QueryCubePropertyEnum.java
public static QueryCubePropertyEnum getByName(String name) { if (Strings.isNullOrEmpty(name)) { return null; }//from w w w. j a v a 2 s . c o m for (QueryCubePropertyEnum property : QueryCubePropertyEnum.values()) { if (property.propertyName.equals(name.toUpperCase())) { return property; } } return null; }