List of usage examples for org.apache.commons.collections4 CollectionUtils isEmpty
public static boolean isEmpty(final Collection<?> coll)
From source file:org.dspace.app.rest.RestResourceController.java
@RequestMapping(method = RequestMethod.GET, value = "/search") public ResourceSupport listSearchMethods(@PathVariable String apiCategory, @PathVariable String model) { ResourceSupport root = new ResourceSupport(); DSpaceRestRepository repository = utils.getResourceRepository(apiCategory, model); List<String> searchMethods = repositoryUtils.listSearchMethods(repository); if (CollectionUtils.isEmpty(searchMethods)) { throw new RepositorySearchNotFoundException(model); }/*from w w w .ja va 2 s . com*/ for (String name : searchMethods) { Link link = linkTo(this.getClass(), apiCategory, model).slash("search").slash(name).withRel(name); root.add(link); } return root; }
From source file:org.duniter.elasticsearch.service.DocStatService.java
public void computeStats() { // Skip if empty if (CollectionUtils.isEmpty(statDefs)) return;/*from w ww.j ava 2s . c o m*/ int bulkSize = pluginSettings.getIndexBulkSize(); long now = System.currentTimeMillis() / 1000; BulkRequestBuilder bulkRequest = client.prepareBulk(); DocStat stat = new DocStat(); stat.setTime(now); int counter = 0; for (StatDef statDef : statDefs) { long count = docStatDao.countDoc(statDef.index, statDef.type); // Update stat properties (resue existing obj) stat.setIndex(statDef.index); stat.setIndexType(statDef.type); stat.setCount(count); // Call compute listeners if any if (CollectionUtils.isNotEmpty(statDef.listeners)) { statDef.listeners.forEach(l -> l.onCompute(stat)); } // Add insertion into bulk IndexRequestBuilder request = docStatDao.prepareIndex(stat); bulkRequest.add(request); counter++; // Flush the bulk if not empty if ((counter % bulkSize) == 0) { client.flushBulk(bulkRequest); bulkRequest = client.prepareBulk(); } } // last flush if ((counter % bulkSize) != 0) { client.flushBulk(bulkRequest); } }
From source file:org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetType.java
private boolean isOneModuleListEmpty(final DistributionSetType dsType) { return (!CollectionUtils.isEmpty(((JpaDistributionSetType) dsType).elements) && CollectionUtils.isEmpty(elements)) || (CollectionUtils.isEmpty(((JpaDistributionSetType) dsType).elements) && !CollectionUtils.isEmpty(elements)); }
From source file:org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetType.java
private boolean areBothModuleListsEmpty(final DistributionSetType dsType) { return CollectionUtils.isEmpty(((JpaDistributionSetType) dsType).elements) && CollectionUtils.isEmpty(elements); }
From source file:org.eclipse.hawkbit.ui.management.targettable.TargetTable.java
private static boolean noFilterSelected(final Collection<TargetUpdateStatus> status, final Long distributionId, final Boolean noTagClicked, final String[] targetTags, final String searchText) { return CollectionUtils.isEmpty(status) && distributionId == null && Strings.isNullOrEmpty(searchText) && !isTagSelected(targetTags, noTagClicked); }
From source file:org.efaps.esjp.common.loginalert.AlertProvider_Base.java
/** * Gets the login alerts.//from w w w .j a v a2 s .com * * @return the login alerts */ public List<ILoginAlert> getLoginAlerts() { if (CollectionUtils.isEmpty(this.loginAlerts)) { try { this.loginAlerts = Listener.get().<ILoginAlert>invoke(ILoginAlert.class); } catch (final EFapsException e) { LOG.error("Catched error", e); } } return this.loginAlerts; }
From source file:org.efaps.esjp.ui.print.Table_Base.java
/** * Execute for gridx.//from w w w. jav a 2s . c om * * @param _parameter Parameter as passed by the eFaps API * @param _uiTable the ui table * @param _mime the mime * @return the jasper report builder * @throws EFapsException on error */ protected JasperReportBuilder execute4GridX(final Parameter _parameter, final UITable _uiTable, final String _mime) throws EFapsException { final JasperReportBuilder ret = getBuilder(_parameter, _uiTable, _mime); final String[] oidArr = (String[]) Context.getThreadContext().getSessionAttribute("selectedOIDs4print"); final Set<String> oids = ArrayUtils.isEmpty(oidArr) ? SetUtils.emptySet() : new HashSet<>(Arrays.asList(oidArr)); final String[] visibles = _parameter.getParameterValues("visibleRow"); final String[] columns = _parameter.getParameterValues("column"); final boolean isPdf = "pdf".equalsIgnoreCase(_mime); final List<Map<String, Object>> values = new ArrayList<>(); if (ArrayUtils.isNotEmpty(visibles)) { final List<UIRow> uirows = _uiTable.getValues(); final UIRow[] rowsArray = uirows.toArray(new UIRow[uirows.size()]); for (final String visible : visibles) { final UIRow row = rowsArray[Integer.valueOf(visible)]; if (CollectionUtils.isEmpty(oids) || oids.contains(row.getInstance().getOid())) { final Map<String, Object> map = new HashMap<>(); values.add(map); for (final String column : columns) { for (final IFilterable cell : row.getCells()) { if (cell.belongsTo(Long.valueOf(column))) { if (cell instanceof UIField) { final UIField uiField = (UIField) cell; Object value = isPdf ? uiField.getPickListValue() : (uiField.getCompareValue() != null ? uiField.getCompareValue() : uiField.getPickListValue()); if (value instanceof DateTime) { value = ((DateTime) value).toDate(); } map.put(uiField.getFieldConfiguration().getName(), value); } break; } } } } } for (final String column : columns) { for (final UITableHeader header : _uiTable.getHeaders()) { if (Long.valueOf(column) == header.getFieldId()) { final TextColumnBuilder<?> cb = getColumnBuilder4Values(values, header); if (isPdf) { final StyleBuilder colStyle = getStyle(_parameter, Section.COLUMN); if ("right".equalsIgnoreCase(header.getFieldConfig().getAlign())) { colStyle.setHorizontalTextAlignment(HorizontalTextAlignment.RIGHT); } cb.setStyle(colStyle).setTitleStyle(getStyle(_parameter, Section.COLUMNHEADER)); } ret.addColumn(cb); break; } } } } if (isPdf) { ret.setPageMargin(DynamicReports.margin(20)).setPageFormat(PageType.A4, PageOrientation.LANDSCAPE) .setColumnHeaderStyle(getStyle(_parameter, Table_Base.Section.COLUMNHEADER)) .highlightDetailEvenRows().pageFooter(DynamicReports.cmp.pageXofY().setStyle( DynamicReports.stl.style().setHorizontalTextAlignment(HorizontalTextAlignment.CENTER))); } else { ret.setIgnorePagination(true).setPageMargin(DynamicReports.margin(0)); } ret.setLocale(Context.getThreadContext().getLocale()).setDataSource(getSource(_parameter, values)); return ret; }
From source file:org.ethereum.net.server.ChannelManagerImpl.java
private void processNewPeers() { if (!CollectionUtils.isEmpty(newPeers)) { final List<Channel> processed = new ArrayList<>(); newPeers.stream().filter(channel -> channel.isProtocolsInitialized()).forEach(channel -> { ReasonCode reason = getNewPeerDisconnectionReason(channel); if (reason == null) { process(channel);/*from ww w. j a va 2s .c om*/ } else { disconnect(channel, reason); } processed.add(channel); }); newPeers.removeAll(processed); } }
From source file:org.ethereum.rpc.Web3Impl.java
private Account getDefaultAccount() { List<byte[]> accountAddresses = this.wallet.getAccountAddresses(); if (!CollectionUtils.isEmpty(accountAddresses)) { return this.wallet.getAccount(accountAddresses.get(0)); }/* www .j ava 2 s .co m*/ return null; }
From source file:org.finra.herd.dao.impl.AbstractHerdDao.java
/** * Builds a query restriction predicate for the storage. * * @param builder the criteria builder//from w w w . j a va 2 s . co m * @param storageEntity the storage entity that appears in the from clause * @param storagePlatformEntity the storage platform entity that appears in the from clause * @param storageNames the list of storage names where the business object data storage units should be looked for (case-insensitive) * @param storagePlatformType the optional storage platform type, e.g. S3 for Hive DDL. It is ignored when the list of storages is not empty * @param excludedStoragePlatformType the optional storage platform type to be excluded from search. It is ignored when the list of storages is not empty or * the storage platform type is specified * * @return the query restriction predicate */ protected Predicate getQueryRestrictionOnStorage(CriteriaBuilder builder, From<?, StorageEntity> storageEntity, From<?, StoragePlatformEntity> storagePlatformEntity, List<String> storageNames, String storagePlatformType, String excludedStoragePlatformType) { List<Predicate> predicates = new ArrayList<>(); // If specified, add restriction on storage. if (!CollectionUtils.isEmpty(storageNames)) { // Add a storage name restriction to the main query where clause. List<String> uppercaseStorageNames = new ArrayList<>(); for (String storageName : storageNames) { uppercaseStorageNames.add(storageName.toUpperCase()); } predicates.add(builder.upper(storageEntity.get(StorageEntity_.name)).in(uppercaseStorageNames)); } else if (StringUtils.isNotBlank(storagePlatformType)) { // Select storage units only from the storages of the specified storage platform type. predicates.add( builder.equal(storagePlatformEntity.get(StoragePlatformEntity_.name), storagePlatformType)); } else if (StringUtils.isNotBlank(excludedStoragePlatformType)) { // Ignore any storages of the excluded storage platform type. predicates.add(builder.notEqual(storagePlatformEntity.get(StoragePlatformEntity_.name), excludedStoragePlatformType)); } return builder.and(predicates.toArray(new Predicate[predicates.size()])); }