List of usage examples for java.util List removeIf
default boolean removeIf(Predicate<? super E> filter)
From source file:org.mule.service.soap.client.CxfClientProvider.java
private void removeInterceptor(List<Interceptor<? extends Message>> inInterceptors, String name) { inInterceptors.removeIf(i -> i instanceof PhaseInterceptor && ((PhaseInterceptor) i).getId().equals(name)); }
From source file:act.installer.reachablesexplorer.PatentFinder.java
private void run(Loader loader, Searcher searcher) throws IOException { DBCursor<Reachable> reachableDBCursor = loader.getJacksonReachablesCollection().find(); while (reachableDBCursor.hasNext()) { Reachable reachable = reachableDBCursor.next(); SynonymData synonyms = reachable.getSynonyms(); Set<String> preferredSynonyms = null; if (synonyms != null) { Map<PubchemSynonymType, Set<String>> pubchemSynonyms = synonyms.getPubchemSynonyms(); /* Search for different kinds of synonyms in order of preference (where preference tries to strike a balance * between verbosity and specificity). Stop when we've found a type of synonym that is available for this * molecule, and use that in the patent search. */ for (PubchemSynonymType type : SYNONYM_TYPE_PREFERENCE) { if (pubchemSynonyms.containsKey(type)) { preferredSynonyms = pubchemSynonyms.get(type); break; }/* w ww .ja v a 2 s. c o m*/ } } if (preferredSynonyms == null) { LOGGER.warn("No synonyms for molecule %s", reachable.getInchi()); preferredSynonyms = Collections.emptySet(); } List<String> allNames = new ArrayList<>(reachable.getNames()); allNames.addAll(preferredSynonyms); allNames.removeIf(s -> s == null || s.length() < 3); // Eliminate potential garbage rankings for short names. // Note: stop words should not appear in the index, so no need to filter on terms. Collections.sort(allNames); LOGGER.info("Running query with terms: %s", StringUtils.join(allNames, ", ")); List<Searcher.SearchResult> results = searcher.searchInClaims(allNames); if (results.size() > 0) { LOGGER.info("Results (%d) for %s:", results.size(), reachable.getPageName()); List<PatentSummary> summaries = new ArrayList<>(results.size()); for (Searcher.SearchResult result : results) { LOGGER.info("(%.3f) %s: %s", result.getRelevanceScore(), result.getId(), result.getTitle()); summaries.add(new PatentSummary(result.getId(), result.getTitle(), result.getRelevanceScore())); } reachable.setPatentSummaries(summaries); loader.upsert(reachable); } else { LOGGER.info("No results for %s", reachable.getPageName()); } } }
From source file:pl.hycom.pip.messanger.controller.GreetingController.java
@GetMapping("/admin/deleteGreeting/{locale}") public String removeGreeting(@PathVariable String locale, Model model) { if (StringUtils.equals(locale, DEFAULT_LOCALE)) { prepareModel(model);// w w w.j a va2 s . co m String message = getMessage("greetings.invalidOperation"); model.addAttribute("errors", Collections.singletonList(message)); return VIEW_GREETINGS; } try { List<com.github.messenger4j.profile.Greeting> greetings = getGreetingsWithDefaultLocale(); greetings.removeIf(g -> StringUtils.equals(g.getLocale(), locale)); profileClient.removeWelcomeMessage(); profileClient.setupWelcomeMessages(greetings); log.info("Deleting greeting succeeded"); } catch (MessengerApiException | MessengerIOException e) { log.info("Deleting greeting failed", e); } return REDIRECT_ADMIN_GREETINGS; }
From source file:com.github.lynxdb.server.core.repository.SuggestRepo.java
public List<String> byTagValue(Vhost _vhost, String _query) { List<String> result = ct.select(QueryBuilder.select("tagv").from("suggest_tagv") .where(QueryBuilder.eq("vhostid", _vhost.getId())).limit(Integer.MAX_VALUE), String.class); if (_query.isEmpty()) { return result; }//from w ww . ja v a 2 s.com result.removeIf((s -> !s.contains(_query))); monitor.queryGetCount.incrementAndGet(); return result; }
From source file:com.github.lynxdb.server.core.repository.SuggestRepo.java
public List<String> byTagKey(Vhost _vhost, String _query) { List<String> result = ct.select(QueryBuilder.select("tagk").from("suggest_tagk") .where(QueryBuilder.eq("vhostid", _vhost.getId())).limit(Integer.MAX_VALUE), String.class); if (_query.isEmpty()) { return result; }/* www .ja v a2s . co m*/ result.removeIf((s -> !s.contains(_query))); monitor.queryGetCount.incrementAndGet(); return result; }
From source file:com.github.lynxdb.server.core.repository.SuggestRepo.java
public List<String> byName(Vhost _vhost, String _query) { List<String> result = ct.select(QueryBuilder.select("name").from("suggest_name") .where(QueryBuilder.eq("vhostid", _vhost.getId())).limit(Integer.MAX_VALUE), String.class); if (_query.isEmpty()) { return result; }/*ww w .java2 s. com*/ result.removeIf((s -> !s.contains(_query))); monitor.queryGetCount.incrementAndGet(); return result; }
From source file:com.codelanx.codelanxlib.command.TabInfo.java
/** * Applies this {@link TabInfo} to a series of command arguments. If the * final argument is incomplete, then any default arguments which do not * start with the specified incomplete argument will be removed from the * possible results/*from ww w. j a v a 2s . co m*/ * * @since 0.1.0 * @version 0.1.0 * * @param sender The {@link CommandSender} who is tabbing * @param args The arguments being tested * @return The possible arguments that could be used */ public List<String> apply(CommandSender sender, String... args) { String arg = null; int get = args.length - 1; if (args.length > 0) { arg = args[get]; } else { get = 0; } SupplierContainer back = this.defaults.get(get); if (back == null) { return TabInfo.BLANK_TAB_COMPLETE; } else { List<String> fil = new ArrayList<>(back.apply(sender, arg)); //Potentially unknown return (unmodifiable) fil.removeIf(Lambdas::isNull); if (arg != null) { final String tempArg = arg; fil.removeIf(s -> !s.startsWith(tempArg)); } return fil; } }
From source file:org.ligoj.app.plugin.id.resource.batch.AbstractBatchResource.java
protected <T extends AbstractBatchTask<B>> long batchInternal(final InputStream uploadedFile, final String[] columns, final String encoding, final String[] defaultColumns, final Class<B> batchType, final Class<T> taskType, final Boolean quiet) throws IOException { // Public identifier is based on system date final long id = System.currentTimeMillis(); // Check column's name validity final String[] sanitizeColumns = ArrayUtils.isEmpty(columns) ? defaultColumns : columns; checkHeaders(defaultColumns, sanitizeColumns); // Build CSV header from array final String csvHeaders = StringUtils.chop(ArrayUtils.toString(sanitizeColumns)).substring(1).replace(',', ';') + "\n"; // Build entries with prepended CSV header final String encSafe = ObjectUtils.defaultIfNull(encoding, StandardCharsets.UTF_8.name()); final ByteArrayInputStream input = new ByteArrayInputStream(csvHeaders.getBytes(encSafe)); final List<B> entries = csvForBean.toBean(batchType, new InputStreamReader(new SequenceInputStream(input, uploadedFile), encSafe)); entries.removeIf(Objects::isNull); // Validate them validator.validateCheck(entries);//from w w w .j a va 2 s.c om // Clone the context for the asynchronous import final BatchTaskVo<B> importTask = new BatchTaskVo<>(); importTask.setEntries(entries); importTask.setPrincipal(SecurityContextHolder.getContext().getAuthentication().getName()); importTask.setId(id); importTask.setQuiet(BooleanUtils.isTrue(quiet)); // Schedule the import final T task = SpringUtils.getBean(taskType); task.configure(importTask); executor.execute(task); // Also cleanup the previous tasks cleanup(); // Expose the task with internal identifier, based on current user PLUS the public identifier imports.put(importTask.getPrincipal() + "-" + importTask.getId(), importTask); // Return private task identifier return id; }
From source file:org.apache.hadoop.hbase.util.compaction.MajorCompactor.java
private boolean futuresComplete(List<Future<?>> futures) { futures.removeIf(Future::isDone); return futures.isEmpty(); }
From source file:org.openhab.tools.analysis.checkstyle.ManifestExternalLibrariesCheck.java
private List<String> getManifestJarFiles(FileText fileText) throws IOException { BundleInfo manifest = null;//w ww . j av a 2 s . c o m try { manifest = parseManifestFromFile(fileText); } catch (CheckstyleException ex) { throw new IOException(COULD_NOT_OPEN_MANIFEST); } List<String> classpathEntries = manifest.getClasspath(); if (classpathEntries != null) { // Spaces at the end of the bundle classpath are trimmed. classpathEntries.replaceAll(String::trim); // Binaries, compiled from the bundle sources are excluded. We will check only external binaries. classpathEntries.removeIf(x -> !x.contains(".jar")); return classpathEntries; } else { return Collections.emptyList(); } }