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

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

Introduction

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

Prototype

@Nullable
public static String emptyToNull(@Nullable String string) 

Source Link

Document

Returns the given string if it is nonempty; null otherwise.

Usage

From source file:org.n52.sos.request.RequestContext.java

public void setToken(String token) {
    this.token = Optional.fromNullable(Strings.emptyToNull(token));
}

From source file:io.druid.query.extraction.JavascriptExtractionFn.java

@Override
public String apply(Object value) {
    return Strings.emptyToNull(fn.apply(value));
}

From source file:io.github.bktlib.command.CommandBase.java

/**
 * @return A {@link Command#description() descrio} desse commando
 *//*from  w ww  .  ja  v  a  2 s  .  c o m*/
public Optional<String> getDescription() {
    return Optional.ofNullable(Strings.emptyToNull(commandAnnotation.description()));
}

From source file:org.n52.sos.util.Reference.java

public Reference setShow(String show) {
    this.show = Optional.fromNullable(Strings.emptyToNull(show));
    return this;
}

From source file:com.google.gerrit.server.account.InternalAccountDirectory.java

private void fill(AccountInfo info, Account account, @Nullable Collection<ExternalId> externalIds,
        Set<FillOptions> options) {
    if (options.contains(FillOptions.ID)) {
        info._accountId = account.getId().get();
    } else {/*from  ww w.  j av  a 2  s  .  com*/
        // Was previously set to look up account for filling.
        info._accountId = null;
    }
    if (options.contains(FillOptions.NAME)) {
        info.name = Strings.emptyToNull(account.getFullName());
        if (info.name == null) {
            info.name = account.getUserName();
        }
    }
    if (options.contains(FillOptions.EMAIL)) {
        info.email = account.getPreferredEmail();
    }
    if (options.contains(FillOptions.SECONDARY_EMAILS)) {
        info.secondaryEmails = externalIds != null ? getSecondaryEmails(account, externalIds) : null;
    }
    if (options.contains(FillOptions.USERNAME)) {
        info.username = externalIds != null ? AccountState.getUserName(externalIds) : null;
    }

    if (options.contains(FillOptions.STATUS)) {
        info.status = account.getStatus();
    }

    if (options.contains(FillOptions.AVATARS)) {
        AvatarProvider ap = avatar.get();
        if (ap != null) {
            info.avatars = new ArrayList<>(3);
            IdentifiedUser user = userFactory.create(account.getId());

            // GWT UI uses DEFAULT_SIZE (26px).
            addAvatar(ap, info, user, AvatarInfo.DEFAULT_SIZE);

            // PolyGerrit UI prefers 32px and 100px.
            if (!info.avatars.isEmpty()) {
                if (32 != AvatarInfo.DEFAULT_SIZE) {
                    addAvatar(ap, info, user, 32);
                }
                if (100 != AvatarInfo.DEFAULT_SIZE) {
                    addAvatar(ap, info, user, 100);
                }
            }
        }
    }
}

From source file:de.bund.bfr.knime.pmm.js.common.Matrix.java

/**
 * Sets the name of this {@link Matrix}.
 * /*from   w  w  w  . j ava2  s. c  o m*/
 * Empty strings are converted to null.
 * 
 * @param name
 *            the name to be set
 */
public void setName(String name) {
    this.name = Strings.emptyToNull(name);
}

From source file:fathom.shiro.FormAuthcHandler.java

protected void redirectRequest(Context context) {
    String originalDestination = context.getSession(FormAuthcGuard.DESTINATION_ATTRIBUTE);
    String redirectPath = Optional.fromNullable(Strings.emptyToNull(originalDestination)).or("/");
    context.redirect(redirectPath);/*from w w w . ja v a  2s  .  c  o m*/
}

From source file:org.n52.shetland.ogc.ows.OwsCapabilities.java

public void setService(String service) {
    this.service = Optional.ofNullable(Strings.emptyToNull(service));
}

From source file:org.sonar.server.user.AbstractUserSession.java

public T setName(@Nullable String s) {
    this.name = Strings.emptyToNull(s);
    return clazz.cast(this);
}

From source file:com.google.gerrit.server.group.GroupJson.java

private GroupInfo init(GroupDescription.Basic group) {
    GroupInfo info = new GroupInfo();
    info.id = Url.encode(group.getGroupUUID().get());
    info.name = Strings.emptyToNull(group.getName());
    info.url = Strings.emptyToNull(group.getUrl());
    info.options = new GroupOptionsInfo(group);

    AccountGroup g = GroupDescriptions.toAccountGroup(group);
    if (g != null) {
        info.description = Strings.emptyToNull(g.getDescription());
        info.groupId = g.getId().get();/* w  ww  . ja v  a2  s .co  m*/
        if (g.getOwnerGroupUUID() != null) {
            info.ownerId = Url.encode(g.getOwnerGroupUUID().get());
            GroupDescription.Basic o = groupBackend.get(g.getOwnerGroupUUID());
            if (o != null) {
                info.owner = o.getName();
            }
        }
    }

    return info;
}