当前位置: 首页>>代码示例>>Java>>正文


Java CollectionUtils类代码示例

本文整理汇总了Java中org.apache.commons.collections.CollectionUtils的典型用法代码示例。如果您正苦于以下问题:Java CollectionUtils类的具体用法?Java CollectionUtils怎么用?Java CollectionUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CollectionUtils类属于org.apache.commons.collections包,在下文中一共展示了CollectionUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getLoginUserMenuList

import org.apache.commons.collections.CollectionUtils; //导入依赖的package包/类
/**
 * 获取当前登录者所能看见的菜单集合
 * @param request
 * @param response
 * @return
 */
@ResponseBody
@RequestMapping(value="/login/user/menus", method=GET, produces=APPLICATION_JSON)
public Object getLoginUserMenuList(HttpServletRequest request, HttpServletResponse response) {
	List<Map<String,Object>> dataList = new ArrayList<Map<String,Object>>();
	try {
		List<AdminResource> userMenuResources = new ArrayList<AdminResource>();
		AdminUserRealm realm = ShiroUtils.getRealm(AdminUserRealm.class);
		AuthorizationInfo authInfo = realm.getAuthorizationInfo(SecurityUtils.getSubject().getPrincipals());
		if(authInfo instanceof CustomAuthorizationInfo){
			CustomAuthorizationInfo<AdminResource> authorizationInfo = (CustomAuthorizationInfo<AdminResource>) authInfo;
			Set<AdminResource> userResources = authorizationInfo.getResources();
			if(!CollectionUtils.isEmpty(userResources)){
				for(AdminResource resource : userResources){
					if(AdminResourceActionTypeEnum.ADMIN_RESOURCE_ACTION_TYPE_MENU.getTypeCode().equals(resource.getActionType())){
						userMenuResources.add(resource);
					}
				}
				dataList = resourceTreeBuilder.buildObjectTree(GlobalConstants.DEFAULT_ADMIN_ROOT_RESOURCE_ID, userMenuResources, resourceNavMenuNodeConverter);
			}
		}
	} catch (Exception e) {
		logger.error(e.getMessage(), e);
	}
	return dataList;
}
 
开发者ID:penggle,项目名称:xproject,代码行数:32,代码来源:AdminController.java

示例2: 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;
}
 
开发者ID:xuxueli,项目名称:xxl-api,代码行数:20,代码来源:XxlApiDocumentController.java

示例3: invokeConfigItemPostProcessors

import org.apache.commons.collections.CollectionUtils; //导入依赖的package包/类
/**
 * 调用所有的{@link ConfigItemPostProcessor}进行配置项预处理
 *
 * @param versionPropertySource
 */
private void invokeConfigItemPostProcessors(VersionPropertySource<ConfigItemList> versionPropertySource) {
    if (versionPropertySource == null) {
        return;
    }
    List<ConfigItemPostProcessor> configItemPostProcessors = this.configItemPostProcessors;
    if (CollectionUtils.isEmpty(configItemPostProcessors)) {
        return;
    }

    long version = versionPropertySource.getVersion();
    EnumerablePropertySource<?> propertySource = versionPropertySource.getSource();
    if (propertySource == null) {
        return;
    }
    if (!(propertySource instanceof ConfigPropertySource)) {
        return;
    }

    ConfigPropertySource configPropertySource = (ConfigPropertySource) propertySource;

    for (ConfigItemPostProcessor postProcessor : configItemPostProcessors) {
        postProcessor.postProcessConfigItems(version, configPropertySource);
    }
}
 
开发者ID:zouzhirong,项目名称:configx,代码行数:30,代码来源:ConfigContext.java

示例4: testGetTopLevelKeys

import org.apache.commons.collections.CollectionUtils; //导入依赖的package包/类
@Test
public void testGetTopLevelKeys() {
	List<String> expected = Lists.newArrayList("value1", "value2");

	IData idata = IDataFactory.create();
	IDataCursor cursor = idata.getCursor();
	IDataUtil.put(cursor, "value1", "something");
	IDataUtil.put(cursor, "value2", "another one");
	cursor.destroy();

	Document document = docFactory.wrap(idata);
	CollectionUtils.isEqualCollection(expected, document.getKeys());
}
 
