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:es.uah.aut.srg.micobs.xtext.MICOBSElementAbstractScopeProvider.java

public IScope scope_MCommonPackageFile_imports(final MCommonPackageFile packageFile, EReference imports) {
    Iterable<IEObjectDescription> descriptions = null;

    try {//from w  ww . j  av  a 2  s. c o  m

        descriptions = Iterables.concat(Iterables.transform(getImportLibraryManagers(),
                new Function<ILibraryManager, Iterable<IEObjectDescription>>() {
                    @Override
                    public Iterable<IEObjectDescription> apply(ILibraryManager from) {

                        return Iterables.transform(from.getAllPackages(),
                                new Function<MCommonPackage, IEObjectDescription>() {

                                    @Override
                                    public IEObjectDescription apply(MCommonPackage from) {
                                        return EObjectDescription.create(
                                                qualifiedNameProvider.getFullyQualifiedName(from), from);
                                    }
                                });

                    }
                }));
    } catch (LibraryManagerException e) {
        e.printStackTrace();
        return IScope.NULLSCOPE;
    }
    return new SimpleScope(IScope.NULLSCOPE, Iterables.filter(descriptions, Predicates.notNull()));
}

From source file:net.shibboleth.idp.authn.impl.DefaultAuthenticationResultSerializer.java

/**
 * Set the principal serializers used for principals found in the {@link AuthenticationResult}.
 * // w w w .j  a v a 2  s . c  o m
 * @param serializers principal serializers to use
 */
public void setPrincipalSerializers(
        @Nonnull @NonnullElements Collection<PrincipalSerializer<String>> serializers) {
    ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);

    principalSerializers = new ArrayList<>(Collections2.filter(serializers, Predicates.notNull()));
}

From source file:org.jclouds.ibm.smartcloud.compute.functions.InstanceToNodeMetadata.java

@Override
public NodeMetadata apply(Instance from) {
    // TODO hardware
    String group = parseGroupFromName(from.getName());
    String ip = ipFromIP.apply(from.getPrimaryIP());
    Set<String> ipSet = ip != null ? ImmutableSet.of(ip) : ImmutableSet.<String>of();
    Image image = images.get().get(from.getImageId());
    String key = credentialsMap.get(from.getKeyName());
    return new NodeMetadataBuilder().ids(from.getId() + "").name(from.getName())
            .location(locations.get().get(image.getLocation())).group(group).imageId(from.getImageId())
            .state(instanceStateToNodeState.get(from.getStatus()))
            .operatingSystem(image != null ? image.getOperatingSystem() : null).publicAddresses(ipSet)
            .privateAddresses(Iterables.filter(Iterables.transform(from.getSecondaryIPs(), ipFromIP),
                    Predicates.notNull()))
            .credentials(new Credentials(image.getDefaultCredentials().identity, key)).build();
}

From source file:de.iteratec.iteraplan.businesslogic.exchange.elasticmi.read.BusinessMappingCardinalityValidator.java

/**{@inheritDoc}**/
@Override//from w ww  .ja  v a2 s  .com
protected boolean canValidate(RMetamodel rMetamodel) {
    RStructuredTypeExpression bmType = rMetamodel.findStructuredTypeByPersistentName("BusinessMapping");
    if (bmType == null) {
        return false;
    }

    RRelationshipEndExpression toBp = bmType.findRelationshipEndByPersistentName("businessProcess");
    RRelationshipEndExpression toBu = bmType.findRelationshipEndByPersistentName("businessUnit");
    RRelationshipEndExpression toProd = bmType.findRelationshipEndByPersistentName("product");
    RRelationshipEndExpression toIs = bmType.findRelationshipEndByPersistentName("informationSystemRelease");
    return Iterables.all(Lists.newArrayList(toBp, toBu, toIs, toProd), Predicates.notNull());
}

From source file:net.shibboleth.idp.service.ReloadableSpringService.java

/**
 * Sets the list of configurations for this service.
 * /*from   w  w  w .j  a  v a2  s  .  c  om*/
 * This setting can not be changed after the service has been initialized.
 * 
 * @param configs list of configurations for this service, may be null or empty
 */
