List of usage examples for org.apache.commons.collections4 CollectionUtils isNotEmpty
public static boolean isNotEmpty(final Collection<?> coll)
From source file:com.wiiyaya.provider.main.service.impl.BackendUserServiceImpl.java
@Override @Transactional(rollbackFor = BusinessException.class) public void updateUser(BackendUserDto backendUserDto) throws BusinessException { BackendUser backendUserDb = backendUserDao.findOne(backendUserDto.getId()); if (backendUserDb == null) { throw new BusinessException(MainConstant.ERROR_USER_NOT_FOUND); }//from w ww.j a v a 2 s. c o m if (backendUserDb.getId() <= 3L) { throw new BusinessException(MainConstant.ERROR_USER_CANT_AMD); } backendUserDb.setVersion(backendUserDto.getVersion()); backendUserDb.setNickname(backendUserDto.getNickname()); backendUserDb.setEmail(backendUserDto.getEmail()); backendUserDb.setPhone(backendUserDto.getPhone()); //?? if (StringUtils.isNotEmpty(backendUserDto.getNewPwd())) { if (StringUtils.isEmpty(backendUserDto.getPwdConfirm()) || !backendUserDto.getNewPwd().equals(backendUserDto.getPwdConfirm())) { throw new BusinessException(MainConstant.ERROR_USER_NEW_PWD_NOT_MATCH); } if (StringUtils.isEmpty(backendUserDto.getOldPwd()) || !passwordEncoder.matches(backendUserDto.getOldPwd(), backendUserDb.getPassword())) { throw new BusinessException(MainConstant.ERROR_USER_OLD_PWD_NOT_MATCH); } backendUserDb.setPassword(passwordEncoder.encode(backendUserDto.getNewPwd())); } if (CollectionUtils.isNotEmpty(backendUserDto.getRoleIds())) { for (Iterator<Role> itDb = backendUserDb.getRoles().iterator(); itDb.hasNext();) { final Role roleDb = itDb.next(); //boolean existInPage = IterableUtils.matchesAny(backendUserDto.getRoleIds(), object -> roleDb.getId().equals(object)); Lambda ? boolean existInPage = IterableUtils.matchesAny(backendUserDto.getRoleIds(), new Predicate<Long>() { @Override public boolean evaluate(Long object) { return roleDb.getId().equals(object); } }); if (!existInPage) { itDb.remove(); } } backendUserDb.getRoles().addAll(roleDao.findAll(backendUserDto.getRoleIds())); } else { backendUserDb.getRoles().clear(); } backendUserDao.save(backendUserDb); }
From source file:com.haulmont.cuba.gui.data.impl.GroupDelegate.java
public boolean hasChildren(GroupInfo group) { boolean groupExists = containsGroup(group); List<GroupInfo> groupChildren = this.children.get(group); return groupExists && CollectionUtils.isNotEmpty(groupChildren); }
From source file:com.fredhopper.core.connector.index.upload.impl.RestPublishingStrategy.java
protected URI createUri(final String scheme, final String host, final Integer port, final String servername, final String path, final List<NameValuePair> params) { Preconditions.checkArgument(StringUtils.isNotBlank(scheme)); Preconditions.checkArgument(StringUtils.isNotBlank(host)); Preconditions.checkArgument(port != null); Preconditions.checkArgument(StringUtils.isNotBlank(servername)); Preconditions.checkArgument(StringUtils.isNotBlank(path)); final URIBuilder uriBuilder = new URIBuilder(); uriBuilder.setScheme(scheme);/*from w w w . jav a 2 s .c om*/ uriBuilder.setHost(host); uriBuilder.setPort(port.intValue()); uriBuilder.setPath("/".concat(servername).concat(path)); if (CollectionUtils.isNotEmpty(params)) { uriBuilder.setParameters(params); } try { return uriBuilder.build(); } catch (final URISyntaxException ex) { throw new IllegalArgumentException(ex); } }
From source file:jodtemplate.pptx.postprocessor.StylePostprocessor.java
private Element getApPrElement(final Element ap) { final List<Element> apPrElements = ap.getContent(Filters.element(PPTXDocument.PPR_ELEMENT, getNamespace())); if (CollectionUtils.isNotEmpty(apPrElements)) { return apPrElements.get(0).clone(); }/*from ww w .j av a2s . com*/ return null; }
From source file:io.cloudslang.lang.compiler.modeller.transformers.PythonActionTransformerTest.java
private Map<String, Serializable> transformAndThrowErrorIfExists( PythonActionTransformer pythonActionTransformer, Map<String, Serializable> rawData) { TransformModellingResult<Map<String, Serializable>> transformModellingResult = pythonActionTransformer .transform(rawData);//from www.j a va2s . com BasicTransformModellingResult<Map<String, Serializable>> basicTransformModellingResult = (BasicTransformModellingResult<Map<String, Serializable>>) transformModellingResult; List<RuntimeException> errors = basicTransformModellingResult.getErrors(); if (CollectionUtils.isNotEmpty(errors)) { throw errors.get(0); } else { return basicTransformModellingResult.getTransformedData(); } }
From source file:com.epam.catgenome.manager.reference.io.cytoband.CytobandReader.java
private void parse(final File file) throws IOException { try (BufferedReader reader = new BufferedReader( new InputStreamReader(IOHelper.openStream(file), Charset.defaultCharset()))) { String row;//from w ww . ja v a2 s . c o m int lineNum = 1; // strict is TRUE means that parser should validate chromosome's name extracted from the given // input using the provided dictionary that specifies all valid names for chromosomes final boolean strict = CollectionUtils.isNotEmpty(chromosomes); while ((row = reader.readLine()) != null) { // get all columns that provides required data String[] columns = row.split(COLUMN_SEPARATOR); if (columns.length != Cols.NCOLS.index()) { throw new IllegalArgumentException( MessageHelper.getMessage("error.cytobands.unexpected.row.cols", lineNum)); } // validates name for a chromosome and specifies a record to handle its band; if // it's necessary a new record will be created and added to the result final String chromosome = getText(columns, Cols.CHROM); if (strict && !chromosomes.contains(chromosome)) { throw new IllegalArgumentException( MessageHelper.getMessage("error.cytobands.illegal.chromosome", chromosome, lineNum)); } CytobandRecord record = records.get(chromosome); if (record == null) { record = new CytobandRecord(chromosome); records.put(chromosome, record); } // parses other columns and fills in information about a band final Cytoband band = new Cytoband(); band.setChromosome(chromosome); band.setName(getText(columns, Cols.BAND_NAME)); band.setGiemsaStain(getGiemsaStain(columns)); band.setEndIndex(getInt(columns, Cols.END_INDEX, lineNum)); band.setStartIndex(getInt(columns, Cols.START_INDEX, lineNum)); record.getBands().add(band); lineNum++; } } }
From source file:com.haulmont.cuba.gui.xml.layout.loaders.AbstractTableLoader.java
protected void addDynamicAttributes(Table component, Datasource ds, List<Table.Column> availableColumns) { if (metadataTools.isPersistent(ds.getMetaClass())) { Set<CategoryAttribute> attributesToShow = dynamicAttributesGuiTools .getAttributesToShowOnTheScreen(ds.getMetaClass(), context.getFullFrameId(), component.getId()); if (CollectionUtils.isNotEmpty(attributesToShow)) { ds.setLoadDynamicAttributes(true); for (CategoryAttribute attribute : attributesToShow) { final MetaPropertyPath metaPropertyPath = DynamicAttributesUtils .getMetaPropertyPath(ds.getMetaClass(), attribute); Object columnWithSameId = IterableUtils.find(availableColumns, o -> o.getId().equals(metaPropertyPath)); if (columnWithSameId != null) { continue; }// www . j av a2s .c o m final Table.Column column = new Table.Column(metaPropertyPath); column.setCaption(LocaleHelper.isLocalizedValueDefined(attribute.getLocaleNames()) ? attribute.getLocaleName() : StringUtils.capitalize(attribute.getName())); if (attribute.getDataType().equals(PropertyType.STRING)) { column.setMaxTextLength(clientConfig.getDynamicAttributesTableColumnMaxTextLength()); } if (attribute.getDataType().equals(PropertyType.ENUMERATION)) { column.setFormatter(value -> LocaleHelper.getEnumLocalizedValue((String) value, attribute.getEnumerationLocales())); } component.addColumn(column); } } dynamicAttributesGuiTools.listenDynamicAttributesChanges(ds); } }
From source file:io.cloudslang.lang.compiler.modeller.DependenciesHelper.java
private Set<String> getSystemPropertiesFromInOutParam(List<? extends InOutParam> inOutParams) { Set<String> result = new HashSet<>(); if (inOutParams != null) { for (InOutParam inOutParam : inOutParams) { Set<String> systemPropertyDependencies = inOutParam.getSystemPropertyDependencies(); if (CollectionUtils.isNotEmpty(systemPropertyDependencies)) { result.addAll(systemPropertyDependencies); }/*from ww w. j av a2 s. c om*/ } } return result; }
From source file:com.jkoolcloud.tnt4j.streams.inputs.AbstractWsStream.java
@Override protected boolean isInputEnded() { boolean hasRunningSteps = true; Set<TriggerKey> triggerKeys = null; try {/*from w w w .jav a2 s. c o m*/ triggerKeys = scheduler.getTriggerKeys(null); } catch (SchedulerException exc) { } if (CollectionUtils.isNotEmpty(triggerKeys)) { for (TriggerKey tKey : triggerKeys) { try { Trigger t = scheduler.getTrigger(tKey); if (t.mayFireAgain()) { hasRunningSteps = false; break; } } catch (SchedulerException exc) { } } } return hasRunningSteps; }
From source file:io.ucoin.ucoinj.web.pages.home.HomePage.java
/** -- Internal methods -- */ protected void doSearch(AjaxRequestTarget target, final String searchQuery) { if (StringUtils.isBlank(searchQuery)) { resultListView.removeAll();//from ww w . j ava 2 s.co m resultListView.setVisibilityAllowed(false); resultParent.setVisible(false); } else { CurrencyIndexerService service = ServiceLocator.instance().getCurrencyIndexerService(); List<SearchResult> result = service.searchCurrenciesAsVO(searchQuery); if (CollectionUtils.isNotEmpty(result)) { resultListView.removeAll(); resultParent.setVisible(true); resultParent.modelChanged(); resultListView.setVisibilityAllowed(true); resultListView.setDefaultModelObject(result); resultListView.modelChanged(); } else { resultListView.removeAll(); resultListView.setVisibilityAllowed(false); resultParent.setVisible(false); } } // submit actual list after reordering form.process(null); target.add(resultParent); }