List of usage examples for org.apache.commons.collections4 CollectionUtils isEmpty
public static boolean isEmpty(final Collection<?> coll)
From source file:com.epam.catgenome.manager.reference.CytobandManager.java
/** * Returns {@code Track} with cytobands if they're available for a chromosome with * the given ID, otherwise returns <tt>null</tt>. * * @param chromosomeId {@code Long} represents Chromosome ID which cytobands should * be loaded//from w ww .j av a 2 s . c o m * @return {@code Track} describes cytological card if it's available or <tt>null</tt> * otherwise * @throws IOException will be thrown if any I/O errors occur */ public Track<Cytoband> loadCytobands(final Long chromosomeId) throws IOException { // loads chromosome data by the given ID final Chromosome chromosome = referenceGenomeManager.loadChromosome(chromosomeId); // tries to find a file that provides cytobands for the given chromosome final File cytobandFile = fileManager.makeCytobandsFile(chromosome); if (!cytobandFile.exists()) { return null; } // loads cytobands from a file, skipping validation, because it was done earlier final CytobandReader reader = CytobandReader.getInstance(cytobandFile); final CytobandRecord record = reader.getRecord(chromosome.getName()); if (record == null || CollectionUtils.isEmpty(record.getBands())) { return null; } // creates and fills a new track that describes cytobands final Track<Cytoband> track = new Track<>(TrackType.CYTOBAND); track.setStartIndex(1); track.setScaleFactor(1D); track.setId(chromosomeId); track.setChromosome(chromosome); track.setBlocks(record.getBands()); track.setName(chromosome.getName()); track.setEndIndex(chromosome.getSize()); return track; }
From source file:com.epam.catgenome.dao.gene.GeneFileDao.java
@Transactional(propagation = Propagation.MANDATORY) public List<GeneFile> loadGeneFiles(Collection<Long> ids) { if (CollectionUtils.isEmpty(ids)) { return Collections.emptyList(); }//w ww. j a v a 2s. c o m long listId = daoHelper.createTempLongList(ids); List<BiologicalDataItem> files = getJdbcTemplate().query(loadGeneFilesQuery, BiologicalDataItemDao.BiologicalDataItemParameters.getRowMapper(), listId); daoHelper.clearTempList(listId); return files.stream().map(f -> (GeneFile) f).collect(Collectors.toList()); }
From source file:com.jkoolcloud.tnt4j.streams.parsers.ActivityRegExParser.java
@Override public void addField(ActivityField field) { List<ActivityFieldLocator> locators = field.getLocators(); if (CollectionUtils.isEmpty(locators)) { return;//from ww w . ja v a 2 s . co m } List<ActivityFieldLocator> matchLocs = new ArrayList<>(); List<ActivityFieldLocator> groupLocs = new ArrayList<>(); for (ActivityFieldLocator locator : locators) { ActivityFieldLocatorType locType = locator.getBuiltInType(); logger().log(OpLevel.DEBUG, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME, "ActivityParser.adding.field"), field); // Utils.getDebugString(field)); if (locType == ActivityFieldLocatorType.REMatchNum) { if (groupMap.containsKey(field)) { throw new IllegalArgumentException( StreamsResources.getStringFormatted(StreamsResources.RESOURCE_BUNDLE_NAME, "ActivityRegExParser.conflicting.mapping", field)); } matchLocs.add(locator); } else { if (matchMap.containsKey(field)) { throw new IllegalArgumentException( StreamsResources.getStringFormatted(StreamsResources.RESOURCE_BUNDLE_NAME, "ActivityRegExParser.conflicting.mapping", field)); } groupLocs.add(locator); } } if (!matchLocs.isEmpty()) { matchMap.put(field, matchLocs); } if (!groupLocs.isEmpty()) { groupMap.put(field, groupLocs); } }
From source file:com.romeikat.datamessie.core.base.dao.impl.StatisticsDao.java
public StatisticsSparseTable getStatistics(final SharedSessionContract ssc, final Collection<Long> sourceIds, final LocalDate published) { if (CollectionUtils.isEmpty(sourceIds) || published == null) { return new StatisticsSparseTable(); }// w ww. ja v a2 s.com // Query final StringBuilder hql = new StringBuilder(); hql.append("SELECT s.sourceId, s.state, documents "); hql.append("FROM Statistics s "); hql.append("WHERE s.sourceId IN :_sourceIds "); hql.append("AND s.published = :_published "); hql.append("GROUP BY s.sourceId, s.state "); final Query<Object[]> query = ssc.createQuery(hql.toString(), Object[].class); query.setParameterList("_sourceIds", sourceIds); query.setParameter("_published", published); // Execute final List<Object[]> records = query.list(); // Postprocess final StatisticsSparseTable statistics = new StatisticsSparseTable(); for (final Object[] record : records) { final long sourceId = (Long) record[0]; final DocumentProcessingState state = (DocumentProcessingState) record[1]; final long number = (Long) record[2]; final DocumentsPerState documentsForState = new DocumentsPerState(); documentsForState.put(state, number); statistics.putValue(sourceId, published, documentsForState); } // Done return statistics; }
From source file:co.runrightfast.incubator.rx.impl.ObservableRingBufferImpl.java
private void onEvent(final RingBufferReference<A> msg, final long sequence, final boolean endOfBatch) { if (CollectionUtils.isEmpty(subscribers)) { warning.log("onEvent", new LogMessage("message dropped because there are no observers", getClass().getName(), sequence)); return;//from ww w . j av a2 s . c o m } for (final Subscriber<? super A> subscriber : subscribers) { if (subscriber.isUnsubscribed()) { this.subscribers.remove(subscriber); continue; } try { subscriber.onNext(msg.data); } catch (final Throwable t) { subscriber.onError(t); this.subscribers.remove(subscriber); } } }
From source file:com.jkoolcloud.tnt4j.streams.fields.AbstractFieldEntity.java
/** * Transforms provided object value using defined transformations. If more than one transformation defined, * transformations are applied sequentially where transformation input data is output of previous transformation. * * @param fieldValue//from ww w . ja va 2 s . c o m * value to transform * @return transformed value * @throws Exception * if transformation operation fails */ public Object transformValue(Object fieldValue) throws Exception { if (CollectionUtils.isEmpty(transformations)) { return fieldValue; } Object tValue = fieldValue; for (ValueTransformation<Object, Object> vt : transformations) { tValue = vt.transform(tValue); } return tValue; }
From source file:io.cloudslang.lang.compiler.modeller.transformers.ResultsTransformer.java
private void addResult(List<Result> results, Result element, List<RuntimeException> errors) { List<RuntimeException> validationErrors = preCompileValidator.validateNoDuplicateInOutParams(results, element);/*from w w w .j a v a 2s. co m*/ if (CollectionUtils.isEmpty(validationErrors)) { results.add(element); } else { errors.addAll(validationErrors); } }
From source file:io.cloudslang.lang.compiler.modeller.transformers.AbstractOutputsTransformer.java
void addOutput(List<Output> outputs, Output element, List<RuntimeException> errors) { List<RuntimeException> validationErrors = preCompileValidator.validateNoDuplicateInOutParams(outputs, element);//from w w w .jav a 2 s. c om if (CollectionUtils.isEmpty(validationErrors)) { outputs.add(element); } else { errors.addAll(validationErrors); } }
From source file:com.baifendian.swordfish.dao.model.ExecutionNode.java
/** * job link /* www .j av a 2 s .c o m*/ */ public void addJobLinkList(List<String> jobLinkList) { if (jobLinkList == null) { return; } if (CollectionUtils.isEmpty(this.jobLinkList)) { setJobLinkList(jobLinkList); return; } this.jobLinkList.addAll(jobLinkList); this.jobLinks = JsonUtil.toJsonString(this.jobLinkList); }
From source file:com.ejisto.event.ApplicationEventDispatcher.java
@SuppressWarnings("unchecked") private void notifyListenersFor(Class<BaseApplicationEvent> eventClass, final BaseApplicationEvent applicationEvent) { List<ApplicationListener<? extends BaseApplicationEvent>> listeners = registeredListeners.get(eventClass); if (!CollectionUtils.isEmpty(listeners)) { for (final ApplicationListener listener : listeners) { log.trace("forwarding event to listener " + listener); listener.onApplicationEvent(applicationEvent); }//from ww w .ja v a 2 s .c o m } Class<?> superClass = eventClass.getSuperclass(); if (superClass != null && BaseApplicationEvent.class.isAssignableFrom(superClass)) { notifyListenersFor((Class<BaseApplicationEvent>) eventClass.getSuperclass(), applicationEvent); } }