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.ogc.ows.service.OwsServiceRequestContext.java
public void setToken(String token) { this.token = Optional.ofNullable(Strings.emptyToNull(token)); }
From source file:de.bund.bfr.knime.pmm.js.common.Misc.java
/** * Sets the description of this {@link Misc}. * /*from www .j av a 2 s .c om*/ * Empty strings are converted to null. * * @param description the description of this {@link Misc} */ public void setDescription(final String description) { this.description = Strings.emptyToNull(description); }
From source file:org.apache.james.mpt.imapmailbox.cyrus.host.CyrusHostSystem.java
public String createMailboxStringFromMailboxPath(MailboxPath mailboxPath) { return Joiner.on('.').skipNulls().join("user", mailboxPath.getUser(), Strings.emptyToNull(mailboxPath.getName())); }
From source file:org.dcache.alarms.server.LogEntryServerWrapper.java
public void setBaseDir(String baseDir) { this.baseDir = Strings.emptyToNull(baseDir); }
From source file:com.cloudbees.jenkins.plugins.amazonecs.ECSCloud.java
@DataBoundConstructor public ECSCloud(String name, List<ECSTaskTemplate> templates, @Nonnull String credentialsId, String cluster, String regionName, String cloudWatchAlarmName, String instanceCapStr, String jenkinsUrl) { super(name);//from www . j a v a 2 s .c o m this.credentialsId = credentialsId; this.cluster = cluster; this.templates = templates; this.regionName = regionName; this.cloudWatchAlarmName = cloudWatchAlarmName; this.jenkinsUrl = Strings.emptyToNull(jenkinsUrl); if (templates != null) { for (ECSTaskTemplate template : templates) { template.setOwer(this); } } if (instanceCapStr.isEmpty()) { this.instanceCap = Integer.MAX_VALUE; } else { this.instanceCap = Integer.parseInt(instanceCapStr); } }
From source file:org.eclipse.buildship.ui.launch.JavaHomeTab.java
@Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { GradleRunConfigurationAttributes.applyJavaHomeExpression(Strings.emptyToNull(this.javaHomeText.getText()), configuration);/*from www . j a va2 s. com*/ }
From source file:com.google.gerrit.server.change.Restore.java
@Override public Object apply(ChangeResource req, Input input) throws Exception { ChangeControl control = req.getControl(); IdentifiedUser caller = (IdentifiedUser) control.getCurrentUser(); Change change = req.getChange();/* ww w .j a va 2 s . c o m*/ if (!control.canRestore()) { throw new AuthException("restore not permitted"); } else if (change.getStatus() != Status.ABANDONED) { throw new ResourceConflictException("change is " + status(change)); } ChangeMessage message; ReviewDb db = dbProvider.get(); db.changes().beginTransaction(change.getId()); try { change = db.changes().atomicUpdate(change.getId(), new AtomicUpdate<Change>() { @Override public Change update(Change change) { if (change.getStatus() == Change.Status.ABANDONED) { change.setStatus(Change.Status.NEW); ChangeUtil.updated(change); return change; } return null; } }); if (change == null) { throw new ResourceConflictException( "change is " + status(db.changes().get(req.getChange().getId()))); } indexer.index(change); message = newMessage(input, caller, change); db.changeMessages().insert(Collections.singleton(message)); new ApprovalsUtil(db).syncChangeStatus(change); db.commit(); } finally { db.rollback(); } try { ReplyToChangeSender cm = restoredSenderFactory.create(change); cm.setFrom(caller.getAccountId()); cm.setChangeMessage(message); cm.send(); } catch (Exception e) { log.error("Cannot email update for change " + change.getChangeId(), e); } hooks.doChangeRestoredHook(change, caller.getAccount(), db.patchSets().get(change.currentPatchSetId()), Strings.emptyToNull(input.message), dbProvider.get()); return json.format(change); }
From source file:org.sonar.server.rule.RubyRuleService.java
public void updateRule(Map<String, Object> params) { RuleUpdate update = RuleUpdate.createForPluginRule(RuleKey.parse((String) params.get("ruleKey"))); String fn = (String) params.get("debtRemediationFunction"); if (fn == null) { update.setDebtRemediationFunction(null); } else {/* w w w . j a v a 2 s . c o m*/ update.setDebtRemediationFunction( new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.valueOf(fn), Strings.emptyToNull((String) params.get("debtRemediationCoefficient")), Strings.emptyToNull((String) params.get("debtRemediationOffset")))); } updater.update(update, userSession); }
From source file:com.tinspx.util.net.ConfigHttpURLConnection.java
@Override public String getHeaderField(String name) { return headers != null ? Strings.emptyToNull(headers.first(name)) : null; }
From source file:io.janusproject.Boot.java
/** * Parse the command line./*from w w w .java2s.c om*/ * * @param args - the CLI arguments given to the program. * @return the arguments that are not recognized as CLI options. */ @SuppressWarnings("unchecked") public static String[] parseCommandLine(String[] args) { CommandLineParser parser = new GnuParser(); try { CommandLine cmd = parser.parse(getOptions(), args); // Show the help when there is no argument. if (cmd.getArgs().length == 0) { showHelp(); return null; } boolean noLogo = false; int verbose = LoggerCreator.toInt(JanusConfig.VERBOSE_LEVEL_VALUE); Iterator<Option> optIterator = cmd.iterator(); while (optIterator.hasNext()) { Option opt = optIterator.next(); switch (opt.getOpt()) { case "h": //$NON-NLS-1$ showHelp(); return null; case "s": //$NON-NLS-1$ showDefaults(); return null; case "f": //$NON-NLS-1$ String rawFilename = opt.getValue(); if (rawFilename == null || "".equals(rawFilename)) { //$NON-NLS-1$ showHelp(); } File file = new File(rawFilename); if (!file.canRead()) { showError(Locale.getString("INVALID_PROPERTY_FILENAME", //$NON-NLS-1$ rawFilename), null); return null; } setPropertiesFrom(file); break; case "o": //$NON-NLS-1$ setOffline(true); break; case "R": //$NON-NLS-1$ setRandomContextUUID(); break; case "B": //$NON-NLS-1$ setBootAgentTypeContextUUID(); break; case "W": //$NON-NLS-1$ setDefaultContextUUID(); break; case "D": //$NON-NLS-1$ String name = opt.getValue(0); if (!Strings.isNullOrEmpty(name)) { setProperty(name, Strings.emptyToNull(opt.getValue(1))); } break; case "l": //$NON-NLS-1$ verbose = Math.max(LoggerCreator.toInt(opt.getValue()), 0); break; case "q": //$NON-NLS-1$ if (verbose > 0) { --verbose; } break; case "v": //$NON-NLS-1$ ++verbose; break; case "nologo": //$NON-NLS-1$ noLogo = true; break; default: } } // Change the verbosity setVerboseLevel(verbose); // Show the Janus logo? if (noLogo || verbose == 0) { setProperty(JanusConfig.JANUS_LOGO_SHOW_NAME, Boolean.FALSE.toString()); } return cmd.getArgs(); } catch (IOException | ParseException e) { showError(e.getLocalizedMessage(), e); // Event if showError never returns, add the return statement for // avoiding compilation error. return null; } }