开发者ID:innodev-au,项目名称:wmboost-data,代码行数:14,代码来源:DocumentTest.java

示例5: testSelects

import org.apache.commons.collections.CollectionUtils; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testSelects() {
    Record r = new Record();
    r.setUserIdentityARN("arn:sample");
    List<Record> records = Arrays.asList(r, new Record());
    Collection<Record> sample = CollectionUtils.select(records, new Predicate() {
        @Override
        public boolean evaluate(Object o) {
            return o instanceof Record && ((Record) o).getUserIdentityARN() != null &&  ((Record) o).getUserIdentityARN().contains("sample");
        }
    });

    Assertions.assertThat(sample).hasSize(1);
}
 
开发者ID:riboseinc,项目名称:aws-codecommit-trigger-plugin,代码行数:16,代码来源:StringUtilsTest.java

示例6: isDefined

import org.apache.commons.collections.CollectionUtils; //导入依赖的package包/类
/**
 * 判断对象是不是定义了 <br>
 * List的话,不为NULL和空<br>
 * 字符串的的话,不为NULL或空<br>
 * Integer的话,不为NULL或0<br>
 * 
 * @param obj
 *            要判断的对象
 * @return 是否定义了
 */
public static boolean isDefined(Object obj) {
    if (obj instanceof Collection) {
        return CollectionUtils.isNotEmpty((Collection<?>) obj);
    }

    if (obj instanceof Map) {
        return MapUtils.isNotEmpty((Map<?, ?>) obj);
    }

    if (obj instanceof String) {
        return StringUtils.isNotEmpty((String) obj);
    }

    if (obj instanceof Integer) {
        return obj != null && (Integer) obj != 0;
    }

    return obj != null;
}
 
开发者ID:Chihpin,项目名称:Yidu,代码行数:30,代码来源:Utils.java

示例7: batchRemove

import org.apache.commons.collections.CollectionUtils; //导入依赖的package包/类
/**
 * 批量删除补偿事务信息
 *
 * @param ids             ids 事务id集合
 * @param applicationName 应用名称
 * @return true 成功
 */
@Override
public Boolean batchRemove(List<String> ids, String applicationName) {
    if (CollectionUtils.isEmpty(ids) || StringUtils.isBlank(applicationName)) {
        return Boolean.FALSE;
    }

    final String rootPath = RepositoryPathUtils.buildZookeeperPath(applicationName);
    ids.stream().map(id -> {
        try {
            final String path = buildRootPath(rootPath, id);
            byte[] content = zooKeeper.getData(path,
                    false, new Stat());
            final TransactionRecoverAdapter adapter = objectSerializer.deSerialize(content, TransactionRecoverAdapter.class);
            zooKeeper.delete(path, adapter.getVersion());
            return 1;
        } catch (Exception e) {
            e.printStackTrace();
            return -1;
        }

    }).count();

    return Boolean.TRUE;
}
 
开发者ID:yu199195,项目名称:happylifeplat-transaction,代码行数:32,代码来源:ZookeeperRecoverTransactionServiceImpl.java

示例8: 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;
}
 
开发者ID:brucezee,项目名称:jspider,代码行数:8,代码来源:RandomProxyStrategy.java

示例9: getFullPieceMd5s

import org.apache.commons.collections.CollectionUtils; //导入依赖的package包/类
private List<String> getFullPieceMd5s(Task task, FileMetaData metaData) {
    List<String> pieceMd5s = taskService.getFullPieceMd5sByTask(task);
    if (CollectionUtils.isEmpty(pieceMd5s)) {
        pieceMd5s = fileMetaDataService.readPieceMd5(task.getTaskId(), metaData.getRealMd5());
    }
    return pieceMd5s;
}
 
开发者ID:alibaba,项目名称:Dragonfly,代码行数:8,代码来源:CacheDetectorImpl.java

示例10: determineLifecycleStatus

