List of usage examples for com.google.common.base Strings nullToEmpty
public static String nullToEmpty(@Nullable String string)
From source file:com.google.caliper.worker.WorkerEventLog.java
public void notifyFailure(Exception e) { writer.println(controlLogMessageRenderer.render(new FailureLogMessage(e.getClass().getName(), Strings.nullToEmpty(e.getMessage()), ImmutableList.copyOf(e.getStackTrace())))); }
From source file:com.zimbra.cs.service.account.ModifyPrefs.java
public Element handle(Element request, Map<String, Object> context) throws ServiceException { ZimbraSoapContext zsc = getZimbraSoapContext(context); Account account = getRequestedAccount(zsc); if (!canModifyOptions(zsc, account)) throw ServiceException.PERM_DENIED("can not modify options"); HashMap<String, Object> prefs = new HashMap<String, Object>(); Map<String, Set<String>> name2uniqueAttrValues = new HashMap<String, Set<String>>(); for (KeyValuePair kvp : request.listKeyValuePairs(AccountConstants.E_PREF, AccountConstants.A_NAME)) { String name = kvp.getKey(), value = kvp.getValue(); char ch = name.length() > 0 ? name.charAt(0) : 0; int offset = ch == '+' || ch == '-' ? 1 : 0; if (!name.startsWith(PREF_PREFIX, offset)) throw ServiceException.INVALID_REQUEST("pref name must start with " + PREF_PREFIX, null); AttributeInfo attrInfo = AttributeManager.getInstance().getAttributeInfo(name.substring(offset)); if (attrInfo == null) { throw ServiceException.INVALID_REQUEST("no such attribute: " + name, null); }/* www . ja va 2 s . com*/ if (attrInfo.isCaseInsensitive()) { String valueLowerCase = Strings.nullToEmpty(value).toLowerCase(); if (name2uniqueAttrValues.get(name) == null) { Set<String> set = new HashSet<String>(); set.add(valueLowerCase); name2uniqueAttrValues.put(name, set); StringUtil.addToMultiMap(prefs, name, value); } else { Set<String> set = name2uniqueAttrValues.get(name); if (set.add(valueLowerCase)) { StringUtil.addToMultiMap(prefs, name, value); } } } else { StringUtil.addToMultiMap(prefs, name, value); } } if (prefs.containsKey(Provisioning.A_zimbraPrefMailForwardingAddress)) { if (!account.getBooleanAttr(Provisioning.A_zimbraFeatureMailForwardingEnabled, false)) throw ServiceException.PERM_DENIED("forwarding not enabled"); } // call modifyAttrs and pass true to checkImmutable Provisioning.getInstance().modifyAttrs(account, prefs, true, zsc.getAuthToken()); Element response = zsc.createElement(AccountConstants.MODIFY_PREFS_RESPONSE); return response; }
From source file:net.anyflow.menton.http.HttpResponse.java
public void setContent(String content) { content().writeBytes(Strings.nullToEmpty(content).getBytes(CharsetUtil.UTF_8)); logger.debug(content().toString(CharsetUtil.UTF_8)); }
From source file:org.sosy_lab.solver.mathsat5.Mathsat5InterpolatingProver.java
@Override public BooleanFormula getInterpolant(List<Integer> formulasOfA) throws SolverException { Preconditions.checkState(curEnv != 0); int[] groupsOfA = new int[formulasOfA.size()]; int i = 0;/*ww w . j a v a 2s . c o m*/ for (Integer f : formulasOfA) { groupsOfA[i++] = f; } long itp; try { itp = msat_get_interpolant(curEnv, groupsOfA); } catch (IllegalArgumentException e) { String msg = Strings.nullToEmpty(e.getMessage()); if (msg.contains("impossible to build a suitable congruence graph") || msg.contains("can't build ie-local interpolant") || msg.contains("splitting of AB-mixed terms not supported") || msg.contains("Hypothesis belongs neither to A nor to B")) { // This is not a bug in CPAchecker, but a problem of MathSAT which happens during interpolation throw new SolverException(e.getMessage(), e); } throw e; } if (!useSharedEnv) { itp = msat_make_copy_from(mgr.getEnvironment(), itp, curEnv); } return mgr.encapsulateBooleanFormula(itp); }
From source file:fr.da2i.lup1.entity.formation.Member.java
public String getPicture() { return Strings.nullToEmpty(picture); }
From source file:de.schildbach.pte.TlemProvider.java
@Override protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol, final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) { if ("1".equals(mot)) { if (trainType == null && ("DLR".equals(trainNum) || "Light Railway".equals(trainName))) return new Line(id, network, Product.SUBURBAN_TRAIN, "DLR"); } else if ("13".equals(mot)) { if ("OO".equals(trainType) || "Ordinary passenger (o.pas.)".equals(trainName)) return new Line(id, network, Product.REGIONAL_TRAIN, "OO" + Strings.nullToEmpty(trainNum)); }/*from w w w . j a v a 2s . c o m*/ return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName); }
From source file:org.polimi.zarathustra.Heuristics.java
/** * Checks this heuristic: if an added/deleted/edited attribute or an edited text have different * xpaths on the control and test nodes, consider them as a false difference. This is needed to * deal with the recurring behavior of the comparer according to which elements are erroneously * seen as moved and hence compared with completely different nodes on different xpaths. */// www . ja v a2 s . c o m static boolean editedElementOnDifferentXpath(Difference difference) { String firstXPath = Strings.nullToEmpty(difference.getControlNodeDetail().getXpathLocation()); String secondXPath = Strings.nullToEmpty(difference.getTestNodeDetail().getXpathLocation()); if (((difference.getId() == 2) || (difference.getId() == 3) || (difference.getId() == 14)) && !firstXPath.equalsIgnoreCase(secondXPath)) { return true; } else { return false; } }
From source file:net.ljcomputing.team.domain.Team.java
/** * @see java.lang.Comparable#compareTo(java.lang.Object) *///from w w w .j ava 2 s .c om @Override public int compareTo(Team o) { return ComparisonChain.start().compare(Strings.nullToEmpty(this.name), Strings.nullToEmpty(o.name)) .result(); }
From source file:com.arcbees.bourseje.client.admin.add.AddView.java
@Override public void onFinish(IUploader uploader) { url = Strings.nullToEmpty(uploader.getServerMessage().getMessage()); imagePlaceHolder.setImageSource(url); }
From source file:com.picdrop.model.user.RegisteredUser.java
@Override public String getFullName() { String sep = Strings.isNullOrEmpty(this.lastname) ? "" : " "; return String.format("%s%s%s", Strings.nullToEmpty(this.name), sep, Strings.nullToEmpty(this.lastname)); }