for (Entry<String, Object> capability : capabilitiesObj.entrySet()) {
EventType eventType = EventType.valueOf(capability.getKey());
List<Context> contexts = CollectionUtils.newArrayList();
DBObject capabilityObj = (DBObject) capability.getValue();
DBObject contextsObj = (DBObject) capabilityObj.get(CAPABILITY_CONTEXTS_FIELD);
for (String contextId : contextsObj.keySet()) {
contexts.add(Context.valueOf((String) contextsObj.get(contextId)));
}
String filter = (String) capabilityObj.get(CAPABILITY_FILTER_FIELD);
capabilities.put(eventType, new Capability(eventType, contexts, filter));