List of usage examples for org.apache.commons.collections4 CollectionUtils isEmpty
public static boolean isEmpty(final Collection<?> coll)
From source file:io.cloudslang.lang.cli.utils.CompilerHelperImpl.java
private Set<SystemProperty> loadPropertiesFromFiles(List<File> files, String[] extensions, String directory) { Collection<File> fileCollection; if (CollectionUtils.isEmpty(files)) { fileCollection = loadDefaultFiles(extensions, directory, true); if (CollectionUtils.isEmpty(fileCollection)) { return new HashSet<>(); }/* w w w .j av a 2s .co m*/ } else { fileCollection = files; for (File propertyFileCandidate : fileCollection) { Extension.validatePropertiesFileExtension(propertyFileCandidate.getName()); } } Map<File, Set<SystemProperty>> loadedProperties = new HashMap<>(); for (File propFile : fileCollection) { try { SlangSource source = SlangSource.fromFile(propFile); logger.info("Loading file: " + propFile); Set<SystemProperty> propsFromFile = slang.loadSystemProperties(source); mergeSystemProperties(loadedProperties, propsFromFile, propFile); } catch (Throwable ex) { String errorMessage = "Error loading file: " + propFile + " nested exception is " + ex.getMessage(); logger.error(errorMessage, ex); throw new RuntimeException(errorMessage, ex); } } return SetUtils.mergeSets(loadedProperties.values()); }
From source file:com.epam.catgenome.manager.protein.ProteinSequenceReconstructionManager.java
/** * Constructs amino acid sequences for specified gene track * * @param track a track to create sequences * @param cdsList a list of CDS blocks/* ww w. ja v a 2 s . com*/ * @param cdsNucleotides a list od CDS sequences * @param frames a list of CDS's frames * @return a map of protein sequences to CDS */ public Map<Gene, List<ProteinSequenceEntry>> getAminoAcids(final Track<Gene> track, final List<Gene> cdsList, final List<List<Sequence>> cdsNucleotides, final List<Integer> frames) { if (CollectionUtils.isEmpty(cdsList) || CollectionUtils.isEmpty(cdsNucleotides)) { return Collections.emptyMap(); } double time1 = Utils.getSystemTimeMilliseconds(); Map<Gene, List<ProteinSequenceEntry>> proteinSequences = new HashMap<>(); //if gene is on the negative strand, we should process it from the end checkAndRevert(cdsList, cdsNucleotides, frames); MutableInt aminoAcidCounter = new MutableInt(0); for (int i = 0; i < cdsNucleotides.size(); i++) { List<Sequence> nucleotides = cdsNucleotides.get(i); Gene cds = cdsList.get(i); int extendedStart = 0; int frame = frames.get(i); if (frame > 0 && i != 0) { //restore the part of the triplet from the previous nucleotides List<Sequence> prev = cdsNucleotides.get(i - 1); int prevNucleotides = TRIPLE_LENGTH - frame; if (prev.size() >= prevNucleotides) { List<Sequence> nucleotidesExtended = new ArrayList<>(); nucleotidesExtended.addAll(prev.subList(prev.size() - prevNucleotides, prev.size())); nucleotidesExtended.addAll(nucleotides); nucleotides = nucleotidesExtended; extendedStart = -prevNucleotides; } } else { nucleotides = nucleotides.subList(frame, nucleotides.size()); } // Construct amino acids from nucleotide triples. List<List<Sequence>> tripleList = ListUtils.partition(nucleotides, TRIPLE_LENGTH); List<ProteinSequenceEntry> value = reconstructAminoAcidByTriples(track, cds, cdsNucleotides, i, tripleList, extendedStart, aminoAcidCounter); proteinSequences.putIfAbsent(cds, value); } double time2 = Utils.getSystemTimeMilliseconds(); LOGGER.debug("Get amino acids {}:{} ms", Thread.currentThread().getName(), time2 - time1); return proteinSequences; }
From source file:com.evolveum.midpoint.web.component.form.ValueChoosePanel.java
protected void editValuePerformed(AjaxRequestTarget target) { List<QName> supportedTypes = getSupportedTypes(); ObjectFilter filter = createChooseQuery() == null ? null : createChooseQuery().getFilter(); if (CollectionUtils.isEmpty(supportedTypes)) { supportedTypes = WebComponentUtil.createObjectTypeList(); }/*w w w . ja v a2s . c o m*/ Class<O> defaultType = getDefaultType(supportedTypes); ObjectBrowserPanel<O> objectBrowserPanel = new ObjectBrowserPanel<O>(getPageBase().getMainPopupBodyId(), defaultType, supportedTypes, false, getPageBase(), filter) { private static final long serialVersionUID = 1L; @Override protected void onSelectPerformed(AjaxRequestTarget target, O object) { getPageBase().hideMainPopup(target); ValueChoosePanel.this.choosePerformed(target, object); } }; getPageBase().showMainPopup(objectBrowserPanel, target); }
From source file:nc.noumea.mairie.appock.viewmodel.PanierViewModel.java
@Command public void creeDemandeApprovisionnement() { if (CollectionUtils.isEmpty(selectedListeArticlePanier)) { Messagebox.show(/* w ww. j a v a 2 s . c o m*/ "Vous devez slectionner au moins un article dans le panier pour pouvoir crer une demande d'approvisionnement", "Cration refuse", Messagebox.OK, Messagebox.INFORMATION); return; } Demande demande = demandeService.creeDemandeFromListeArticlePanier(selectedListeArticlePanier); if (demande == null) { return; } for (ArticlePanier articlePanier : selectedListeArticlePanier) { entity.removeArticlePanier(articlePanier); } panierRepository.save(entity); rechargeOnglet(entity, "/layout/panier.zul", MainController.TITRE_PANIER); rechargeOngletListeDemande(); ouvreOnglet(demande, null); showNotificationStandard("Demande " + demande.getNumero() + " cr"); }
From source file:com.evolveum.midpoint.prism.delta.ContainerDelta.java
/** * Post processing of delta to expand missing values from the object. E.g. a delete deltas may * be "id-only" so they contain only id of the value to delete. In such case locate the full value * in the object and fill it into the delta. * This method may even delete id-only values that are no longer present in the object. *//*from w w w. j a va2 s . com*/ public <O extends Objectable> void expand(PrismObject<O> object, Trace logger) throws SchemaException { if (valuesToDelete != null) { ItemPath path = this.getPath(); PrismContainer<Containerable> container = null; if (object != null) { container = object.findContainer(path); } Iterator<PrismContainerValue<V>> iterator = valuesToDelete.iterator(); while (iterator.hasNext()) { PrismContainerValue<V> deltaCVal = iterator.next(); if (CollectionUtils.isEmpty(deltaCVal.getItems())) { Long id = deltaCVal.getId(); if (id == null) { throw new IllegalArgumentException( "No id and no items in value " + deltaCVal + " in delete set in " + this); } if (container != null) { PrismContainerValue<Containerable> containerCVal = container.findValue(id); if (containerCVal != null) { for (Item<?, ?> containerItem : containerCVal.getItems()) { deltaCVal.add(containerItem.clone()); } continue; } } // id-only value with ID that is not in the object any more: delete the value from delta iterator.remove(); } } } }
From source file:monasca.api.infrastructure.persistence.hibernate.NotificationMethodSqlRepoImpl.java
@Override @SuppressWarnings("unchecked") public List<NotificationMethod> find(String tenantId, List<String> sortBy, String offset, int limit) { Session session = null;/* w ww . ja va 2 s .c o m*/ List<NotificationMethodDb> resultList; List<NotificationMethod> notificationList = Lists.newArrayList(); final String rawQuery = "from NotificationMethodDb where tenant_id = :tenantId %1$s"; try { session = sessionFactory.openSession(); final StringBuilder orderByPart = new StringBuilder(); if (sortBy != null && !sortBy.isEmpty()) { orderByPart.append(" order by ").append(COMMA_JOINER.join(sortBy)); if (!sortBy.contains("id")) { orderByPart.append(",id"); } } else { orderByPart.append(" order by id "); } final String queryHql = String.format(rawQuery, orderByPart); final Query query = session.createQuery(queryHql).setString("tenantId", tenantId); if (limit > 0) { query.setMaxResults(limit + 1); } if (offset != null && !offset.isEmpty()) { query.setFirstResult(Integer.parseInt(offset)); } resultList = query.list(); if (CollectionUtils.isEmpty(resultList)) { return notificationList; } for (NotificationMethodDb item : resultList) { notificationList.add(this.convertToNotificationMethod(item)); } return notificationList; } finally { if (session != null) { session.close(); } } }
From source file:com.adguard.filter.rules.UrlFilterRule.java
/** * There are two exceptions for domain permitting in url blocking rules. * White list rules must fire when request has no referrer. * Also rules without third-party option should fire. * * @param domainName Domain name/*ww w. j a v a 2s.c o m*/ * @return true if permitted */ @Override public boolean isPermitted(String domainName) { // Lazy loading rule properties loadRuleProperties(); if (StringUtils.isEmpty(domainName)) { // For white list rules to fire when request has no referrer if (whiteListRule && CollectionUtils.isEmpty(getPermittedDomains())) { return true; } // Also firing rules when there's no constraint on ThirdParty-FirstParty type if (CollectionUtils.isEmpty(getPermittedDomains()) && !isOptionEnabled(UrlFilterRuleOption.THIRD_PARTY) && !isOptionDisabled(UrlFilterRuleOption.THIRD_PARTY)) { return true; } } return super.isPermitted(domainName); }
From source file:nc.noumea.mairie.appock.viewmodel.EditStockViewModel.java
protected void creeSortieStock(String referentAchatOuService) { if (CollectionUtils.isEmpty(selectedListeArticleStock)) { Messagebox.show(//from w w w.j a v a2s. c o m "Vous devez slectionner un article dans la liste avant de pouvoir effectuer une sortie de stock", "Erreur", Messagebox.OK, Messagebox.ERROR); return; } Map<String, Object> args = new HashMap<>(); args.put("selectedListeArticleStock", selectedListeArticleStock); args.put("referentAchatOuService", referentAchatOuService); Executions.createComponents("/layout/createSortieStockPopup.zul", null, args); }
From source file:io.cloudslang.lang.tools.build.ArgumentProcessorUtils.java
/** * @param stringList the list of strings * @param emptyMessage the empty message to use * @return A string joining the test suite names using io.cloudslang.lang.tools.build.SlangBuildMain#LIST_JOINER *///ww w .java 2 s.c o m public static String getListForPrint(final List<String> stringList, final String emptyMessage) { return CollectionUtils.isEmpty(stringList) ? ((emptyMessage == null) ? EMPTY : emptyMessage) : join(stringList, LIST_JOINER); }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopAbstractComponent.java
@Override public String getStyleName() { if (CollectionUtils.isEmpty(styles)) return StringUtils.EMPTY; return String.join(" ", styles); }