Example usage for com.google.common.base Strings nullToEmpty

List of usage examples for com.google.common.base Strings nullToEmpty

Introduction

In this page you can find the example usage for com.google.common.base Strings nullToEmpty.

Prototype

public static String nullToEmpty(@Nullable String string) 

Source Link

Document

Returns the given string if it is non-null; the empty string otherwise.

Usage

From source file:com.google.cloud.tools.intellij.appengine.cloud.executor.AppEngineStandardRunTask.java

@Override
public void execute(ProcessStartListener startListener) {
    CloudSdkService sdkService = CloudSdkService.getInstance();

    // show a warning notification if the cloud sdk version is not supported
    CloudSdkVersionNotifier.getInstance().notifyIfUnsupportedVersion();

    CloudSdk sdk = new CloudSdk.Builder().sdkPath(sdkService.getSdkHomePath()).async(true)
            .startListener(startListener).build();

    CloudSdkAppEngineDevServer devServer = new CloudSdkAppEngineDevServer(sdk);
    devServer.run(runConfig);/*from  w w w  .j  a va2  s  .  co m*/

    UsageTrackerProvider.getInstance().trackEvent(GctTracking.APP_ENGINE_RUN)
            .addMetadata(GctTracking.METADATA_LABEL_KEY, Strings.nullToEmpty(runnerId)).ping();

}

From source file:com.electronicpanopticon.spring.web.rest.RestClient.java

public String applicationUrl() {
    return serverUrl() + "/" + Strings.nullToEmpty(applicationPath);
}

From source file:mobi.jenkinsci.server.core.services.ProxyHttpClientURLDownloader.java

private boolean isHTMLPage(RawBinaryNode result) {
    return Strings.nullToEmpty(result.getHttpContentType()).contains("text/html");
}

From source file:com.b2international.snowowl.snomed.datastore.request.SnomedSimpleMapMemberWithDescriptionCreateDelegate.java

@Override
public String execute(SnomedRefSet refSet, TransactionContext context) {
    checkRefSetType(refSet, SnomedRefSetType.SIMPLE_MAP_WITH_DESCRIPTION);
    checkReferencedComponent(refSet);//  w w w . j ava 2  s.c o  m
    checkNonEmptyProperty(refSet, SnomedRf2Headers.FIELD_MAP_TARGET);

    checkComponentExists(refSet, context, SnomedRf2Headers.FIELD_MODULE_ID, getModuleId());
    checkComponentExists(refSet, context, SnomedRf2Headers.FIELD_REFERENCED_COMPONENT_ID,
            getReferencedComponentId());

    if (SnomedIdentifiers.isValid(getProperty(SnomedRf2Headers.FIELD_MAP_TARGET))) {
        checkComponentExists(refSet, context, SnomedRf2Headers.FIELD_MAP_TARGET);
    }

    SnomedSimpleMapRefSetMember member = SnomedComponents.newSimpleMapMember().withId(getId())
            .withActive(isActive()).withReferencedComponent(getReferencedComponentId())
            .withModule(getModuleId()).withRefSet(getReferenceSetId())
            .withMapTargetId(getComponentId(SnomedRf2Headers.FIELD_MAP_TARGET))
            .withMapTargetDescription(
                    Strings.nullToEmpty(getProperty(SnomedRf2Headers.FIELD_MAP_TARGET_DESCRIPTION)))
            .addTo(context);

    return member.getUuid();
}

From source file:com.b2international.snowowl.snomed.datastore.internal.id.SnomedIdentifierImpl.java

@Override
public String toString() {
    if (id == null) {
        id = String.format("%s%s%s%s%s", itemId, Strings.nullToEmpty(namespace), formatIdentifier,
                componentIdentifier, checkDigit);
    }/*  ww  w. j  ava2 s .c  o  m*/
    return id;
}

From source file:de.schildbach.wallet.data.AddressBookLiveData.java

public void setConstraint(final String constraint) {
    loader.setSelectionArgs(new String[] { Strings.nullToEmpty(constraint) });
    loader.forceLoad();/*from  w  w w  .j a  v  a 2s  .  co m*/
}

From source file:uk.org.ukfederation.mda.EntityDescriptorUKIdPopulationStage.java

/** {@inheritDoc} */
@Override//from   w ww  .  j a v a  2 s  . c om
protected void doExecute(@Nonnull @NonnullElements final Collection<Item<Element>> items)
        throws StageProcessingException {

    // ID values that we have already seen (they must be unique)
    final Set<String> ids = new HashSet<>(items.size());

    for (Item<Element> item : items) {
        final Element element = item.unwrap();
        final ClassToInstanceMultiMap<ItemMetadata> metadata = item.getItemMetadata();

        if (!SAMLMetadataSupport.isEntityDescriptor(element)) {
            // all items must be EntityDescriptor elements
            metadata.put(new ErrorStatus(getId(), "item was not an EntityDescriptor"));
        } else {
            final String id = AttributeSupport.getAttributeValue(element, null, "ID");
            final String eid = Strings
                    .nullToEmpty(AttributeSupport.getAttributeValue(element, null, "entityID"));
            if (id == null) {
                metadata.put(
                        new ErrorStatus(getId(), "EntityDescriptor " + eid + " did not have an ID attribute"));
            } else if (!pattern.matcher(id).matches()) {
                metadata.put(new ErrorStatus(getId(), "EntityDescriptor " + eid + " has an ID value '" + id
                        + "' that does not look like a UK federation identifier"));
            } else if (ids.contains(id)) {
                metadata.put(
                        new ErrorStatus(getId(), "EntityDescriptor " + eid + " has duplicate ID value " + id));
            } else {
                metadata.put(new UKId(id));
                ids.add(id);
            }
        }

    }
}

From source file:org.sonar.plugins.j3c.jacoco.JacocoAnalyzer.java

public JacocoAnalyzer(ModuleFileSystem fileSystem, PathResolver pathResolver, J3cConfiguration configuration,
        JavaResourceLocator javaResourceLocator) {
    this.fileSystem = fileSystem;
    this.pathResolver = pathResolver;
    this.configuration = configuration;
    this.javaResourceLocator = javaResourceLocator;
    this.excludesMatcher = new WildcardMatcher(Strings.nullToEmpty(configuration.getExcludes()));
}

From source file:com.zimbra.cs.mailbox.Document.java

public String getFragment() {
    return Strings.nullToEmpty(fragment);
}

From source file:org.sonatype.nexus.security.privilege.PrivilegeDescriptorSupport.java

/**
 * Helper to read a required privilege property.
 *
 * @throws IllegalStateException Missing required property.
 *///from w  ww  . j  a v  a  2 s.  co m
protected String readProperty(final CPrivilege privilege, final String name) {
    String value = privilege.getProperty(name);
    checkState(!Strings.nullToEmpty(value).isEmpty(), "Missing required property: %s", name);
    return value;
}