本文整理匯總了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);
}