本文整理汇总了Java中org.apache.commons.collections.CollectionUtils.subtract方法的典型用法代码示例。如果您正苦于以下问题:Java CollectionUtils.subtract方法的具体用法?Java CollectionUtils.subtract怎么用?Java CollectionUtils.subtract使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.collections.CollectionUtils
的用法示例。
在下文中一共展示了CollectionUtils.subtract方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import org.apache.commons.collections.CollectionUtils; //导入方法依赖的package包/类
@Override
public void process(WatchedEvent event) throws Exception {
String topicParentPath = zkConf.getZKBasePath() + "/topics";
LOG.info("get zookeeper notification for path={}", topicParentPath);
if (event.getType() == Watcher.Event.EventType.NodeChildrenChanged) {
List<String> newTopics = zkClient.getChildren().forPath(topicParentPath);
List<String> oldTopics = metadata.getAllTopics();
Collection<String> addedTopics = CollectionUtils.subtract(newTopics, oldTopics);
Collection<String> deletedTopics = CollectionUtils.subtract(oldTopics, newTopics);
for (String topic : addedTopics) {
String topicPath = topicParentPath + "/" + topic;
zkClient.getChildren()
.usingWatcher(new TopicWatcher(topic))
.forPath(topicPath);
Map<Integer, Integer> queueMap = readTopicInfo(topic);
metadata.updateTopicMap(topic, queueMap);
}
metadata.removeTopics(deletedTopics);
}
zkClient.getChildren()
.usingWatcher(new TopicsWather())
.forPath(topicParentPath);
}
示例2: getNotSkippedTasks
import org.apache.commons.collections.CollectionUtils; //导入方法依赖的package包/类
private Collection<String> getNotSkippedTasks() {
List all = getExecutedTasks();
Set skipped = getSkippedTasks();
return CollectionUtils.subtract(all, skipped);
}
示例3: getSymmetricDifference
import org.apache.commons.collections.CollectionUtils; //导入方法依赖的package包/类
/**
* Returns a pair consisting of two collections: set1 - set2, and set2-set1.
*/
public static Pair getSymmetricDifference(Set set1, Set set2) {
Collection old = CollectionUtils.subtract(set1, set2);
Collection newP = CollectionUtils.subtract(set2, set1);
return new Pair(old, newP);
}