List of usage examples for com.google.common.base Predicates notNull
@GwtCompatible(serializable = true) public static <T> Predicate<T> notNull()
From source file:net.shibboleth.idp.saml.impl.nameid.AttributeSourcedSAML2NameIDGenerator.java
/** * Set the attribute sources to pull from. * // w w w . java 2 s. co m * @param ids attribute IDs to pull from */ public synchronized void setAttributeSourceIds(@Nonnull @NonnullElements final List<String> ids) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); Constraint.isNotNull(ids, "Attribute ID collection cannot be null"); attributeSourceIds = Lists.newArrayList(Collections2.filter(ids, Predicates.notNull())); }
From source file:org.locationtech.geogig.geotools.plumbing.ExportDiffOp.java
/** * Executes the export operation using the parameters that have been specified. * // w w w. j a v a 2 s.c o m * @return a FeatureCollection with the specified features */ @Override protected SimpleFeatureStore _call() { final SimpleFeatureStore targetStore = getTargetStore(); final String refspec = old ? oldRef : newRef; final RevTree rootTree = resolveRootTree(refspec); final NodeRef typeTreeRef = resolTypeTreeRef(refspec, path, rootTree); final ObjectId defaultMetadataId = typeTreeRef.getMetadataId(); final ProgressListener progressListener = getProgressListener(); progressListener.started(); progressListener.setDescription("Exporting diffs for path '" + path + "'... "); FeatureCollection<SimpleFeatureType, SimpleFeature> asFeatureCollection = new BaseFeatureCollection<SimpleFeatureType, SimpleFeature>() { @Override public FeatureIterator<SimpleFeature> features() { Iterator<DiffEntry> diffs = command(DiffOp.class).setOldVersion(oldRef).setNewVersion(newRef) .setFilter(path).call(); final Iterator<SimpleFeature> plainFeatures = getFeatures(diffs, old, objectDatabase(), defaultMetadataId, progressListener); Iterator<Optional<Feature>> transformed = Iterators.transform(plainFeatures, ExportDiffOp.this.function); Iterator<SimpleFeature> filtered = Iterators .filter(Iterators.transform(transformed, new Function<Optional<Feature>, SimpleFeature>() { @Override public SimpleFeature apply(Optional<Feature> input) { return (SimpleFeature) (input.isPresent() ? input.get() : null); } }), Predicates.notNull()); return new DelegateFeatureIterator<SimpleFeature>(filtered); } }; // add the feature collection to the feature store final Transaction transaction; if (transactional) { transaction = new DefaultTransaction("create"); } else { transaction = Transaction.AUTO_COMMIT; } try { targetStore.setTransaction(transaction); try { targetStore.addFeatures(asFeatureCollection); transaction.commit(); } catch (final Exception e) { if (transactional) { transaction.rollback(); } Throwables.propagateIfInstanceOf(e, GeoToolsOpException.class); throw new GeoToolsOpException(e, StatusCode.UNABLE_TO_ADD); } finally { transaction.close(); } } catch (IOException e) { throw new GeoToolsOpException(e, StatusCode.UNABLE_TO_ADD); } progressListener.complete(); return targetStore; }
From source file:org.robotframework.ide.eclipse.main.plugin.tableeditor.settings.SettingsEditorPageSelectionProvider.java
@SuppressWarnings("rawtypes") private ISelection translateEntriesToSettings(final ISelection selection) { if (selection instanceof IStructuredSelection) { final IStructuredSelection structuredSelection = (IStructuredSelection) selection; final int size = structuredSelection.size(); final List<Entry> entries = Selections.getElements(structuredSelection, Entry.class); if (!entries.isEmpty() && entries.size() == size) { return new StructuredSelection(newArrayList( Iterables.filter(Iterables.transform(entries, new Function<Entry, RobotElement>() { @Override public RobotElement apply(final Entry entry) { return (RobotElement) entry.getValue(); }/*from ww w. j ava 2s. c o m*/ }), Predicates.notNull()))); } return selection; } return selection; }
From source file:net.shibboleth.idp.attribute.resolver.spring.dc.impl.DataConnectorFactoryBean.java
/** * Set the list of bean factory post processors for this connector. * /*from ww w .j a va 2 s. c o m*/ * @param processors bean factory post processors to apply */ public void setBeanFactoryPostProcessors( @Nonnull @NonnullElements final List<BeanFactoryPostProcessor> processors) { factoryPostProcessors = Lists.newArrayList(Collections2.filter(processors, Predicates.notNull())); }
From source file:org.eclipse.sirius.editor.tools.internal.presentation.ViewpoitnDependenciesSelectionDialog.java
@SuppressWarnings("unchecked") private List<URI> getSelectedSiriusURIs(Viewpoint vp, EStructuralFeature feature) { return Lists.newArrayList(Iterables.filter((List<URI>) vp.eGet(feature), Predicates.notNull())); }
From source file:com.spectralogic.ds3cli.command.GetDetailedObjects.java
private Predicate<DetailedS3Object> getDatePredicate() throws ParseException { if (Guard.isMapNullOrEmpty(this.filterParams)) { return Predicates.notNull(); }/*from w ww . j a v a 2 s. c o m*/ // newerthan and olderthan are relative final String newer = this.filterParams.get(NEWERTHAN); final String older = this.filterParams.get(OLDERTHAN); // before and after are actual dates final String after = this.filterParams.get(AFTER); final String before = this.filterParams.get(BEFORE); // if any of these are set, create a range for the predicate if (!Guard.isStringNullOrEmpty(newer) && !Guard.isStringNullOrEmpty(older) && !Guard.isStringNullOrEmpty(after) && !Guard.isStringNullOrEmpty(before)) { return Predicates.notNull(); } Date newerThan = new Date(0L); Date olderThan = new Date(Long.MAX_VALUE); if (!Guard.isStringNullOrEmpty(newer)) { newerThan = new Date(new Date().getTime() - DateUtils.dateDiffToSeconds(newer) * MILLIS_PER_SECOND); } if (!Guard.isStringNullOrEmpty(older)) { olderThan = new Date(new Date().getTime() - DateUtils.dateDiffToSeconds(older) * MILLIS_PER_SECOND); } if (!Guard.isStringNullOrEmpty(after)) { newerThan = DateUtils.parseParamDate(after); } if (!Guard.isStringNullOrEmpty(before)) { olderThan = DateUtils.parseParamDate(before); } // set final to pass iknto predicate final Date newerThanDate = newerThan; final Date olderThanDate = olderThan; return new Predicate<DetailedS3Object>() { @Override public boolean apply(@Nullable final DetailedS3Object input) { return input.getCreationDate().after(newerThanDate) && input.getCreationDate().before(olderThanDate); } }; }
From source file:de.metas.ui.web.window.model.lookup.LookupDataSourceFactory.java
public void cacheInvalidateOnRecordsChanged(final Set<String> tableNames) { tableNames.stream().map(cacheInvalidationGroupsByTableName::get).filter(Predicates.notNull()) .forEach(CacheInvalidationGroup::cacheInvalidate); }
From source file:org.apache.beam.runners.spark.metrics.WithMetricsSupport.java
private Function<Map.Entry<String, Metric>, Map<String, Gauge>> aggregatorMetricToGauges() { return new Function<Map.Entry<String, Metric>, Map<String, Gauge>>() { @Override//from w ww. ja v a 2 s . co 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:net.shibboleth.idp.oidc.config.login.LoginConfiguration.java
/** * Sets name iD format precedence.//from w ww . ja v a 2 s .c o m * * @param formats the formats */ public void setNameIDFormatPrecedence(@Nonnull @NonnullElements final List<String> formats) { Constraint.isNotNull(formats, "List of formats cannot be null"); this.nameIDFormatPrecedence = new ArrayList(Collections2.filter(formats, Predicates.notNull())); }
From source file:org.sonar.server.computation.task.projectanalysis.api.measurecomputer.MeasureComputerContextImpl.java
@Override public Iterable<Measure> getChildrenMeasures(String metric) { validateInputMetric(metric);/*from ww w.j a va2 s. c om*/ return FluentIterable.from(internalComponent.getChildren()) .transform(new ComponentToMeasure(metricRepository.getByKey(metric))) .transform(ToMeasureAPI.INSTANCE).filter(Predicates.notNull()); }