public void setServiceConfigurations(@Nonnull final Collection<Resource> configs) {
    ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
    ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);

    serviceConfigurations = ImmutableList.<Resource>builder()
            .addAll(Iterables.filter(configs, Predicates.notNull())).build();
    if (!serviceConfigurations.isEmpty()) {
        resourceLastModifiedTimes = new long[serviceConfigurations.size()];

        int numOfResources = serviceConfigurations.size();
        Resource serviceConfig;
        for (int i = 0; i < numOfResources; i++) {
            serviceConfig = serviceConfigurations.get(i);
            try {
                if (serviceConfig.exists()) {
                    resourceLastModifiedTimes[i] = serviceConfig.lastModified();
                } else {
                    resourceLastModifiedTimes[i] = -1;
                }
            } catch (IOException e) {
                log.info("{} Configuration resource '" + serviceConfig.getDescription()
                        + "' last modification date could not be determined", getLogPrefix(), e);
                resourceLastModifiedTimes[i] = -1;
            }
        }
    } else {
        resourceLastModifiedTimes = null;
    }
}

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

/**
 * Set the source attribute IDs./*w  ww. j  a v a  2s.com*/
 * 
 * @param newSourceAttributes the source attribute IDs
 */
public void setSourceAttributes(@Nonnull @NullableElements final List<String> newSourceAttributes) {
    ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
    ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);

    final ArrayList<String> checkedSourceAttrs = new ArrayList<String>(newSourceAttributes.size());
    CollectionSupport.addIf(checkedSourceAttrs, newSourceAttributes, Predicates.notNull());
    sourceAttributes = Collections.unmodifiableList(checkedSourceAttrs);
}

From source file:org.apache.beam.runners.spark.aggregators.metrics.WithNamedAggregatorsSupport.java

private Function<Map.Entry<String, Metric>, Map<String, Gauge>> toGauges() {
    return new Function<Map.Entry<String, Metric>, Map<String, Gauge>>() {
        @Override//  ww  w .j a v a  2s .  c o  m
        public Map<String, Gauge> apply(final Map.Entry<String, Metric> entry) {
            final NamedAggregators agg = ((AggregatorMetric) entry.getValue()).getNamedAggregators();
            final String parentName = entry.getKey();
            final Map<String, Gauge> gaugeMap = Maps.transformEntries(agg.renderAll(), toGauge());
            final Map<String, Gauge> fullNameGaugeMap = Maps.newLinkedHashMap();
            for (Map.Entry<String, Gauge> gaugeEntry : gaugeMap.entrySet()) {
                fullNameGaugeMap.put(parentName + "." + gaugeEntry.getKey(), gaugeEntry.getValue());
            }
            return Maps.filterValues(fullNameGaugeMap, Predicates.notNull());
        }
    };
}

From source file:org.eclipse.xtext.scoping.Scopes.java

public static Iterable<IEObjectDescription> filterDuplicates(Iterable<IEObjectDescription> filtered) {
    Map<QualifiedName, IEObjectDescription> result = Maps.newLinkedHashMap();
    for (IEObjectDescription e : filtered) {
        QualifiedName qualifiedName = e.getName();
        if (result.containsKey(qualifiedName)) {
            result.put(qualifiedName, null);
        } else {//w w w  .j av  a 2  s  .com
            result.put(qualifiedName, e);
        }
    }
    return Iterables.filter(result.values(), Predicates.notNull());
}

From source file:net.shibboleth.idp.attribute.filter.context.AttributeFilterContext.java

/**
 * Sets the attributes that have been filtered.
 * //from  w w  w .j a va2  s  .  c om
 * @param attributes attributes that have been filtered
 */
public void setFilteredIdPAttributes(@Nullable @NullableElements final Collection<IdPAttribute> attributes) {
    Collection<IdPAttribute> checkedAttributes = new ArrayList<>();
    CollectionSupport.addIf(checkedAttributes, attributes, Predicates.notNull());

    filteredAttributes = MapConstraints.constrainedMap(
            new HashMap<String, IdPAttribute>(checkedAttributes.size()), MapConstraints.notNull());

    for (final IdPAttribute attribute : checkedAttributes) {
        filteredAttributes.put(attribute.getId(), attribute);
    }
}

From source file:org.opensaml.saml.common.profile.logic.EntityAttributesPredicate.java

/**
 * Constructor./* w w  w  . j av  a  2s.  c o  m*/
 * 
 * @param candidates the {@link Candidate} criteria to check for
 * @param trim true iff the values found in the metadata should be trimmed before comparison
 * @param all true iff all the criteria must match to be a successful test
 */
public EntityAttributesPredicate(@Nonnull @NonnullElements final Collection<Candidate> candidates,
        final boolean trim, final boolean all) {

    Constraint.isNotNull(candidates, "Attribute collection cannot be null");

    candidateSet = new ArrayList<>(Collections2.filter(candidates, Predicates.notNull()));

    trimTags = trim;
    matchAll = all;
}