本文整理汇总了Java中org.apache.commons.collections.CollectionUtils.isNotEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java CollectionUtils.isNotEmpty方法的具体用法?Java CollectionUtils.isNotEmpty怎么用?Java CollectionUtils.isNotEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.collections.CollectionUtils
的用法示例。
在下文中一共展示了CollectionUtils.isNotEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: delete
import org.apache.commons.collections.CollectionUtils; //导入方法依赖的package包/类
@RequestMapping("/delete")
@ResponseBody
public ReturnT<String> delete(int id) {
// 存在Test记录,拒绝删除
List<XxlApiTestHistory> historyList = xxlApiTestHistoryDao.loadByDocumentId(id);
if (CollectionUtils.isNotEmpty(historyList)) {
return new ReturnT<String>(ReturnT.FAIL_CODE, "拒绝删除,该接口下存在Test记录,不允许删除");
}
// 存在Mock记录,拒绝删除
List<XxlApiMock> mockList = xxlApiMockDao.loadAll(id);
if (CollectionUtils.isNotEmpty(mockList)) {
return new ReturnT<String>(ReturnT.FAIL_CODE, "拒绝删除,该接口下存在Mock记录,不允许删除");
}
int ret = xxlApiDocumentDao.delete(id);
return (ret>0)?ReturnT.SUCCESS:ReturnT.FAIL;
}
示例2: getLoad
import org.apache.commons.collections.CollectionUtils; //导入方法依赖的package包/类
private float getLoad(Map<String, List<Integer>> fieldIndex, String[] fields, String key) {
float maxValue = -1.0f;
int fieldsLen = fields.length;
List<Integer> indexs = fieldIndex.get(key);
if (CollectionUtils.isNotEmpty(indexs)) {
if (Collections.max(indexs) < fieldsLen) {
for (Integer index : indexs) {
String value = fields[index];
if (StringUtils.isNotBlank(value) && value.matches("\\d+\\.?\\d*")) {
maxValue = maxValue >= Float.parseFloat(value) ? maxValue : Float.parseFloat(value);
}
}
}
}
return maxValue;
}
示例3: dashboardInfo
import org.apache.commons.collections.CollectionUtils; //导入方法依赖的package包/类
@Override
public Map<String, Object> dashboardInfo() {
int jobInfoCount = xxlJobInfoDao.findAllCount();
int jobLogCount = xxlJobLogDao.triggerCountByHandleCode(-1);
int jobLogSuccessCount = xxlJobLogDao.triggerCountByHandleCode(ReturnT.SUCCESS_CODE);
// executor count
Set<String> executerAddressSet = new HashSet<String>();
List<XxlJobGroup> groupList = xxlJobGroupDao.findAll();
if (CollectionUtils.isNotEmpty(groupList)) {
for (XxlJobGroup group: groupList) {
List<String> registryList = null;
if (group.getAddressType() == 0) {
registryList = JobRegistryMonitorHelper.discover(RegistryConfig.RegistType.EXECUTOR.name(), group.getAppName());
} else {
if (StringUtils.isNotBlank(group.getAddressList())) {
registryList = Arrays.asList(group.getAddressList().split(","));
}
}
if (CollectionUtils.isNotEmpty(registryList)) {
executerAddressSet.addAll(registryList);
}
}
}
int executorCount = executerAddressSet.size();
Map<String, Object> dashboardMap = new HashMap<String, Object>();
dashboardMap.put("jobInfoCount", jobInfoCount);
dashboardMap.put("jobLogCount", jobLogCount);
dashboardMap.put("jobLogSuccessCount", jobLogSuccessCount);
dashboardMap.put("executorCount", executorCount);
return dashboardMap;
}
示例4: processCacheByQuick
import org.apache.commons.collections.CollectionUtils; //导入方法依赖的package包/类
private boolean processCacheByQuick(Task task, int breakNum, CacheResult cacheResult,
FileMetaData metaData) throws IOException {
List<String> pieceMd5s;
if (breakNum == -1) {
if (StringUtils.isNotBlank(metaData.getRealMd5())) {
pieceMd5s = getFullPieceMd5s(task, metaData);
Long fileLen = metaData.getFileLength();
if (CollectionUtils.isNotEmpty(pieceMd5s)) {
reportCache(task, fileLen, metaData.getRealMd5(), pieceMd5s);
cacheResult.setStartPieceNum(breakNum);
return true;
}
}
}
return false;
}
示例5: visit
import org.apache.commons.collections.CollectionUtils; //导入方法依赖的package包/类
@Override
public void visit(Partner item) {
if (StringUtils.isBlank(item.getId())) {
getValidationState().pushError(ValidationState.ErrorType.PartnerIdMissing);
}
if (item.getProperties().size() < 1) {
getValidationState().pushError(ValidationState.ErrorType.PartnerPropertiesMissing);
}
// validate that we are not deleting partner which is used in some of the rules
Collection<IfExpression> rules = getValidationState().getRules();
if (CollectionUtils.isNotEmpty(rules)) {
StringBuilder errorMsg = new StringBuilder("Partner is used in ");
boolean hasError = false;
for (IfExpression rule : rules) {
// only last IfExpression of a rule contains return.
// if current IfExpression has another (nested) IfExpression there is no sense
// to try to validate current return statement (it's null).
// It's somewhere deeper in nested IfExpression...
IfExpression lastIfExpression = getLastIfExpressionFromRule(rule);
for (Expressions partnerIdValue : lastIfExpression.getReturn()) {
if (item.getId().equals(((Value) partnerIdValue).getValue())) {
errorMsg.append(rule.getId()).append(", ");
hasError = true;
break;
}
}
}
if (hasError) {
errorMsg.deleteCharAt(errorMsg.lastIndexOf(","));
errorMsg.append("rule(s).");
getValidationState().pushError(ValidationState.ErrorType.PartnerIsInUse, errorMsg.toString());
}
}
}
示例6: setCaches
import org.apache.commons.collections.CollectionUtils; //导入方法依赖的package包/类
public void setCaches(Collection<Cache> caches) {
if (CollectionUtils.isNotEmpty(caches)) {
for (Cache cache : caches) {
this.caches.put(cache.getName(), cache);
}
}
}
示例7: listForSaleByPage
import org.apache.commons.collections.CollectionUtils; //导入方法依赖的package包/类
@Override
@Transactional(readOnly = true)
public Page<EstateItemDTO> listForSaleByPage(Pageable pageable, Map<String, Object> paramMap) throws Exception {
String cacheKey = CacheKeyGenerator.generate(EstateItemDTO.class, "listForSaleByPage", pageable, paramMap);
Page<EstateItemDTO> targetItemPage = new PageX();
// 读取缓存数据
targetItemPage = byteRedisClient.getByteObj(cacheKey, targetItemPage.getClass());
if (targetItemPage != null && CollectionUtils.isNotEmpty(targetItemPage.getContent())) {
return new PageX(targetItemPage.getContent(), pageable, targetItemPage.getTotalElements());
} else {
Page<EstateItemModel> sourceItemPage = estateItemRepository.findAll(EstateItemSpecification.getForSaleSpec(paramMap), pageable);
List<EstateItemModel> sourceItemList = sourceItemPage.getContent();
if (CollectionUtils.isNotEmpty(sourceItemList)) {
List<EstateItemDTO> targetItemList = new ArrayList();
for (EstateItemModel model : sourceItemList) {
EstateItemDTO dto = new EstateItemDTO();
CachedBeanCopier.copy(model, dto);
if (StringUtils.isBlank(dto.getCoverUrl())) dto.setCoverUrl("/3rd-party/porto/img/blank.jpg");
dto.setDetailHref("/estate/" + dto.getHouseCode() + ".shtml");
dto.setTotalPriceStr(dto.getTotalPrice() + "万");
dto.setUnitPriceStr("单价" + dto.getUnitPrice() + "万");
dto.setDownPayments(dto.getUnitPriceStr() + ", 首付" + BigDecimal.valueOf(0.3d).multiply(dto.getTotalPrice()).setScale(2, BigDecimal.ROUND_HALF_DOWN) + "万");
dto.setAreaStr(dto.getArea() + "平米");
dto.setFocusNumStr(dto.getFocusNum() + "人关注");
dto.setWatchNumStr(dto.getWatchNum() + "次带看");
dto.setNewEstate(dto.getUpdateTime().isAfter(TimeUtil.nowDateTime().minusDays(3))); // 是当前日期三天前发布的
targetItemList.add(dto);
}
targetItemPage = new PageX(targetItemList, pageable, sourceItemPage.getTotalElements());
// 数据写入缓存
byteRedisClient.setByteObj(cacheKey, targetItemPage, 3600);
}
return targetItemPage;
}
}
示例8: whereIn
import org.apache.commons.collections.CollectionUtils; //导入方法依赖的package包/类
/**
* Add a "where aaa in (x, y, z)" clause. Skipped if the collection is null or empty.
* The collection is converted to a comma-separated strings.
* <b>NOTE:</b> It is always better to use collections as a parameter, like "aaa in :someCollection"
* @param attributeName attribute or column name
* @param values a list of values (e.g. integers)
*/
public YadaSql whereIn(String attributeName, Collection values) {
if (CollectionUtils.isNotEmpty(values)) {
String valueListString = StringUtils.join(values, ',');
where(attributeName + " in ("+valueListString+")");
}
return this;
}
示例9: deleteTemplateRule
import org.apache.commons.collections.CollectionUtils; //导入方法依赖的package包/类
@Override
public OperationResult deleteTemplateRule(String appName, String ruleId) {
final OperationContextHolder.OperationContext currentContext = OperationContextHolder.getCurrentContext();
final PendingChangesStatus pendingChangesStatus = currentContext.getPendingChangesStatus();
SelectServer templates = currentContext.getTemplatePathRules();
Collection<IfExpression> flavorRules = currentContext.getFlavorRules().getItems();
boolean containsTemplates = (templates != null && CollectionUtils.isNotEmpty(templates.getItems()));
IfExpression current = containsTemplates ? templates.getRule(ruleId) : null;
flavorRules.addAll(PendingChangeStatusHelper.getPendingFlavorRules(pendingChangesStatus));
return deleteRule(appName, ruleId, current, flavorRules, ApplicationStatusMode.OFFLINE);
}
示例10: gc
import org.apache.commons.collections.CollectionUtils; //导入方法依赖的package包/类
@Override
public boolean gc(GcMeta gcMeta) {
boolean result = false;
if (gcMeta != null) {
List<String> cids = gcMeta.getCids();
String taskId = gcMeta.getTaskId();
if (CollectionUtils.isNotEmpty(cids) && taskId != null) {
for (String cid : cids) {
peerTaskRepo.remove(taskId, cid);
}
}
result = true;
}
return result;
}
示例11: coolNamedMethod
import org.apache.commons.collections.CollectionUtils; //导入方法依赖的package包/类
public Filter coolNamedMethod(Filter.OrFilter filter) {
final Set<Filter> filters = filter.getChildren().stream()
.map(f -> checkScopeValidity(f))
.filter(f -> Objects.nonNull(f))
.collect(Collectors.toSet());
if (filters.size() > 1) {
return Filter.OrFilter.fromSet(filters);
} else if (CollectionUtils.isNotEmpty(filters)){
return filters.iterator().next();
}
return null;
}
示例12: validateProperty
import org.apache.commons.collections.CollectionUtils; //导入方法依赖的package包/类
public static <T> ValidationResult validateProperty(T obj, String propertyName) {
ValidationResult result = new ValidationResult();
Set<ConstraintViolation<T>> set = validator.validateProperty(obj, propertyName, Default.class);
if (CollectionUtils.isNotEmpty(set)) {
result.setHasErrors(true);
Map<String, String> errorMsg = Maps.newHashMap();
for (ConstraintViolation<T> cv : set) {
errorMsg.put(propertyName, cv.getMessage());
}
result.setErrorMsg(errorMsg);
}
return result;
}
示例13: fillFileDataType
import org.apache.commons.collections.CollectionUtils; //导入方法依赖的package包/类
/**
* parse field of datatype (注意,循环引用问题;此处显示最长引用链路长度为5;)
*
* @param dataType
* @param maxRelateLevel
* @return
*/
private XxlApiDataType fillFileDataType(XxlApiDataType dataType, int maxRelateLevel){
// init field list
List<XxlApiDataTypeField> fieldList = xxlApiDataTypeFieldDao.findByParentDatatypeId(dataType.getId());
dataType.setFieldList(fieldList);
// parse field list
if (CollectionUtils.isNotEmpty(dataType.getFieldList()) && maxRelateLevel>0) {
for (XxlApiDataTypeField field: dataType.getFieldList()) {
XxlApiDataType fieldDataType = xxlApiDataTypeDao.load(field.getFieldDatatypeId());
fieldDataType = fillFileDataType(fieldDataType, --maxRelateLevel);
field.setFieldDatatype(fieldDataType);
}
}
return dataType;
}
示例14: getProxy
import org.apache.commons.collections.CollectionUtils; //导入方法依赖的package包/类
@Override
public HttpProxy getProxy(List<HttpProxy> httpProxies) {
if (CollectionUtils.isNotEmpty(httpProxies)) {
return httpProxies.get(new Random().nextInt(httpProxies.size()-1));
}
return null;
}
示例15: getProxy
import org.apache.commons.collections.CollectionUtils; //导入方法依赖的package包/类
@Override
public HttpProxy getProxy(List<HttpProxy> httpProxies) {
if (CollectionUtils.isNotEmpty(httpProxies)) {
return httpProxies.get(index.getAndIncrement() % httpProxies.size());
}
return null;
}