List of usage examples for com.google.common.base Predicates notNull
@GwtCompatible(serializable = true) public static <T> Predicate<T> notNull()
From source file:gobblin.data.management.version.finder.AbstractHiveDatasetVersionFinder.java
/** * Create {@link HiveDatasetVersion}s for all {@link Partition}s of a {@link HiveDataset}. * Calls {@link #getDatasetVersion(Partition)} for every {@link Partition} found. * <p>//from w ww . j ava 2 s . c om * Note: If an exception occurs while processing a partition, that partition will be ignored in the returned collection * </p> * * @throws IllegalArgumentException if <code>dataset</code> is not a {@link HiveDataset}. Or if {@link HiveDataset#getTable()} * is not partitioned. */ @Override public Collection<HiveDatasetVersion> findDatasetVersions(Dataset dataset) throws IOException { if (!(dataset instanceof HiveDataset)) { throw new IllegalArgumentException("HiveDatasetVersionFinder is only compatible with HiveDataset"); } final HiveDataset hiveDataset = (HiveDataset) dataset; if (!HiveUtils.isPartitioned(hiveDataset.getTable())) { throw new IllegalArgumentException( "HiveDatasetVersionFinder is only compatible with partitioned hive tables"); } try (AutoReturnableObject<IMetaStoreClient> client = hiveDataset.getClientPool().getClient()) { List<Partition> partitions = HiveUtils.getPartitions(client.get(), hiveDataset.getTable(), Optional.<String>absent()); return Lists.newArrayList( Iterables.filter(Iterables.transform(partitions, new Function<Partition, HiveDatasetVersion>() { @Override public HiveDatasetVersion apply(Partition partition) { try { return getDatasetVersion(partition); } catch (Throwable e) { log.warn(String.format("Failed to get DatasetVersion %s. Skipping.", partition.getCompleteName()), e); return null; } } }), Predicates.notNull())); } }
From source file:de.metas.ui.web.pickingV2.packageable.PackageableRowsRepository.java
List<PackageableRow> retrieveRows(final List<DocumentFilter> filters) { final PackageableQuery query = createPackageableQuery(filters); return packageablesRepo.stream(query) .collect(GuavaCollectors.toImmutableListMultimap(packageable -> extractGroupingKey(packageable))) .asMap().values().stream().map(this::createPackageableRowNoFail).filter(Predicates.notNull()) .collect(ImmutableList.toImmutableList()); }
From source file:net.shibboleth.idp.attribute.filter.context.AttributeFilterContext.java
/** * Sets the attributes which are to be filtered. * //from www. j av a 2s .c o m * @param attributes attributes which are to be filtered */ public void setPrefilteredIdPAttributes(@Nullable @NullableElements final Collection<IdPAttribute> attributes) { Collection<IdPAttribute> checkedAttributes = new ArrayList<>(); CollectionSupport.addIf(checkedAttributes, attributes, Predicates.notNull()); prefilteredAttributes = MapConstraints.constrainedMap( new HashMap<String, IdPAttribute>(checkedAttributes.size()), MapConstraints.notNull()); for (final IdPAttribute attribute : checkedAttributes) { prefilteredAttributes.put(attribute.getId(), attribute); } }
From source file:net.shibboleth.idp.authn.impl.ValidateRemoteUser.java
/** * Set the whitelisted usernames.//from w w w . j a v a2 s. com * * @param whitelist whitelist to set */ public void setWhitelistedUsernames(@Nonnull @NonnullElements final Collection<String> whitelist) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); whitelistedUsernames = Sets.newHashSet(Collections2.filter(whitelist, Predicates.notNull())); }
From source file:com.google.devtools.build.skyframe.InMemoryGraphImpl.java
@Override public Map<SkyKey, SkyValue> getDoneValues() { return Collections.unmodifiableMap( Maps.filterValues(Maps.transformValues(nodeMap, new Function<InMemoryNodeEntry, SkyValue>() { @Override/*from w w w. j a v a 2 s . co m*/ public SkyValue apply(InMemoryNodeEntry entry) { return entry.isDone() ? entry.getValue() : null; } }), Predicates.notNull())); }
From source file:net.shibboleth.idp.attribute.filter.AttributeFilterPolicy.java
/** * Constructor.//from w ww .j av a 2s .co m * * @param policyId unique ID of this policy * @param requirementRule criterion used to determine if this policy is active for a given request * @param attributeRules value filtering policies employed if this policy is active */ public AttributeFilterPolicy(@Nonnull @NotEmpty String policyId, @Nonnull PolicyRequirementRule requirementRule, @Nullable @NullableElements Collection<AttributeRule> attributeRules) { setId(policyId); rule = Constraint.isNotNull(requirementRule, "Attribute filter policy activiation criterion can not be null"); ArrayList<AttributeRule> checkedPolicies = new ArrayList<>(); CollectionSupport.addIf(checkedPolicies, attributeRules, Predicates.notNull()); if (null != attributeRules) { valuePolicies = ImmutableList.copyOf(Iterables.filter(attributeRules, Predicates.notNull())); } else { valuePolicies = Collections.EMPTY_LIST; } }
From source file:com.qcadoo.mes.materialFlow.hooks.TransformationsModelValidators.java
private boolean areTransfersValid(final List<Entity> transfers) { final Iterable<Long> usedProductIds = Iterables.transform(transfers, EXTRACT_TRANSFER_PRODUCT_ID); return FluentIterable.from(transfers).filter(Predicates.notNull()).allMatch(new Predicate<Entity>() { @Override/*from w w w .j a v a 2 s .c o m*/ public boolean apply(final Entity transfer) { return transferIsValid(usedProductIds, transfer); } }); }
From source file:io.crate.metadata.PartitionInfos.java
@Override public Iterator<PartitionInfo> iterator() { // get a fresh one for each iteration return FluentIterable.from(clusterService.state().metaData().indices()).filter(PARTITION_INDICES_PREDICATE) .transform(CREATE_PARTITION_INFO_FUNCTION).filter(Predicates.notNull()).iterator(); }
From source file:com.google.devtools.build.skyframe.InMemoryGraph.java
/** * Returns a read-only live view of the done values in the graph. Dirty, changed, and error values * are not present in the returned map//from w w w. j a v a 2 s . com */ Map<SkyKey, SkyValue> getDoneValues() { return Collections.unmodifiableMap( Maps.filterValues(Maps.transformValues(nodeMap, new Function<NodeEntry, SkyValue>() { @Override public SkyValue apply(NodeEntry entry) { return entry.isDone() ? entry.getValue() : null; } }), Predicates.notNull())); }
From source file:org.opensaml.saml.metadata.resolver.impl.CompositeMetadataResolver.java
/** * Sets the current set of metadata resolvers. * /*from w w w. j a v a 2s . c om*/ * @param newResolvers the metadata resolvers to use * * @throws ResolverException thrown if there is a problem adding the metadata provider */ public void setResolvers(@Nonnull @NonnullElements List<MetadataResolver> newResolvers) throws ResolverException { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); ComponentSupport.ifDestroyedThrowDestroyedComponentException(this); if (newResolvers == null || newResolvers.isEmpty()) { resolvers = Collections.emptyList(); return; } resolvers = new ArrayList<>(Collections2.filter(newResolvers, Predicates.notNull())); }