List of usage examples for com.google.common.base Strings isNullOrEmpty
public static boolean isNullOrEmpty(@Nullable String string)
From source file:net.es.nsi.pce.pf.PfUtils.java
public static String getSourceStpOrFail(AttrConstraints constraints) { String sourceStp = getP2PServiceBaseTypeOrFail(constraints).getSourceSTP(); if (Strings.isNullOrEmpty(sourceStp)) { throw Exceptions.missingParameter(Point2PointTypes.getSourceStp().getNamespace(), Point2PointTypes.getSourceStp().getType(), "null"); }//from w ww . j ava 2 s . c o m return sourceStp; }
From source file:br.com.tecsinapse.exporter.converter.DateTableCellConverter.java
@Override public Date apply(String input) { return Strings.isNullOrEmpty(input) ? null : ExporterDateUtils.parseDate(input); }
From source file:com.enonic.cms.core.search.result.AbstractFacetResultXmlCreator.java
protected void addAttributeIfNotNull(Element element, String attributeName, String value) { if (Strings.isNullOrEmpty(value)) { return;// www. j a va 2 s . c o m } element.setAttribute(attributeName, value); }
From source file:org.easyrec.utils.io.MySQL.java
/** * This function adds a Like clause to an SQL statement. * The Like clause starts with the keyword "AND" meaning that given sql string * has to end with the keyword/* w w w . ja va 2 s.c o m*/ * "WHERE" and a clause (e.g. 1=1) before the like clause can be appended. * If the attributeValue has less than 3 charactars a equal comparison is * performed. * * @param sql * @param attribute * @param attributeValue * */ public static StringBuilder addLikeClause(StringBuilder sql, String attribute, String attributeValue) { if (Strings.isNullOrEmpty(attributeValue)) return sql; if (attributeValue.length() > 2) { return sql.append(" AND ").append(attribute).append(" LIKE '%").append(attributeValue).append("%' "); } else { return sql.append(" AND ").append(attribute).append(" = '").append(attributeValue).append("' "); } }
From source file:org.apache.isis.core.metamodel.facets.object.domainobject.objectspecid.ObjectSpecIdFacetForDomainObjectAnnotation.java
public static ObjectSpecIdFacet create(final DomainObject domainObject, final FacetHolder holder) { if (domainObject == null) { return null; }/*from ww w .j a va2 s .co m*/ final String objectType = domainObject.objectType(); if (Strings.isNullOrEmpty(objectType)) { return null; } return new ObjectSpecIdFacetForDomainObjectAnnotation(objectType, holder); }
From source file:org.sonar.core.measure.db.MeasureKey.java
public static MeasureKey of(String componentKey, String metricKey) { Preconditions.checkArgument(!Strings.isNullOrEmpty(componentKey), "Component key must be set"); Preconditions.checkArgument(!Strings.isNullOrEmpty(metricKey), "Metric key must be set"); return new MeasureKey(componentKey, metricKey); }
From source file:org.apache.camel.component.jclouds.JcloudsBlobStoreHelper.java
/** * Creates all directories that are part of the blobName. *///from w w w .j a v a 2 s . c o m public static void mkDirs(BlobStore blobStore, String container, String blobName) { if (blobStore != null && !Strings.isNullOrEmpty(blobName) && blobName.contains("/")) { String directory = BlobStoreUtils.parseDirectoryFromPath(blobName); blobStore.createDirectory(container, directory); } }
From source file:org.sonatype.nexus.security.UserIdMdcHelper.java
public static boolean isSet() { String userId = MDC.get(KEY); return !(Strings.isNullOrEmpty(userId) || UNKNOWN.equals(userId)); }
From source file:org.sourcepit.common.maven.util.Xpp3Utils.java
public static void addDependencyValues(@NotNull final Xpp3Dom dependencyNode, @NotNull Dependency dependency) { String value = dependency.getGroupId(); if (!Strings.isNullOrEmpty(value)) { addValueNode(dependencyNode, "groupId", value); }//from ww w . j ava 2 s. co m value = dependency.getArtifactId(); if (!Strings.isNullOrEmpty(value)) { addValueNode(dependencyNode, "artifactId", value); } value = dependency.getVersion(); if (!Strings.isNullOrEmpty(value)) { addValueNode(dependencyNode, "version", value); } value = dependency.getType(); if (!Strings.isNullOrEmpty(value) && !"jar".equals(value)) { addValueNode(dependencyNode, "type", value); } value = dependency.getClassifier(); if (!Strings.isNullOrEmpty(value)) { addValueNode(dependencyNode, "classifier", value); } value = dependency.getScope(); if (!Strings.isNullOrEmpty(value) && !"compile".equals(value)) { addValueNode(dependencyNode, "scope", value); } value = dependency.getSystemPath(); if (!Strings.isNullOrEmpty(value)) { addValueNode(dependencyNode, "systemPath", value); } value = dependency.getOptional(); if (!Strings.isNullOrEmpty(value) && !"false".equals(value)) { addValueNode(dependencyNode, "optional", value); } }
From source file:org.apache.james.jmap.utils.DownloadPath.java
public static DownloadPath from(String path) { Preconditions.checkArgument(!Strings.isNullOrEmpty(path), "'path' is mandatory"); // path = /blobId/name // idx = 0 1 2 List<String> pathVariables = Splitter.on('/').splitToList(path); Preconditions.checkArgument(pathVariables.size() >= 1 && pathVariables.size() <= 3, "'blobId' is mandatory"); String blobId = Iterables.get(pathVariables, 1, null); Preconditions.checkArgument(!Strings.isNullOrEmpty(blobId), "'blobId' is mandatory"); return new DownloadPath(blobId, name(pathVariables)); }