Example usage for com.google.common.base Predicates notNull

List of usage examples for com.google.common.base Predicates notNull

Introduction

In this page you can find the example usage for com.google.common.base Predicates notNull.

Prototype

@GwtCompatible(serializable = true)
public static <T> Predicate<T> notNull() 

Source Link

Document

Returns a predicate that evaluates to true if the object reference being tested is not null.

Usage

From source file:org.testfx.service.query.impl.NodeQueryImpl.java

@Override
public NodeQuery lookup(Function<Node, Set<Node>> function) {
    FluentIterable<Node> query = FluentIterable.from(parentNodes);
    query = query.filter(Predicates.notNull());
    query = query.transformAndConcat(function);
    parentNodes = query.toSet();// w  w w.ja v a 2 s. c o m
    return this;
}

From source file:com.isotrol.impe3.idx.config.NodeSearcherFactoryBean.java

private Queryable getQueryable() {
    if (providers == null || providers.isEmpty()) {
        return null;
    }//from   w w w . j a v  a2 s .c om
    Set<DirectoryProvider> set = Sets.newHashSet(Iterables.filter(providers, Predicates.notNull()));
    if (set.isEmpty()) {
        return null;
    }
    if (set.size() == 1) {
        DirectoryProvider p = set.iterator().next();
        return managed ? Queryables.managed(p) : Queryables.simple(p);
    }
    return managed ? Queryables.managed(set) : Queryables.multi(set);
}

From source file:org.opensaml.storage.impl.client.PopulateClientStorageSaveContext.java

/**
 * Set the {@link ClientStorageService} instances to check for saving.
 * //from  w  w  w  .ja va 2s.c o  m
 * @param services instances to check for saving
 */
public void setStorageServices(@Nonnull @NonnullElements final Collection<ClientStorageService> services) {
    ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);

    Constraint.isNotNull(services, "StorageService collection cannot be null");
    storageServices = new ArrayList<>(Collections2.filter(services, Predicates.notNull()));
}

From source file:net.shibboleth.idp.attribute.filter.impl.AttributeFilterImpl.java

/**
 * Constructor.//from  w ww.  ja va  2s. c  o m
 * 
 * @param engineId ID of this engine
 * @param policies filter policies used by this engine
 */
public AttributeFilterImpl(@Nonnull @NotEmpty String engineId,
        @Nullable @NullableElements final Collection<AttributeFilterPolicy> policies) {
    setId(engineId);

    ArrayList<AttributeFilterPolicy> checkedPolicies = new ArrayList<>();
    CollectionSupport.addIf(checkedPolicies, policies, Predicates.notNull());
    filterPolicies = ImmutableList.copyOf(Iterables.filter(checkedPolicies, Predicates.notNull()));
}

From source file:net.shibboleth.idp.attribute.resolver.impl.ad.mapped.ValueMap.java

/**
 * Sets the Source values for the mapping.
 *
 * @param newValues functions used to map an input value to an output value
 *///ww  w. ja va2s. com
public synchronized void setSourceValues(@Nullable @NullableElements final Collection<SourceValue> newValues) {

    sourceValues = ImmutableSet.copyOf(Iterables.filter(newValues, Predicates.notNull()));
}

From source file:com.google.cloud.dataflow.sdk.util.CombiningOutputBuffer.java

@Override
public OutputT extract(OutputBuffer.Context<K, W> c) throws IOException {
    Iterable<AccumT> accums = FluentIterable.from(c.sourceWindows())
            .transform(Functions.forMap(inMemoryBuffer, null)).filter(Predicates.notNull())
            .append(c.readBuffers(accumTag, c.sourceWindows()));

    AccumT result = Iterables.isEmpty(accums) ? null : combineFn.mergeAccumulators(c.key(), accums);

    clear(c);//from   www. j a v  a2  s.com
    inMemoryBuffer.put(c.window(), result);

    return result == null ? null : combineFn.extractOutput(c.key(), result);
}

From source file:com.facebook.presto.server.MockQueryManager.java

@Override
public List<QueryInfo> getAllQueryInfo() {
    return ImmutableList.copyOf(filter(transform(queries.values(), new Function<SimpleQuery, QueryInfo>() {
        @Override//from w  ww  . j  av  a  2 s  .  com
        public QueryInfo apply(SimpleQuery queryWorker) {
            try {
                return queryWorker.getQueryInfo();
            } catch (RuntimeException ignored) {
                return null;
            }
        }
    }), Predicates.notNull()));
}

From source file:net.shibboleth.idp.attribute.resolver.ad.mapped.impl.ValueMap.java

/**
 * Sets the Source values for the mapping.
 *
 * @param newValues functions used to map an input value to an output value
 *//*from  w ww  .  jav  a 2s .c  o  m*/
public void setSourceValues(@Nullable @NullableElements final Collection<SourceValue> newValues) {

    sourceValues = ImmutableSet.copyOf(Iterables.filter(newValues, Predicates.notNull()));
}

From source file:org.geogit.storage.memory.HeapGraphDatabase.java

@Override
public ImmutableList<ObjectId> getParents(ObjectId commitId) throws IllegalArgumentException {
    return graph.get(commitId).transform(new Function<Node, ImmutableList<ObjectId>>() {
        @Override/* w w w  . ja va  2  s . com*/
        public ImmutableList<ObjectId> apply(Node n) {
            // transform outgoing nodes to id
            // filter for null to skip fake root node
            return new ImmutableList.Builder<ObjectId>()
                    .addAll(filter(transform(n.to(), NODE_TO_ID), Predicates.notNull())).build();
        }
    }).or((ImmutableList) ImmutableList.of());
}

From source file:todoapp.fixture.security.userrole.UserRolesFixtureScript.java

@Override
protected void execute(ExecutionContext ec) {

    // required/*from w w  w.  j  av  a 2s  . c om*/
    final String username = Util.coalesce(ec.getParameter("username"), getUsername());
    if (username == null) {
        throw new IllegalArgumentException("username is required");
    }

    // validate user
    this.applicationUser = applicationUsers.findUserByUsername(username);
    if (this.applicationUser == null) {
        throw new IllegalArgumentException(String.format("No user with username: '%s'", username));
    }

    // no defaults for roles

    // validate all roleNames
    this.applicationRoleList = Lists.newArrayList(
            Iterables.filter(Iterables.transform(getRoleNames(), roleNameToRole()), Predicates.notNull()));

    if (this.applicationRoleList.size() != getRoleNames().size()) {
        throw new IllegalArgumentException("One or more roles not found");
    }

    // execute
    ec.addResult(this, applicationUser.getName(), this.applicationUser);

    for (ApplicationRole applicationRole : this.applicationRoleList) {
        if (applicationRole != null) {
            this.applicationUser.addRole(applicationRole);
        }
        ec.addResult(this, applicationRole.getName(), applicationRole);
    }
}