List of usage examples for com.google.common.base Predicates notNull
@GwtCompatible(serializable = true) public static <T> Predicate<T> notNull()
From source file:org.netbeans.modules.android.project.AndroidInfoImpl.java
@Override public Iterable<FileObject> getDependentProjectDirs() { return Iterables .filter(Iterables.transform(getDependentProjectDirPaths(), new Function<String, FileObject>() { @Override/* w w w.java2 s . co m*/ public FileObject apply(String input) { return FileUtil.toFileObject( FileUtil.normalizeFile(new File(project.getProjectDirectoryFile(), input))); } }), Predicates.notNull()); }
From source file:net.shibboleth.idp.cas.config.impl.LoginConfiguration.java
/** * Set the authentication flows to use.//from www.j a v a 2s . c om * * @param flows flow identifiers to use */ public void setAuthenticationFlows(@Nonnull @NonnullElements final Collection<String> flows) { Constraint.isNotNull(flows, "Collection of flows cannot be null"); authenticationFlows = new HashSet<>(Collections2.filter(flows, Predicates.notNull())); }
From source file:io.crate.operation.collect.UnassignedShardsCollectService.java
private Iterable<UnassignedShard> createIterator() { List<ShardRouting> allShards = clusterService.state().routingTable().allShards(); if (allShards == null || allShards.size() == 0) { return NO_SHARDS; }//from ww w . j a v a 2 s .com final UnassignedShardIteratorContext context = new UnassignedShardIteratorContext(); return FluentIterable.from(allShards).transform(new Function<ShardRouting, UnassignedShard>() { @Nullable @Override public UnassignedShard apply(@Nullable ShardRouting input) { assert input != null; if (!input.active()) { return new UnassignedShard(input.shardId(), clusterService, context.isPrimary(input.shardId()), input.state()); } return null; } }).filter(Predicates.notNull()); }
From source file:org.jclouds.aws.ec2.compute.suppliers.RegionAndNameToImageSupplier.java
@Override public Map<RegionAndName, ? extends Image> get() { if (amiOwners.length == 0) { logger.debug(">> no owners specified, skipping image parsing"); } else {/*from w w w.jav a2 s . co m*/ logger.debug(">> providing images"); Iterable<Entry<String, DescribeImagesOptions>> queries = concat( getDescribeQueriesForOwnersInRegions(regionMap, amiOwners).entrySet(), ccAmisToDescribeQueries(ccAmis).entrySet()); Iterable<? extends Image> parsedImages = filter(transform(describer.apply(queries), parser), Predicates.notNull()); images.putAll(uniqueIndex(parsedImages, new Function<Image, RegionAndName>() { @Override public RegionAndName apply(Image from) { return new RegionAndName(from.getLocation().getId(), from.getProviderId()); } })); logger.debug("<< images(%d)", images.size()); } return images; }
From source file:org.opensaml.xmlsec.impl.BasicEncryptionConfiguration.java
/** * Set the data encryption credentials to use. * //from ww w. jav a 2 s . co m * @param credentials the list of data encryption credentials */ public void setDataEncryptionCredentials(@Nullable final List<Credential> credentials) { if (credentials == null) { dataEncryptionCredentials = Collections.emptyList(); return; } dataEncryptionCredentials = new ArrayList<>(Collections2.filter(credentials, Predicates.notNull())); }
From source file:org.jclouds.vcloud.director.v1_5.compute.strategy.VcloudDirectorAdaptingComputeServiceStrategies.java
@Override public Iterable<? extends NodeMetadata> listDetailsOnNodesMatching(Predicate<ComputeMetadata> filter) { return FluentIterable.from(client.listNodes()).transform(nodeMetadataAdapter).filter(Predicates.notNull()) .filter(filter);//from ww w .j ava 2 s . co m }
From source file:org.kiji.schema.impl.cassandra.RowDecoders.java
/** * Create a new column family result set decoder function. * * @param tableName The Cassandra table that the results are from. * @param column The Kiji column name of the family. * @param columnRequest The column request defining the request for the family. * @param dataRequest The data request defining the request. * @param layout The layout of the Kiji table. * @param translator A column name translator for the table. * @param decoderProvider A cell decoder provider for the table. * @param <T> Type of cell values. * @return A function to convert a {@link ResultSet} containing a column family to cells. *//*from ww w . ja v a 2 s .c om*/ public static <T> Function<ResultSet, Iterator<KijiCell<T>>> getColumnFamilyDecoderFunction( final CassandraTableName tableName, final KijiColumnName column, final Column columnRequest, final KijiDataRequest dataRequest, final KijiTableLayout layout, final CassandraColumnNameTranslator translator, final CellDecoderProvider decoderProvider) { return new Function<ResultSet, Iterator<KijiCell<T>>>() { /** {@inheritDoc} */ @Override public Iterator<KijiCell<T>> apply(final ResultSet resultSet) { final int mMaxVersions = columnRequest.getMaxVersions(); final long mMinTimestamp = dataRequest.getMinTimestamp(); final long mMaxTimestamp = dataRequest.getMaxTimestamp(); Iterator<Row> rows = resultSet.iterator(); if (mMinTimestamp != 0) { rows = Iterators.filter(rows, new MinTimestampPredicate(mMinTimestamp)); } if (mMaxTimestamp != KConstants.END_OF_TIME) { rows = Iterators.filter(rows, new MaxTimestampPredicate(mMaxTimestamp)); } rows = Iterators.filter(rows, new MaxVersionsPredicate(mMaxVersions)); try { if (layout.getFamilyMap().get(column.getFamily()).isMapType()) { // Map-type family final Function<Row, KijiCell<T>> decoder = new MapFamilyDecoder<>(tableName, translator.toCassandraColumnName(column), translator, decoderProvider.<T>getDecoder(column)); return Iterators.transform(rows, decoder); } else { // Group-type family final Function<Row, KijiCell<T>> decoder = new GroupFamilyDecoder<>(tableName, translator.toCassandraColumnName(column), translator, decoderProvider); // Group family decoder may return nulls, so filter them out return Iterators.filter(Iterators.transform(rows, decoder), Predicates.notNull()); } } catch (NoSuchColumnException e) { throw new IllegalStateException( String.format("Column %s does not exist in Kiji table %s.", column, layout.getName())); } } }; }
From source file:org.opensaml.security.x509.tls.CertificateNameOptions.java
/** * Set the set of types of subject alternative names evaluate as derived issuer entity ID names, * using integer constants defined in {@link org.opensaml.security.X509Support}. * //from w w w. ja v a2s. com * @param names the set of types of subject alternative names */ public void setSubjectAltNames(@Nullable final Set<Integer> names) { if (names == null) { subjectAltNames = Collections.emptySet(); return; } subjectAltNames = new HashSet<>(Collections2.filter(names, Predicates.notNull())); }
From source file:org.apache.beam.runners.dataflow.worker.StreamingStepMetricsContainer.java
private FluentIterable<CounterUpdate> distributionUpdates() { return FluentIterable.from(distributions.entries()) .transform(new Function<Entry<MetricName, DeltaDistributionCell>, CounterUpdate>() { @Override/* ww w. j a v a2s .c om*/ @Nullable public CounterUpdate apply(Map.Entry<MetricName, DeltaDistributionCell> entry) { DistributionData value = entry.getValue().getAndReset(); if (value.count() == 0) { return null; } return MetricsToCounterUpdateConverter .fromDistribution(MetricKey.create(stepName, entry.getKey()), false, value); } }).filter(Predicates.notNull()); }
From source file:org.trancecode.collection.TcIterables.java
/** * Returns the first non-null element from the specified sequence, or the * specified default value if all elements from the sequence were * {@code null}.//w ww . j a v a 2 s. c o m */ public static <T> T getFirstNonNull(final Iterable<T> elements, final T defaultValue) { return Iterables.getFirst(Iterables.filter(elements, Predicates.notNull()), defaultValue); }