List of usage examples for org.apache.commons.collections4 CollectionUtils isNotEmpty
public static boolean isNotEmpty(final Collection<?> coll)
From source file:com.epam.catgenome.dao.DaoHelper.java
/** * Creates a new temporary list of {@code Long} values and generates unique ID for a * created temporary list.//from w ww . ja v a 2 s . c om * * @param list {@code Collection} specifies collection of {@code Long} values that should be * associated with a temporary list if this call is succeeded * @return {@code Long} represents unique ID of a temporary list that has been created after * this call * @throws IllegalArgumentException will be thrown if the given <tt>list</tt> is empty */ @Transactional(propagation = Propagation.MANDATORY) public Long createTempLongList(final Collection<Long> list) { Assert.isTrue(CollectionUtils.isNotEmpty(list)); return createTempLongList(createListId(), list); }
From source file:com.romeikat.datamessie.core.processing.task.documentProcessing.DocumentsProcessingTask.java
private void performProcessing(final TaskExecution taskExecution) throws TaskCancelledException { // Initialize taskExecution.reportWork("Starting documents processing"); // Determine minimum downloaded date final LocalDate minDownloadedDate = getMinDownloadedDate(sessionProvider.getStatelessSession()); // Process all download dates one after another, starting with the minimum downloaded date final MutableObject<LocalDate> downloadedDate = new MutableObject<LocalDate>(minDownloadedDate); while (true) { // Load// www. j a v a 2 s. c o m final List<Document> documentsToProcess = documentsLoader.loadDocumentsToProcess( sessionProvider.getStatelessSession(), taskExecution, downloadedDate.getValue(), failedDocumentIds); // Process if (CollectionUtils.isNotEmpty(documentsToProcess)) { final String singularPlural = stringUtil.getSingularOrPluralTerm("document", documentsToProcess.size()); final TaskExecutionWork work = taskExecution.reportWorkStart( String.format("Processing %s %s", documentsToProcess.size(), singularPlural)); final DocumentsProcessor documentsProcessor = new DocumentsProcessor(ctx); documentsProcessor.processDocuments(documentsToProcess); failedDocumentIds.addAll(documentsProcessor.getFailedDocumentIds()); rebuildStatistics(documentsProcessor.getStatisticsToBeRebuilt()); reindexDocuments(documentsToProcess); taskExecution.reportWorkEnd(work); taskExecution.checkpoint(); } // Prepare for next iteration prepareForNextIteration(taskExecution, downloadedDate, documentsToProcess); } }
From source file:co.rsk.remasc.Remasc.java
/** * Saves uncles of the current block into the siblings map to use in the future for fee distribution *//* www .j a v a2s. c o m*/ private void addNewSiblings() { // Add uncles of the execution block to the siblings map List<BlockHeader> uncles = executionBlock.getUncleList(); if (CollectionUtils.isNotEmpty(uncles)) { for (BlockHeader uncleHeader : uncles) { List<Sibling> siblings = provider.getSiblings().get(uncleHeader.getNumber()); if (siblings == null) siblings = new ArrayList<>(); siblings.add(new Sibling(uncleHeader, executionBlock.getHeader().getCoinbase(), executionBlock.getNumber())); provider.getSiblings().put(uncleHeader.getNumber(), siblings); } } }
From source file:com.jkoolcloud.tnt4j.streams.parsers.GenericActivityParser.java
/** * Returns whether this parser pre-parsers supports the given format of the RAW activity data. This is used by * activity streams to determine if the parser pre-parses can parse the data in the format that the stream has it. * * @param data//w w w . ja v a 2 s . co m * data object whose class is to be verified * @return {@code true} if this parser pre-parsers can process data in the specified format, {@code false} - * otherwise */ protected boolean isDataClassSupportedByPreParser(Object data) { if (CollectionUtils.isNotEmpty(preParsers)) { for (ActivityDataPreParser<?> dp : preParsers) { if (dp.isDataClassSupported(data)) { return true; } } } return false; }
From source file:com.epam.catgenome.dao.ReferenceGenomeDaoTest.java
@Test @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class) public void testChromosomeManagement() { final List<Chromosome> chromosomes = reference.getChromosomes(); // tests that batch of chromosomes are saved and IDs are assigned final int count = chromosomes.size(); final int[] result = referenceGenomeDao.saveChromosomes(reference.getId(), chromosomes); assertEquals("Unexpected batch size.", count, result.length); for (int i = 0; i < count; i++) { assertEquals("Unexpected number of affected rows after chromosome has been saved successfully.", 1, result[i]);//w w w. ja v a 2s .com Chromosome entity = chromosomes.get(i); assertNotNull("Chromosome ID has been assigned.", entity.getId()); assertNotNull("Reference ID has been assigned.", entity.getReferenceId()); } final Chromosome chromosome = chromosomes.get(0); // tests that a chromosome can be retrieved by the given ID final Chromosome foundById = referenceGenomeDao.loadChromosome(chromosome.getId()); assertNotNull("Chromosome isn't found by the given ID.", foundById); ReflectionAssert.assertReflectionEquals("Unexpected chromosome is loaded by ID.", chromosome, foundById); // tests that all chromosomes related to a reference genome with the given ID can be retrieved final List<Chromosome> allChromosomes = referenceGenomeDao .loadAllChromosomesByReferenceId(reference.getId()); assertTrue("Collection of chromosomes is empty, but it should contain more than 1 value.", CollectionUtils.isNotEmpty(allChromosomes)); assertEquals("Unexpected number of chromosomes for the given reference is detected.", count, allChromosomes.size()); final Optional<Chromosome> foundInList = allChromosomes.stream() .filter(e -> chromosome.getId().equals(e.getId())).findFirst(); assertTrue("Chromosome isn't found by ID in the retrieved list.", foundInList.isPresent()); ReflectionAssert.assertReflectionEquals("Unexpected chromosome is found in the list.", chromosome, foundInList.get()); }
From source file:gov.ca.cwds.cals.service.mapper.FacilityMapper.java
default void afterLastVisit(FacilityDto facilityDto, CountyLicenseCase countyLicenseCase) { if (countyLicenseCase != null && CollectionUtils.isNotEmpty(countyLicenseCase.getLicensingVisits())) { List<? extends BaseLicensingVisit> licensingVisits = countyLicenseCase.getLicensingVisits(); if (licensingVisits != null) { Mappers.getMapper(FacilityMapper.class).toFacilityDto(facilityDto, licensingVisits.get(0)); }//from w ww.ja v a 2 s . c o m } }
From source file:com.ebay.myriad.state.SchedulerState.java
public Collection<NodeTask> getActiveTasks() { List<NodeTask> activeNodeTasks = new ArrayList<>(); if (CollectionUtils.isNotEmpty(activeTasks) && CollectionUtils.isNotEmpty(tasks.values())) { activeNodeTasks = tasks.values().stream().filter(task -> activeTasks.contains(task.getTaskId())) .collect(Collectors.toList()); }/* www. j a v a2 s . co m*/ return activeNodeTasks; }
From source file:com.haulmont.cuba.web.sys.MenuBuilder.java
protected Consumer<AppMenu.MenuItem> createMenuBarCommand(final MenuItem item) { if (CollectionUtils.isNotEmpty(item.getChildren()) || item.isMenu()) //check item is menu return null; return createMenuCommandExecutor(item); }
From source file:cop.maven.plugins.AbstractRestToRamlMojo.java
private String buildCompileClasspath() { Set<String> elements = new LinkedHashSet<>(); if (CollectionUtils.isNotEmpty(pluginArtifacts)) elements.addAll(pluginArtifacts.stream() .filter(artifact -> Artifact.SCOPE_COMPILE.equalsIgnoreCase(artifact.getScope()) || Artifact.SCOPE_RUNTIME.equalsIgnoreCase(artifact.getScope())) .map(Artifact::getFile).filter(Objects::nonNull).map(File::getAbsolutePath) .collect(Collectors.toList())); elements.addAll(getClasspathElements()); return String.join(";", elements); }
From source file:com.epam.catgenome.dao.DaoHelper.java
@Transactional(propagation = Propagation.MANDATORY) public Long createTempStringList(final Collection<String> list) { Assert.isTrue(CollectionUtils.isNotEmpty(list)); return createTempStringList(createListId(), list); }