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.obm.push.search.ldap.Configuration.java

@Inject
@VisibleForTesting/*ww w  . ja  va  2 s.  c o m*/
Configuration(IniFile.Factory iniFileFactory, @Named(LoggerModule.CONFIGURATION) Logger configurationLogger) {
    IniFile ini = iniFileFactory.build(LDAP_CONF_FILE);

    logger = configurationLogger;
    url = validUrlOrNull(ini.getStringValue(SEARCH_LDAP_URL));
    baseDn = Strings.emptyToNull(ini.getStringValue(SEARCH_LDAP_BASE));
    filter = Strings.emptyToNull(ini.getStringValue(SEARCH_LDAP_FILTER));
    limit = getValidLimit(ini);
    settings = buildSettings();
    isValidConfiguration = checkConfigurationValidity();

    logConfiguration();
}

From source file:io.druid.segment.filter.ExtractionFilter.java

@Override
public ValueMatcher makeMatcher(ValueMatcherFactory factory) {
    return factory.makeValueMatcher(dimension, new Predicate<String>() {
        @Override//from  w w  w. ja  v a 2  s .  c  om
        public boolean apply(String input) {
            // Assuming that a null/absent/empty dimension are equivalent from the druid perspective
            return value.equals(Strings.nullToEmpty(fn.apply(Strings.emptyToNull(input))));
        }
    });
}

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

@Override
public GroupInfo apply(TopLevelResource resource, Input input) throws AuthException, BadRequestException,
        UnprocessableEntityException, NameAlreadyUsedException, OrmException {
    if (input == null) {
        input = new Input();
    }//from  w  w w.j a  v  a2  s  .  co  m
    if (input.name != null && !name.equals(input.name)) {
        throw new BadRequestException("name must match URL");
    }

    AccountGroup.Id ownerId = owner(input);
    AccountGroup group;
    try {
        group = op.create().createGroup(name, Strings.emptyToNull(input.description),
                Objects.firstNonNull(input.visibleToAll, defaultVisibleToAll), ownerId,
                ownerId == null ? Collections.singleton(self.get().getAccountId())
                        : Collections.<Account.Id>emptySet(),
                null);
    } catch (PermissionDeniedException e) {
        throw new AuthException(e.getMessage());
    }
    return json.format(GroupDescriptions.forAccountGroup(group));
}

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

/**
 * Sets the dbuuid of this {@link Matrix}.
 * /*from ww w . j a v  a2 s  .  c  o m*/
 * Empty strings are conveted to null.
 * 
 * @param dbuuid
 *            the dbuuid to be set
 */
public void setDbuuid(String dbuuid) {
    this.dbuuid = Strings.emptyToNull(dbuuid);
}

From source file:org.gbif.metadata.eml.Agent.java

public String getFullName() {
    String name = "";
    if (firstName != null && !firstName.isEmpty()) {
        name += firstName;/*from  w  ww.  j  a va 2 s.com*/
    }
    if (lastName != null && !lastName.isEmpty()) {
        name += " " + lastName;
    }
    return Strings.emptyToNull(name.trim());
}

From source file:de.bund.bfr.knime.ui.StringTextArea.java

private void textChanged() {
    value = Strings.emptyToNull(getText().trim());
    valueValid = value != null || optional;
    Stream.of(getListeners(TextListener.class)).forEach(l -> l.textChanged(this));
}

From source file:org.impressivecode.depress.scm.svn.SVNOfflineAdapterNodeModel.java

@Override
protected BufferedDataTable[] execute(final BufferedDataTable[] inData, final ExecutionContext exec)
        throws Exception {
    try {/*from   w  w  w.  jav  a  2 s.com*/
        LOGGER.info("Reading logs from file " + this.fileName.getStringValue());
        userExtensions = new ArrayList<String>();
        Collections.addAll(userExtensions, getExtensions());
        String packageNameToFilter = Strings.emptyToNull(packageName.getStringValue());
        SCMParserOptions parserOptions = options(packageNameToFilter, userExtensions);

        SVNExtensionParser parser = new SVNExtensionParser(parserOptions);

        List<SCMDataType> commits = parser.parseEntries(this.fileName.getStringValue());

        LOGGER.info("Reading logs finished");
        BufferedDataTable out = transform(commits, exec);
        LOGGER.info("Transforming logs finished.");
        return new BufferedDataTable[] { out };
    } catch (Exception ex) {
        LOGGER.error("Unable to parse SVN entries", ex);
        throw ex;
    }

}

