List of usage examples for com.google.common.base Predicates notNull
@GwtCompatible(serializable = true) public static <T> Predicate<T> notNull()
From source file:org.jpmml.evaluator.functions.AggregateFunction.java
@Override public FieldValue evaluate(List<FieldValue> arguments) { StorelessUnivariateStatistic statistic = createStatistic(); DataType dataType = null;//from w w w . j a va 2s . c o m // "Missing values in the input to an aggregate function are simply ignored" Iterable<FieldValue> values = Iterables.filter(arguments, Predicates.notNull()); for (FieldValue value : values) { statistic.increment((value.asNumber()).doubleValue()); if (dataType != null) { dataType = TypeUtil.getResultDataType(dataType, value.getDataType()); } else { dataType = value.getDataType(); } } if (statistic.getN() == 0) { throw new InvalidResultException(null); } Object result = cast(getResultType(dataType), statistic.getResult()); return FieldValueUtil.create(result); }
From source file:org.eclipse.xtext.util.formallang.ProductionStringFactory.java
@Override public String createForSequentialChildren(boolean many, boolean optional, Iterable<String> children) { children = Iterables.filter(children, Predicates.notNull()); if (many || optional) return "(" + Joiner.on(" ").join(children) + ")" + card(many, optional); return Joiner.on(" ").join(children) + card(many, optional); }
From source file:com.palantir.common.collect.IterableUtils.java
public static <T> List<List<T>> partitionByHash(List<T> items, int buckets, Function<? super T, Long> f) { Preconditions.checkArgument(Iterables.all(items, Predicates.notNull())); Preconditions.checkArgument(buckets > 0); Preconditions.checkNotNull(f);/*from w ww . ja v a 2 s . co m*/ ArrayList<List<T>> ret = Lists.newArrayList(); for (int i = 0; i < buckets; i++) { ret.add(Lists.<T>newArrayList()); } for (T item : items) { long hash = f.apply(item); int h = (int) (hash ^ (hash >>> 32)); int i = MathUtils.mod(h, buckets); ret.get(i).add(item); } assert assertCorrectlyPartitioned(items, ret); return ret; }
From source file:com.tinspx.util.collect.NotNull.java
/** * Wraps {@code list} as a {@code List} that doe not allow {@code null} * elements to be added.// w w w .ja v a 2 s.c o m * * @throws NullPointerException if any existing element in {@code list} is * {@code null} */ public static <E> List<E> list(List<E> list) { CollectUtils.checkAllNotNull(list); return Predicated.list(list, Predicates.notNull()); }
From source file:org.sonar.server.computation.measure.MeasureComputersHolderImpl.java
@Override public void setMeasureComputers(Iterable<MeasureComputerWrapper> measureComputers) { requireNonNull(measureComputers, "Measure computers cannot be null"); checkState(this.measureComputers == null, "Measure computers have already been initialized"); this.measureComputers = from(measureComputers).filter(Predicates.notNull()).toList(); }
From source file:org.eclipse.sirius.business.internal.movida.registry.DefaultViewpointResourceHandler.java
/** * {@inheritDoc}//from www . j a v a 2 s .com */ public Set<Viewpoint> collectViewpointDefinitions(Resource res) { Set<Viewpoint> viewpoints = Sets.newHashSet(); for (Group group : Iterables.filter(res.getContents(), Group.class)) { for (Viewpoint viewpoint : group.getOwnedViewpoints()) { viewpoints.add(viewpoint); } } return ImmutableSet.copyOf(Iterables.filter(viewpoints, Predicates.notNull())); }
From source file:net.conquiris.lucene.search.ExplicitComparator.java
/** * Constructor.//from ww w . ja va2 s. co m * @param values Values in sort order. Duplicates and {@code nulls} are filtered out. */ private ExplicitComparator(Iterable<? extends T> values) { checkNotNull(values); ImmutableMap.Builder<T, Integer> builder = ImmutableMap.builder(); Set<T> visited = Sets.newHashSet(); int rank = 0; for (T value : Iterables.filter(values, Predicates.notNull())) { if (visited.add(value)) { builder.put(value, rank); rank++; } } this.rankMap = builder.build(); this.otherRank = rank + 1; }
From source file:org.eclipse.emf.compare.ide.internal.hook.ResourceSetHookRegistry.java
/** * Gets the registered {@link IResourceSetHook}s. * /*from w w w .jav a 2s. c o m*/ * @return unmodifiable {@link Collection} of {@link IResourceSetHook}. */ public Collection<IResourceSetHook> getResourceSetHooks() { return Collections.unmodifiableCollection( Collections2.filter(Collections2.transform(registry.values(), TO_HOOK), Predicates.notNull())); }
From source file:uk.org.ukfederation.mda.validate.AbstractValidationStage.java
/** * Set the list of validators to apply to each item. * /* www .java 2 s.c om*/ * @param newValidators the list of validators to set */ public void setValidators(@Nonnull final List<Validator<T>> newValidators) { ComponentSupport.ifDestroyedThrowDestroyedComponentException(this); ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); validators = ImmutableList.copyOf(Iterables.filter(newValidators, Predicates.notNull())); }
From source file:de.metas.ui.web.view.CompositeDefaultViewProfileIdProvider.java
@Override public ViewProfileId getDefaultProfileIdByWindowId(final WindowId windowId) { return providers.stream().map(provider -> provider.getDefaultProfileIdByWindowId(windowId)) .filter(Predicates.notNull()).findFirst().orElse(ViewProfileId.NULL); }