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.relyingparty.MockAuthenticationProfileConfiguration.java
/** * Set the default authentication methods to use, expressed as custom principals. * /*from w w w . j av a 2 s . co m*/ * @param methods default authentication methods to use */ public void setDefaultAuthenticationMethods(@Nonnull @NonnullElements final List<Principal> methods) { Constraint.isNotNull(methods, "List of methods cannot be null"); defaultAuthenticationMethods = Lists.newArrayList(Collections2.filter(methods, Predicates.notNull())); }
From source file:net.shibboleth.idp.authn.impl.ExtractRemoteUser.java
/** * Set the list of request attributes to check for an identity. * //from ww w . j av a 2s . c o m * @param attributes list of request attributes to check */ public void setCheckAttributes(@Nonnull @NonnullElements final Collection<String> attributes) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); checkAttributes = Lists.newArrayList(Collections2.filter(attributes, Predicates.notNull())); }
From source file:org.apache.beam.runners.dataflow.worker.StreamingStepMetricsContainer.java
private FluentIterable<CounterUpdate> counterUpdates() { return FluentIterable.from(counters.entries()) .transform(new Function<Entry<MetricName, DeltaCounterCell>, CounterUpdate>() { @Override/*from w ww.j av a 2 s . c o m*/ @Nullable public CounterUpdate apply(Map.Entry<MetricName, DeltaCounterCell> entry) { long value = entry.getValue().getSumAndReset(); if (value == 0) { return null; } return MetricsToCounterUpdateConverter .fromCounter(MetricKey.create(stepName, entry.getKey()), false, value); } }).filter(Predicates.notNull()); }
From source file:com.flowlogix.security.cdi.ShiroSessionScopeContext.java
public <T> void onDestroy(Session session) { List<String> attrNames = FluentIterable.from(session.getAttributeKeys()) .transform(new Function<Object, String>() { @Override/*w ww . ja va2 s . c o m*/ public String apply(Object f) { return f instanceof String ? (String) f : null; } }).filter(Predicates.and(Predicates.notNull(), Predicates.contains(bpPattern))).toList(); for (String attrName : attrNames) { @SuppressWarnings("unchecked") ScopeInst<T> scopeInst = (ScopeInst<T>) session.getAttribute(attrName); if (scopeInst != null) { scopeInst.bean.destroy(scopeInst.instance, scopeInst.context); } } }
From source file:org.eclipse.incquery.validation.runtime.ConstraintExtensionRegistry.java
private static Iterable<IConstraintSpecification> unwrapConstraintSpecifications( Collection<IProvider<IConstraintSpecification>> providers) { Iterable<IProvider<IConstraintSpecification>> notNullProviders = Iterables.filter(providers, Predicates.notNull()); Iterable<IConstraintSpecification> constraintSpecifications = Iterables.transform(notNullProviders, new Function<IProvider<IConstraintSpecification>, IConstraintSpecification>() { @Override// w w w.ja v a 2s . com public IConstraintSpecification apply(IProvider<IConstraintSpecification> provider) { return provider.get(); } }); return constraintSpecifications; }
From source file:org.opensaml.saml.metadata.resolver.ChainingMetadataResolver.java
/** * Set the registered metadata resolvers. * /*from w w w .j a va 2s . c o m*/ * @param newResolvers the metadata resolvers to use * * @throws ResolverException thrown if there is a problem adding the metadata resolvers */ public void setResolvers(@Nonnull @NonnullElements final List<? extends 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())); }
From source file:org.eclipse.emf.eson.util.EPackageResolver.java
/** * All known EPackages.//from w w w . j a v a 2 s. co m * @return Iterable of EPackage, WITHOUT ANY null ENTRIES! */ public Iterable<EPackage> getAllRegisteredEPackages() { // copy due to potential CME while resolving EPackages List<String> packageUris = Lists.newArrayList(EPackage.Registry.INSTANCE.keySet()); Iterable<String> packageUrisWithoutAnyNulls = Iterables.filter(packageUris, Predicates.notNull()); Iterable<EPackage> packagesMaybeWithNull = Iterables.transform(packageUrisWithoutAnyNulls, new Function<String, EPackage>() { // @since Luna (Eclipse 4.4), @NonNull here leads to: // "Illegal redefinition of parameter uri, inherited method from Function<String,EPackage> does not constrain this parameter" // so we have to make this handstand here instead: public EPackage apply(@Nullable String uri) { if (uri == null) throw new IllegalArgumentException(); return getPackageFromRegistry(uri); } }); Iterable<EPackage> packagesWithoutAnyNulls = Iterables.filter(packagesMaybeWithNull, Predicates.notNull()); return packagesWithoutAnyNulls; }
From source file:io.crate.metadata.doc.DocSchemaInfo.java
private static Predicate<String> createSchemaNamePredicate(final String schemaName) { return Predicates.and(Predicates.notNull(), new Predicate<String>() { @Override//from w w w . j a v a 2 s . c o m public boolean apply(String input) { Matcher matcher = Schemas.SCHEMA_PATTERN.matcher(input); if (matcher.matches()) { return matcher.group(1).equals(schemaName); } else { return Schemas.DEFAULT_SCHEMA_NAME.equals(schemaName); } } }); }
From source file:org.pentaho.di.trans.dataservice.ui.DataServiceDialog.java
protected DataServiceDialog initOptimizations(List<PushDownFactory> pushDownFactories) throws KettleException { ImmutableList<OptimizationOverlay> overlays = FluentIterable.from(pushDownFactories) .transform(new Function<PushDownFactory, OptimizationOverlay>() { @Override//from www. j a va2 s. c o m public OptimizationOverlay apply(PushDownFactory input) { return input.createOverlay(); } }).filter(Predicates.notNull()) .toSortedList(Ordering.natural().onResultOf(new Function<OptimizationOverlay, Comparable>() { @Override public Comparable apply(OptimizationOverlay input) { return input.getPriority(); } })); for (OptimizationOverlay overlay : overlays) { overlay.apply(this); } XulTabbox optimizationTabs = controller.getElementById("optimizationTabs"); if (optimizationTabs.getTabs().getTabCount() > 0) { optimizationTabs.setSelectedIndex(0); } return this; }
From source file:net.shibboleth.idp.cas.config.impl.LoginConfiguration.java
/** * Set the default authentication contexts to use, expressed as custom principals. * * @param contexts default authentication contexts to use *//*from ww w . java2 s.com*/ public void setDefaultAuthenticationMethods( @Nonnull @NonnullElements final List<AuthnContextClassRefPrincipal> contexts) { Constraint.isNotNull(contexts, "List of contexts cannot be null"); defaultAuthenticationContexts = new ArrayList<>(Collections2.filter(contexts, Predicates.notNull())); }