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:net.shibboleth.idp.authn.impl.PopulateSubjectCanonicalizationContext.java

/**
 * Set the flows available for possible use.
 * //from w  w  w. j a  v  a 2s  . c  o  m
 * @param flows the flows available for possible use
 */
public void setAvailableFlows(
        @Nonnull @NonnullElements final Collection<SubjectCanonicalizationFlowDescriptor> flows) {
    ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
    Constraint.isNotNull(flows, "Flow collection cannot be null");

    availableFlows = new ArrayList<>(Collections2.filter(flows, Predicates.notNull()));
}

From source file:brooklyn.networking.subnet.PortForwarderAsyncImpl.java

@Override
public void openFirewallPortRangeAsync(final EntityAndAttribute<String> publicIp, final PortRange portRange,
        final Protocol protocol, final Cidr accessingCidr) {
    DeferredExecutor<String> updater = new DeferredExecutor<String>("open-firewall", publicIp,
            Predicates.notNull(), new Runnable() {
                public void run() {
                    portForwarder.openFirewallPortRange(publicIp.getEntity(), portRange, protocol,
                            accessingCidr);
                }/*w  w w  .j a  v a 2 s.  co  m*/
            });
    subscribe(publicIp.getEntity(), publicIp.getAttribute(), updater);
    updater.apply(publicIp.getEntity(), publicIp.getValue());
}

From source file:org.sonar.db.issue.IssueDao.java

/**
 * Gets a list issues by their keys. The result does NOT contain {@code null} values for issues not found, so
 * the size of result may be less than the number of keys. A single issue is returned
 * if input keys contain multiple occurrences of a key.
 * <p>Contrary to {@link #selectByKeys(DbSession, Collection)}, results are in the same order as input keys.</p>
 *//*from ww w .  j a v  a2s .  c  o  m*/
public List<IssueDto> selectByOrderedKeys(DbSession session, List<String> keys) {
    List<IssueDto> unordered = selectByKeys(session, keys);
    return from(keys).transform(new KeyToIssue(unordered)).filter(Predicates.notNull()).toList();
}

From source file:net.shibboleth.idp.saml.impl.attribute.principalconnector.PrinicpalConnectorCanonicalizer.java

/**
 * Constructor.//from  w  w w .jav a  2  s  .co  m
 * 
 * @param connectors the connectors we care about.
 */
public PrinicpalConnectorCanonicalizer(
        @Nullable @NullableElements final Collection<PrincipalConnector> connectors) {

    if (null != connectors) {
        principalConnectors = ImmutableSet.copyOf(Iterables.filter(connectors, Predicates.notNull()));
    } else {
        principalConnectors = Collections.emptySet();
    }
}

From source file:org.eclipse.xtext.resource.impl.ResourceSetBasedResourceDescriptions.java

@Override
public Iterable<IResourceDescription> getAllResourceDescriptions() {
    if (data != null) {
        return data.getAllResourceDescriptions();
    }/*from  www .j  a va2 s  . c  om*/
    return Iterables.filter(new Iterable<IResourceDescription>() {
        @Override
        public Iterator<IResourceDescription> iterator() {
            return new AbstractIterator<IResourceDescription>() {
                int index = 0;
                List<Resource> resources = resourceSet.getResources();

                @Override
                protected IResourceDescription computeNext() {
                    if (resources.size() <= index)
                        return endOfData();
                    Resource resource = resources.get(index);
                    index++;
                    return getResourceDescription(resource.getURI());
                }
            };
        }
    }, Predicates.notNull());

}

From source file:net.shibboleth.idp.authn.context.CertificateContext.java

/**
 * Set the additional certificates accompanying the end-entity certificate.
 * //from ww w. j  av a 2  s.  c  o m
 * @param certs additional certificates
 * 
 * @return this context
 */
public CertificateContext setIntermediates(@Nonnull @NonnullElements final Collection<Certificate> certs) {
    Constraint.isNotNull(certs, "Intermediate certificate collection cannot be null");

    intermediates.clear();
    intermediates.addAll(Collections2.filter(certs, Predicates.notNull()));

    return this;
}

From source file:org.opensaml.security.credential.impl.AbstractChainingCredentialResolver.java

/**
 * Constructor./*from ww  w .  jav  a 2  s. c  om*/
 * 
 * @param credResolvers the list of chained credential resolvers
 */
public AbstractChainingCredentialResolver(@Nonnull final List<ResolverType> credResolvers) {
    Constraint.isNotNull(credResolvers, "CredentialResolver list cannot be null");
    resolvers = new ArrayList<>(Collections2.filter(credResolvers, Predicates.notNull()));
}

From source file:com.example.ModelWithAnonymousClass.java

public List<String> transform(List<String> paths, final String property) {
    return FluentIterable.from(paths).transform(new Function<String, String>() {
        @Override//  ww  w .ja va 2s  . c  o m
        public String apply(String path) {
            Resource resource = resourceResolver.getResource(path); // Noncompliant {{Objects annotated by @SliceResource should not use or return any session based object, except in constructor or com.cognifide.slice.api.model.InitializableModel.afterCreated().}}
            return resource.getValueMap().get(property, String.class);
        }
    }).filter(Predicates.notNull()).toList();
}

From source file:io.druid.query.GroupByMergedQueryRunner.java

public GroupByMergedQueryRunner(ExecutorService exec, Supplier<GroupByQueryConfig> configSupplier,
        QueryWatcher queryWatcher, StupidPool<ByteBuffer> bufferPool, Iterable<QueryRunner<T>> queryables) {
    this.exec = MoreExecutors.listeningDecorator(exec);
    this.queryWatcher = queryWatcher;
    this.queryables = Iterables.unmodifiableIterable(Iterables.filter(queryables, Predicates.notNull()));
    this.configSupplier = configSupplier;
    this.bufferPool = bufferPool;
}

From source file:org.opensaml.core.xml.util.IndexedXMLObjectChildrenList.java

/**
 * Constructor.//from  w  w  w.j a  v a2  s .  c  o m
 * 
 * @param parent the parent of all elements
 * @param col collection to add to this list
 */
public IndexedXMLObjectChildrenList(@Nonnull final XMLObject parent,
        @Nonnull final Collection<ElementType> col) {
    super(parent);
    Constraint.isNotNull(col, "Initial collection cannot be null");

    objectIndex = new LazyMap<>();

    // This does call our add, which handles the null case properly, but
    // I didn't want to depend on that implementation. Keeping the fail silently
    // behavior means not using an Immutable collection copy.
    addAll(Collections2.filter(col, Predicates.notNull()));
}