本文整理汇总了Java中org.springframework.util.CollectionUtils.containsAny方法的典型用法代码示例。如果您正苦于以下问题:Java CollectionUtils.containsAny方法的具体用法?Java CollectionUtils.containsAny怎么用?Java CollectionUtils.containsAny使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.util.CollectionUtils
的用法示例。
在下文中一共展示了CollectionUtils.containsAny方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: canStart
import org.springframework.util.CollectionUtils; //导入方法依赖的package包/类
private boolean canStart(Channel channel) {
// 判断机器节点是否有存活的通路
// 查询一下最新的存活的node列表,可能channel取出来的数据为cache的结果
List<Long> liveNodes = nodeEvent.liveNodes();
for (Pipeline pipeline : channel.getPipelines()) {
// 判断select
List<Long> nids = getNids(pipeline.getSelectNodes());
if (!CollectionUtils.containsAny(liveNodes, nids)) {
logger.error("current live nodes:{} , but select nids:{} , result:{}", new Object[] { liveNodes, nids,
CollectionUtils.containsAny(liveNodes, nids) });
sendWarningMessage(pipeline.getId(), "can't restart by no select live node");
return false;
}
// 判断extract
nids = getNids(pipeline.getExtractNodes());
if (!CollectionUtils.containsAny(liveNodes, nids)) {
logger.error("current live nodes:{} , but extract nids:{} , result:{}", new Object[] { liveNodes, nids,
CollectionUtils.containsAny(liveNodes, nids) });
sendWarningMessage(pipeline.getId(), "can't restart by no extract live node");
return false;
}
// 判断transform/load
nids = getNids(pipeline.getLoadNodes());
if (!CollectionUtils.containsAny(liveNodes, nids)) {
logger.error("current live nodes:{} , but transform nids:{} , result:{}", new Object[] { liveNodes,
nids, CollectionUtils.containsAny(liveNodes, nids) });
sendWarningMessage(pipeline.getId(), "can't restart by no transform live node");
return false;
}
// 判断当前没有未清理的process
List<ProcessStat> stats = arbitrateViewService.listProcesses(channel.getId(), pipeline.getId());
if (!stats.isEmpty() && !status(channel.getId()).isStart()) {
List<Long> processIds = new ArrayList<Long>();
for (ProcessStat stat : stats) {
processIds.add(stat.getProcessId());
}
sendWarningMessage(pipeline.getId(),
"can't restart by exist process[" + StringUtils.join(processIds, ',') + "]");
return false;
}
}
return true;
}
示例2: hasCurrentRole
import org.springframework.util.CollectionUtils; //导入方法依赖的package包/类
/**
* Controlla se l'utente attuale possiede almeno un ruolo tra quelli specificati. Case Sensitive!
* @param roleToCheck array di ruoli nel formato senza ROLE_ iniziale
* @return
*/
public boolean hasCurrentRole(String[] rolesToCheck) {
Set<String> currentRoles = getCurrentRoles();
Set<String> requiredRoles = new HashSet<String>(Arrays.asList(rolesToCheck));
return CollectionUtils.containsAny(currentRoles, requiredRoles);
}
示例3: matchesRole
import org.springframework.util.CollectionUtils; //导入方法依赖的package包/类
public boolean matchesRole(Collection<String> userRoles) {
if (roles.contains("*") || userRoles.contains("*")) {
return true;
}
return CollectionUtils.containsAny(roles, userRoles);
}