List of usage examples for com.google.common.base Predicates notNull
@GwtCompatible(serializable = true) public static <T> Predicate<T> notNull()
From source file:fi.csc.idp.stepup.impl.CheckRequestedAuthenticationContext.java
/** * Sets the list of authentication methods requiring step up. * //from ww w . j a v a 2s . c o m * * @param <T> * a type of principal to add, if not generic * @param principals * supported principals to add */ public <T extends Principal> void setStepupMethods(@Nonnull @NonnullElements final Collection<T> principals) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); Constraint.isNotNull(principals, "Principal collection cannot be null."); if (stepupPrincipals == null) { stepupPrincipals = new Subject(); } stepupPrincipals.getPrincipals().clear(); stepupPrincipals.getPrincipals().addAll(Collections2.filter(principals, Predicates.notNull())); }
From source file:org.eclipse.buildship.core.workspace.internal.DefaultGradleWorkspaceManager.java
private Set<FixedRequestAttributes> getBuilds(Collection<IProject> projects) { return FluentIterable.from(projects).filter(GradleProjectNature.isPresentOn()) .transform(new Function<IProject, FixedRequestAttributes>() { @Override/*from w w w.j av a2 s. c o m*/ public FixedRequestAttributes apply(IProject project) { Optional<ProjectConfiguration> configuration = CorePlugin.projectConfigurationManager() .tryReadProjectConfiguration(project); return configuration.isPresent() ? configuration.get() .toRequestAttributes(ConversionStrategy.MERGE_WORKSPACE_SETTINGS) : null; } }).filter(Predicates.notNull()).toSet(); }
From source file:org.jclouds.aws.ec2.compute.suppliers.CallForImages.java
public Iterable<Image> call() { logger.debug(">> providing images"); Builder<String, DescribeImagesOptions> builder = ImmutableMap.builder(); for (String region : regions) builder.put(region, filters(filter)); Iterable<Entry<String, DescribeImagesOptions>> queries = builder.build().entrySet(); Iterable<Image> returnVal = filter(transform(describer.apply(queries), parser), Predicates.notNull()); if (logger.isDebugEnabled()) logger.debug("<< images(%s)", Iterables.size(returnVal)); return returnVal; }
From source file:org.grouplens.lenskit.scored.VectorEntryScoredId.java
@Nonnull @Override/*from w w w . j ava 2 s .c om*/ public Collection<SymbolValue<?>> getChannels() { return FluentIterable.from(vector.getChannelSymbols()) .transform(new Function<TypedSymbol<?>, SymbolValue<?>>() { @SuppressWarnings({ "unchecked", "rawtypes" }) @Nullable @Override public SymbolValue<?> apply(@Nullable TypedSymbol input) { assert input != null; Object obj = vector.getChannel(input).get(ent.getKey()); if (obj == null) { return null; } else { return input.withValue(obj); } } }).filter(Predicates.notNull()).toList(); }
From source file:org.napile.idea.plugin.caches.NapileGotoSymbolContributor.java
@NotNull @Override/* w ww . ja v a2 s .com*/ public NavigationItem[] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) { final GlobalSearchScope scope = includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project); final Collection<? extends NavigationItem> it1 = StubIndex.getInstance() .get(NapileIndexKeys.METHODS_SHORT_NAME_KEY, name, project, scope); final Collection<? extends NavigationItem> it2 = StubIndex.getInstance() .get(NapileIndexKeys.MACROS_SHORT_NAME_KEY, name, project, scope); final Collection<? extends NavigationItem> it3 = StubIndex.getInstance() .get(NapileIndexKeys.VARIABLES_SHORT_NAME_KEY, name, project, scope); List<NavigationItem> symbols = new ArrayList<NavigationItem>(it1.size() + it2.size() + it3.size()); symbols.addAll(it1); symbols.addAll(it2); symbols.addAll(it3); final List<NavigationItem> items = new ArrayList<NavigationItem>( Collections2.filter(symbols, Predicates.notNull())); return ArrayUtil.toObjectArray(items, NavigationItem.class); }
From source file:controllers.modules.base.Module.java
public Module setViewModels(Iterable<ViewModel> viewModels) { viewModels = ObjectUtils.defaultIfNull(viewModels, Lists.<ViewModel>newArrayList()); if (!validateViewModels(viewModels)) { throw new IllegalArgumentException("Supplied view models not valid for the current context."); }/* ww w. j a v a2 s .co m*/ this.viewModels = Iterables.filter(viewModels, Predicates.notNull()); return this; }
From source file:org.apache.druid.query.GroupByMergedQueryRunner.java
public GroupByMergedQueryRunner(ExecutorService exec, Supplier<GroupByQueryConfig> configSupplier, QueryWatcher queryWatcher, NonBlockingPool<ByteBuffer> bufferPool, Iterable<QueryRunner<T>> queryables) { this.exec = MoreExecutors.listeningDecorator(exec); this.queryWatcher = queryWatcher; this.queryables = Iterables.unmodifiableIterable(Iterables.filter(queryables, Predicates.notNull())); this.configSupplier = configSupplier; this.bufferPool = bufferPool; }
From source file:gobblin.example.wikipedia.WikipediaSource.java
@Override public List<WorkUnit> getWorkunits(SourceState state) { Map<String, Iterable<WorkUnitState>> previousWorkUnits = state.getPreviousWorkUnitStatesByDatasetUrns(); List<String> titles = new LinkedList<>(Splitter.on(",").omitEmptyStrings() .splitToList(state.getProp(WikipediaExtractor.SOURCE_PAGE_TITLES))); Map<String, LongWatermark> prevHighWatermarks = Maps.newHashMap(); for (Map.Entry<String, Iterable<WorkUnitState>> entry : previousWorkUnits.entrySet()) { Iterable<LongWatermark> watermarks = Iterables.transform(entry.getValue(), new Function<WorkUnitState, LongWatermark>() { @Override// w w w .j ava 2 s .c o m public LongWatermark apply(WorkUnitState wus) { return wus.getActualHighWatermark(LongWatermark.class); } }); watermarks = Iterables.filter(watermarks, Predicates.notNull()); List<LongWatermark> watermarkList = Lists.newArrayList(watermarks); if (watermarkList.size() > 0) { prevHighWatermarks.put(entry.getKey(), Collections.max(watermarkList)); } } Extract extract = createExtract(TableType.SNAPSHOT_ONLY, state.getProp(ConfigurationKeys.EXTRACT_NAMESPACE_NAME_KEY), "WikipediaOutput"); List<WorkUnit> workUnits = Lists.newArrayList(); for (String title : titles) { LongWatermark prevWatermark = prevHighWatermarks.containsKey(title) ? prevHighWatermarks.get(title) : new LongWatermark(-1); prevHighWatermarks.remove(title); WorkUnit workUnit = WorkUnit.create(extract, new WatermarkInterval(prevWatermark, new LongWatermark(-1))); workUnit.setProp(ConfigurationKeys.DATASET_URN_KEY, title); workUnits.add(workUnit); } for (Map.Entry<String, LongWatermark> nonProcessedDataset : prevHighWatermarks.entrySet()) { WorkUnit workUnit = WorkUnit.create(extract, new WatermarkInterval(nonProcessedDataset.getValue(), nonProcessedDataset.getValue())); workUnit.setProp(ConfigurationKeys.DATASET_URN_KEY, nonProcessedDataset.getKey()); workUnits.add(workUnit); } return workUnits; }
From source file:ru.crazyproger.plugins.webtoper.nls.codeinsight.NlsCompletionContributor.java
@NotNull public static Collection<NlsFileImpl> getNlsFiles(Project project) { Collection<VirtualFile> files = getNlsVirtualFiles(project); if (files.isEmpty()) return Collections.emptyList(); final PsiManager psiManager = PsiManager.getInstance(project); Collection<NlsFileImpl> nlsFiles = Collections2.transform(files, new Function<VirtualFile, NlsFileImpl>() { @Override//from ww w. j a v a 2 s. c o m public NlsFileImpl apply(@Nullable VirtualFile virtualFile) { if (virtualFile != null) { return (NlsFileImpl) psiManager.findFile(virtualFile); } return null; } }); return Collections2.filter(nlsFiles, Predicates.notNull()); }
From source file:org.trnltk.morphology.lexicon.DictionaryLoader.java
HashSet<Lexeme> createLexemesFromLines(Iterable<String> lines) { final LexemeCreator loader = new LexemeCreator(); final Iterable<Lexeme> lexemes = Iterables.transform(lines, new Function<String, Lexeme>() { @Override// ww w . ja va2 s . com public Lexeme apply(String input) { if (StringUtils.isBlank(input)) return null; input = input.trim(); if (input.startsWith(COMMENT_SYMBOL)) return null; return loader.createLexemeFromLine(input); } }); return Sets.newHashSet(Iterables.filter(lexemes, Predicates.notNull())); }