From source file:fathom.realm.ldap.LdapRealm.java

@Override
public void setup(Config config) {
    super.setup(config);

    ldapUrl = Strings.emptyToNull(config.getString("url"));
    Preconditions.checkNotNull(ldapUrl, "The LDAP 'url' setting may not be null nor empty!");

    ldapUsername = "";
    if (config.hasPath("username")) {
        ldapUsername = config.getString("username");
    }// w w  w  .jav  a2 s. c o m

    ldapPassword = "";
    if (config.hasPath("password")) {
        ldapPassword = config.getString("password");
    }

    ldapBindPattern = "";
    if (config.hasPath("bindPattern")) {
        ldapBindPattern = config.getString("bindPattern");
    }

    accountBase = "";
    if (config.hasPath("accountBase")) {
        accountBase = config.getString("accountBase");
    }

    accountPattern = "(&(objectClass=person)(sAMAccountName=${username}))";
    if (config.hasPath("accountPattern")) {
        accountPattern = config.getString("accountPattern");
    }

    if (config.hasPath("nameMapping")) {
        nameMapping = config.getString("nameMapping");
    }

    if (config.hasPath("emailMapping")) {
        emailMapping = config.getString("emailMapping");
    }

    groupBase = "";
    if (config.hasPath("groupBase")) {
        config.getString("groupBase");
    }

    groupMemberPattern = "(&(objectClass=group)(member=${dn}))";
    if (config.hasPath("groupMemberPattern")) {
        groupMemberPattern = config.getString("groupMemberPattern");
    }

    if (config.hasPath("adminGroups")) {
        adminGroups = config.getStringList("adminGroups");
    }

}

From source file:com.linecorp.armeria.server.docs.MethodInfo.java

/**
 * Creates a new instance./* ww  w.  j  a  v  a2  s.c  o m*/
 */
public MethodInfo(String name, TypeSignature returnTypeSignature, Iterable<FieldInfo> parameters,
        Iterable<TypeSignature> exceptionTypeSignatures, Iterable<EndpointInfo> endpoints,
        Iterable<HttpHeaders> exampleHttpHeaders, Iterable<String> exampleRequests,
        @Nullable String docString) {

    this.name = requireNonNull(name, "name");

    this.returnTypeSignature = requireNonNull(returnTypeSignature, "returnTypeSignature");
    this.parameters = ImmutableList.copyOf(requireNonNull(parameters, "parameters"));
    this.exceptionTypeSignatures = ImmutableSortedSet.copyOf(comparing(TypeSignature::signature),
            requireNonNull(exceptionTypeSignatures, "exceptionTypeSignatures"));
    this.endpoints = ImmutableSortedSet.copyOf(Comparator.comparing(e -> e.hostnamePattern() + ':' + e.path()),
            requireNonNull(endpoints, "endpoints"));
    this.exampleHttpHeaders = Streams.stream(requireNonNull(exampleHttpHeaders, "exampleHttpHeaders"))
            .map(HttpHeaders::copyOf).map(HttpHeaders::asImmutable).collect(toImmutableList());
    this.exampleRequests = ImmutableList.copyOf(requireNonNull(exampleRequests, "exampleRequests"));
    this.docString = Strings.emptyToNull(docString);
}

From source file:org.killbill.billing.plugin.notification.generator.formatters.DefaultInvoiceItemFormatter.java

@Override
public String getPhaseName() {
    return MoreObjects.firstNonNull(Strings.emptyToNull(translator.get(item.getPhaseName())),
            Strings.nullToEmpty(item.getPhaseName()));
}