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.loadui.testfx.service.finder.impl.NodeFinderImpl.java

private Set<Node> transformToResultNodes(List<Window> windows,
        Function<Node, Set<Node>> toResultNodesFunction) {
    //return FluentIterable.from(windows)
    //    .transform(toRootNodeFunction())
    //    .transformAndConcat(toResultNodesFunction)
    //    .filter(Predicates.notNull())
    //    .toSet();
    Iterable<Node> rootNodes = Iterables.transform(windows, toRootNodeFunction());
    Iterable<Set<Node>> resultNodeSets = Iterables.transform(rootNodes, toResultNodesFunction);
    Iterable<Node> resultNodes = Iterables.concat(resultNodeSets);
    return ImmutableSet.copyOf(Iterables.filter(resultNodes, Predicates.notNull()));
}

From source file:org.opensaml.saml.saml1.profile.impl.AddSubjectConfirmationToSubjects.java

/**
 * Set the confirmation methods to use./*from www .j  a  v a 2 s. c o m*/
 * 
 * @param methods   confirmation methods to use
 */
public void setMethods(@Nonnull @NonnullElements final Collection<String> methods) {
    ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
    Constraint.isNotEmpty(methods, "Confirmation method collection cannot be null or empty");

    confirmationMethods = new ArrayList<>(Collections2.filter(methods, Predicates.notNull()));
}

From source file:net.shibboleth.idp.saml.saml1.profile.config.BrowserSSOProfileConfiguration.java

/**
 * Set the default authentication methods to use, expressed as custom principals.
 * //from w  w  w. j a v  a  2 s .c o  m
 * @param methods   default authentication methods to use
 */
public void setDefaultAuthenticationMethods(
        @Nonnull @NonnullElements final List<AuthenticationMethodPrincipal> methods) {
    Constraint.isNotNull(methods, "List of methods cannot be null");

    defaultAuthenticationMethods = new ArrayList<>(Collections2.filter(methods, Predicates.notNull()));
}

From source file:org.geogit.geotools.plumbing.ExportDiffOp.java

private static Iterator<SimpleFeature> getFeatures(Iterator<DiffEntry> diffs, final boolean old,
        final ObjectDatabase database, final ObjectId metadataId, final ProgressListener progressListener) {

    final SimpleFeatureType featureType = addFidAttribute(database.getFeatureType(metadataId));
    final RevFeatureType revFeatureType = RevFeatureType.build(featureType);
    final SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(featureType);

    Function<DiffEntry, SimpleFeature> asFeature = new Function<DiffEntry, SimpleFeature>() {

        @Override/*  w ww .ja v a2 s  .c  o m*/
        @Nullable
        public SimpleFeature apply(final DiffEntry input) {
            NodeRef nodeRef = old ? input.getOldObject() : input.getNewObject();
            if (nodeRef == null) {
                return null;
            }
            final RevFeature revFeature = database.getFeature(nodeRef.objectId());
            ImmutableList<Optional<Object>> values = revFeature.getValues();
            for (int i = 0; i < values.size(); i++) {
                String name = featureType.getDescriptor(i + 1).getLocalName();
                Object value = values.get(i).orNull();
                featureBuilder.set(name, value);
            }
            featureBuilder.set("geogit_fid", nodeRef.name());
            Feature feature = featureBuilder.buildFeature(nodeRef.name());
            feature.getUserData().put(Hints.USE_PROVIDED_FID, true);
            feature.getUserData().put(RevFeature.class, revFeature);
            feature.getUserData().put(RevFeatureType.class, revFeatureType);

            if (feature instanceof SimpleFeature) {
                return (SimpleFeature) feature;
            }
            return null;
        }

    };

    Iterator<SimpleFeature> asFeatures = Iterators.transform(diffs, asFeature);

    UnmodifiableIterator<SimpleFeature> filterNulls = Iterators.filter(asFeatures, Predicates.notNull());

    return filterNulls;
}

From source file:net.shibboleth.idp.attribute.IdPAttribute.java

/**
 * Replaces the existing values for this attribute with the given values.
 * /*from  www.  jav a  2 s .co  m*/
 * @param newValues the new values for this attribute
 */
public void setValues(@Nullable @NullableElements final Collection<? extends IdPAttributeValue<?>> newValues) {
    final ImmutableList.Builder<IdPAttributeValue<?>> builder = ImmutableList.builder();
    if (newValues != null) {
        builder.addAll(Collections2.filter(newValues, Predicates.notNull()));
    }
    values = builder.build();
}

From source file:com.palantir.atlasdb.keyvalue.api.RangeRequest.java

@Override
public String toString() {
    ToStringHelper helper = MoreObjects.toStringHelper(getClass()).omitNullValues();
    PtBytes.addIfNotEmpty(helper, "startInclusive", startInclusive);
    PtBytes.addIfNotEmpty(helper, "endExclusive", endExclusive);
    if (columns != null && !columns.isEmpty()) {
        helper.add("columns", FluentIterable.from(columns).filter(Predicates.notNull())
                .transform(PtBytes.BYTES_TO_HEX_STRING));
    }//w  w  w .j  av a2s. com
    helper.add("batchHint", batchHint);
    helper.add("reverse", reverse);
    return helper.toString();
}

From source file:org.opentestsystem.authoring.testauth.publish.PublisherUtil.java

protected static Identifier buildIdentifierPrim(final String name, final String label, final String version) {
    String xmlLabel = StringEscapeUtils.escapeXml(label);
    final List<String> fields = Lists
            .newArrayList(Iterables.filter(Lists.newArrayList(StringUtils.trimToNull(name),
                    StringUtils.trimToNull(xmlLabel), StringUtils.trimToNull(version)), Predicates.notNull()));

    if (StringUtils.countMatches(name, "-") == 2) {
        String id = StringUtils.substringAfter(name, "-");
        return new Identifier(id, name, xmlLabel, version);
    }/*from  w  w w . j  a  v a 2s  .  c om*/
    return new Identifier(StringUtils.join(fields.toArray(), "-"), name, xmlLabel, version);
}

From source file:org.androidtransfuse.adapter.element.ASTElementFactory.java

private <T extends ASTBase> List<T> transformAST(List<? extends Element> enclosedElements, Class<T> astType) {
    return FluentIterable.from(enclosedElements)
            .transform(astElementConverterFactory.buildASTElementConverter(astType))
            .filter(Predicates.notNull()).toList();
}

From source file:eu.itesla_project.graph.UndirectedGraphImpl.java

@Override
public Iterable<E> getEdgesObject() {
    return FluentIterable.from(edges).filter(Predicates.notNull()).transform(Edge::getObject);
}

From source file:de.metas.ui.web.handlingunits.report.HUReportProcessInstance.java

private List<HUToReport> extractHUsToReport(final HUEditorView view) {
    final Set<HUToReport> husToCheck = view.streamByIds(viewRowIdsSelection.getRowIds())
            .map(HUEditorRow::getAsHUToReportOrNull).filter(Predicates.notNull())
            .collect(ImmutableSet.toImmutableSet());

    return HUReportService.get().getHUsToProcess(husToCheck);
}