import org.apache.commons.collections.CollectionUtils; //导入依赖的package包/类
public ProcessingLifecycleStatus determineLifecycleStatus(RawLines rawLines) {
    ProcessingLifecycleStatus status = ProcessingLifecycleStatus.UNKNOWN;
    List<List<RawWord>> lines = rawLines.getRawLines();

    if(CollectionUtils.isEmpty(lines)) {
        return status;
    }

    for(List<RawWord> line : lines) {
        if(status != ProcessingLifecycleStatus.UNKNOWN) {
            break;
        }

        for(RawWord word : line) {
            if(word.getWord().contains("Forgot") || word.getWord().contains("Password")) {
                status = ProcessingLifecycleStatus.LOGIN_READY;
                break;
            } else if(word.getWord().contains("Welcome")) {
                status = ProcessingLifecycleStatus.APPLICATION_READY;
                break;
            } else if(word.getWord().contains("Trade")) {
                status = ProcessingLifecycleStatus.TRADE_PARTNER;
            } else if(word.getWord().contains("SOFTWARE")) {
                status = ProcessingLifecycleStatus.ACCEPT_TOS_EULA_READY;
            }
        }
    }

    return status;
}
 
开发者ID:corydissinger,项目名称:mtgo-best-bot,代码行数:31,代码来源:RawLinesProcessor.java

示例11: getExecutable

import org.apache.commons.collections.CollectionUtils; //导入依赖的package包/类
private String getExecutable() {
    File supposedExecutable = new File(executableDir + executableName);

    if(supposedExecutable.exists()) {
        return supposedExecutable.getAbsolutePath();
    } else {
        Collection<File> theExecutable = FileUtils.listFiles(new File(executableDir), new WildcardFileFilter(executableName), TrueFileFilter.INSTANCE);

        if(theExecutable != null || theExecutable.size() > 1 || theExecutable.isEmpty()) {
            File newestExecutable = theExecutable.stream().reduce(new File(""),
                    (aFile, newestFile) -> {
                        if(aFile.lastModified() > newestFile.lastModified()) {
                            return aFile;
                        }

                        return newestFile;
                    });

            return newestExecutable.getAbsolutePath();
        } else if(theExecutable.size() == 1) {
            return ((File)CollectionUtils.get(theExecutable, 0)).getAbsolutePath();
        } else {
            throw new RuntimeException("Could not determine executable path");
        }
    }
}
 
开发者ID:corydissinger,项目名称:mtgo-best-bot,代码行数:27,代码来源:ProcessManager.java

示例12: getRollbackCandidates

import org.apache.commons.collections.CollectionUtils; //导入依赖的package包/类
public List<MigrationTask> getRollbackCandidates(List<MigrationTask> allMigrationTasks, int[] rollbackLevels, PatchInfoStore currentPatchInfoStore) throws MigrationException
{
    validateRollbackLevel(rollbackLevels);

    int rollbackLevel = rollbackLevels[0];
    int currentPatchLevel = currentPatchInfoStore.getPatchLevel();

    if (currentPatchLevel < rollbackLevel)
    {
        throw new MigrationException(
                "The rollback patch level cannot be greater than the current patch level");
    }

    PatchRollbackPredicate rollbackPredicate = new PatchRollbackPredicate(currentPatchLevel,
            rollbackLevel);
    List<MigrationTask> migrationCandidates = new ArrayList<MigrationTask>();
    migrationCandidates.addAll(allMigrationTasks);
    CollectionUtils.filter(migrationCandidates, rollbackPredicate);
    Collections.sort(migrationCandidates);
    // need to reverse the list do we apply the rollbacks in descending
    // order
    Collections.reverse(migrationCandidates);
    return migrationCandidates;

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:OrderedMigrationRunnerStrategy.java

示例13: 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);
        }
    }
}
 
开发者ID:m18507308080,项目名称:bohemia,代码行数:8,代码来源:CachesManager.java

示例14: assertExistTenants

import org.apache.commons.collections.CollectionUtils; //导入依赖的package包/类
private void assertExistTenants(Set<TenantState> tenantKeys) {
    if (CollectionUtils.isEmpty(tenantKeys)) {
        final String error = "Tenant list for " + applicationName + " empty. Check tenants-list.json.";
        log.error(error);
        throw new IllegalStateException(error);
    }
}
 
开发者ID:xm-online,项目名称:xm-commons,代码行数:8,代码来源:TenantListRepository.java

示例15: 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;
}
 
开发者ID:alibaba,项目名称:Dragonfly,代码行数:16,代码来源:PeerTaskServiceImpl.java


注:本文中的org.apache.commons.collections.CollectionUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。