List of usage examples for com.google.common.base Strings nullToEmpty
public static String nullToEmpty(@Nullable String string)
From source file:org.jclouds.openstack.neutron.v2_0.domain.ReferenceWithName.java
@ConstructorProperties({ "id", "tenant_id", "name" }) protected ReferenceWithName(String id, String tenantId, String name) { super(id, tenantId); this.name = Strings.nullToEmpty(name); }
From source file:org.attribyte.util.StringUtil.java
/** * A string equals that allows <tt>null</tt> values * and treats them as equivalent to empty strings. * @param str1 The first string.//from w ww . jav a 2 s . c o m * @param str2 The second string. * @return Are the strings equal? */ @SuppressWarnings({ "StringEquality" }) public static boolean equals(final String str1, final String str2) { return str1 == str2 || Strings.nullToEmpty(str1).equals(Strings.nullToEmpty(str2)); }
From source file:org.gbif.api.vocabulary.IdentifierType.java
/** * Tries to infer the identifier type from a given identifier. * Most identifiers have a URI protocol prefix or a specific structure that * allows the guess.//from w w w. j a v a 2 s .co m * * @return the inferred identifier type or Unknown if identifier is null or cant be inferred. */ public static IdentifierType inferFrom(@Nullable String identifier) { String lcIdentifier = Strings.nullToEmpty(identifier).trim().toLowerCase(); if (lcIdentifier.isEmpty()) { return UNKNOWN; } if (lcIdentifier.startsWith("doi:10") || lcIdentifier.startsWith("urn:doi:") || lcIdentifier.startsWith("http://dx.doi.org/10.")) { return DOI; } if (lcIdentifier.startsWith("http:") || lcIdentifier.startsWith("https:") || lcIdentifier.startsWith("www.")) { return URL; } if (lcIdentifier.startsWith("ftp:")) { return FTP; } if (lcIdentifier.startsWith("urn:lsid:") || lcIdentifier.startsWith("lsid:")) { return LSID; } if (lcIdentifier.startsWith("urn:uuid:") || lcIdentifier.startsWith("uuid:")) { return UUID; } try { java.util.UUID.fromString(lcIdentifier); return UUID; } catch (IllegalArgumentException ignored) { // We're just trying to convert a String to anything readable. Apparently the UUID approach failed. } return UNKNOWN; }
From source file:io.macgyver.core.web.mvc.SearchController.java
@RequestMapping("/core/search") @ResponseBody//from w ww . j a va 2 s.co m public ModelAndView search(HttpServletRequest request) { String query = Strings.nullToEmpty(request.getParameter("q")).toLowerCase(); UIContext uic = UIContext.forCurrentUser(); List<MenuItem> results = Lists.newArrayList(); search(query, uic.getRootMenu(), results); return new ModelAndView("/core/search", "results", results); }
From source file:com.eucalyptus.autoscaling.common.policy.AutoScalingResourceName.java
@Override public String toString() { return new StringBuilder().append(ARN_PREFIX).append(getService()).append(':') .append(Strings.nullToEmpty(getRegion())).append(':').append(Strings.nullToEmpty(getAccount())) .append(':').append(getType()).append(':').append(getResourceName()).toString(); }
From source file:com.eucalyptus.simpleworkflow.common.policy.SimpleWorkflowResourceName.java
@Override public String toString() { return new StringBuilder().append(ARN_PREFIX).append(getService()).append(':') .append(Strings.nullToEmpty(getRegion())).append(':').append(Strings.nullToEmpty(getAccount())) .append(":/").append(getType()).append('/').append(getResourceName()).toString(); }
From source file:at.alladin.rmbt.mapServer.parameters.ShapeTileParameters.java
@Override public void funnel(TileParameters o, PrimitiveSink into) { super.funnel(o, into); if (o instanceof ShapeTileParameters) { final ShapeTileParameters _o = (ShapeTileParameters) o; into.putUnencodedChars(Strings.nullToEmpty(_o.shapeType)); }// ww w . j a va2 s.c o m }
From source file:org.richfaces.resource.mapping.LibraryResourceMapper.java
@Override public ResourceMapping mapResource(ResourceKey resourceKey) { String library = Strings.nullToEmpty(resourceKey.getLibraryName()); if (resourceLibrary.equals(library)) { return new ResourceServletMapping(resourceKey); }//from ww w. j a va 2 s .c om return null; }
From source file:com.b2international.commons.db.JdbcUrl.java
/** * @param scheme//from w w w. j a va 2 s . co m * @param domain * @param deploymentId * @param jdbcSettings * - may be <code>null</code> */ public JdbcUrl(final String scheme, final String domain, final String deploymentId, final String jdbcSettings) { this.scheme = checkNotNull(scheme, "URL scheme argument cannot be null."); this.domain = checkNotNull(domain, "URL domain argument cannot be null."); this.deploymentId = checkNotNull(deploymentId, "URL deployment ID argument cannot be null."); this.jdbcSettings = Strings.nullToEmpty(jdbcSettings); }
From source file:fathom.rest.RestModule.java
@Override protected void setup() { String basePath = Strings.nullToEmpty(getSettings().getString(RestServlet.SETTING_URL, null)).trim(); serve(basePath + "/*").with(RestServlet.class); final PippoSettings pippoSettings = getPippoSettings(getSettings()); final Application application = new Application(pippoSettings); // must set context path before starting application application.getRouter().setContextPath(getSettings().getContextPath()); // must set application path before starting application String contextPath = application.getRouter().getContextPath(); String applicationPath = StringUtils.addEnd(contextPath, "/") + StringUtils.removeStart(basePath, "/"); application.getRouter().setApplicationPath(applicationPath); // start the application which sets up all initializers application.init();/*w w w . jav a2s . c o m*/ bind(Application.class).toInstance(application); bind(Router.class).toInstance(application.getRouter()); bind(Messages.class).toInstance(application.getMessages()); bind(Languages.class).toInstance(application.getLanguages()); bind(MimeTypes.class).toInstance(application.getMimeTypes()); bind(ErrorHandler.class).toInstance(application.getErrorHandler()); bind(TemplateEngine.class).toInstance(application.getTemplateEngine()); bind(HttpCacheToolkit.class).toInstance(application.getHttpCacheToolkit()); bind(ContentTypeEngines.class).toInstance(application.getContentTypeEngines()); bind(RestService.class); }