use of org.opendaylight.yangtools.yang.common.QName in project controller by opendaylight.
the class TestModel method createAugmentedListEntry.
public static MapEntryNode createAugmentedListEntry(final int id, final String name) {
Set<QName> childAugmentations = new HashSet<>();
childAugmentations.add(AUG_CONT_QNAME);
ContainerNode augCont = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(AUG_CONT_QNAME)).withChild(ImmutableNodes.leafNode(AUG_NAME_QNAME, name)).build();
final YangInstanceIdentifier.AugmentationIdentifier augmentationIdentifier = new YangInstanceIdentifier.AugmentationIdentifier(childAugmentations);
final AugmentationNode augmentationNode = Builders.augmentationBuilder().withNodeIdentifier(augmentationIdentifier).withChild(augCont).build();
return ImmutableMapEntryNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifierWithPredicates(AUGMENTED_LIST_QNAME, ID_QNAME, id)).withChild(ImmutableNodes.leafNode(ID_QNAME, id)).withChild(augmentationNode).build();
}
use of org.opendaylight.yangtools.yang.common.QName in project controller by opendaylight.
the class ServiceRegistryWrapper method getMappedServices.
public Map<String, Map<String, Map<String, String>>> getMappedServices() {
Map<String, Map<String, Map<String, String>>> retVal = new HashMap<>();
Map<String, Map<String, ObjectName>> serviceMapping = configServiceRefRegistry.getServiceMapping();
for (Map.Entry<String, Map<String, ObjectName>> nameToRefEntry : serviceMapping.entrySet()) {
for (String refName : nameToRefEntry.getValue().keySet()) {
ObjectName on = nameToRefEntry.getValue().get(refName);
Services.ServiceInstance si = Services.ServiceInstance.fromObjectName(on);
QName qname = QName.create(nameToRefEntry.getKey());
String namespace = qname.getNamespace().toString();
Map<String, Map<String, String>> serviceToRefs = retVal.computeIfAbsent(namespace, k -> new HashMap<>());
String localName = qname.getLocalName();
Map<String, String> refsToSis = serviceToRefs.computeIfAbsent(localName, k -> new HashMap<>());
Preconditions.checkState(!refsToSis.containsKey(refName), "Duplicate reference name %s for service %s:%s, now for instance %s", refName, namespace, localName, on);
refsToSis.put(refName, si.toString());
}
}
return retVal;
}
use of org.opendaylight.yangtools.yang.common.QName in project controller by opendaylight.
the class BindingDOMNotificationListenerAdapter method onNotification.
@Override
public void onNotification(@Nonnull final DOMNotification notification) {
final Notification baNotification = deserialize(notification);
final QName notificationQName = notification.getType().getLastComponent();
getInvoker(notification.getType()).invokeNotification(delegate, notificationQName, baNotification);
}
use of org.opendaylight.yangtools.yang.common.QName in project controller by opendaylight.
the class BindingDOMNotificationListenerAdapter method getNotificationTypes.
private static Set<SchemaPath> getNotificationTypes(final Class<? extends NotificationListener> type) {
// TODO: Investigate possibility and performance impact if we cache this or expose
// it from NotificationListenerInvoker
final Set<SchemaPath> ret = new HashSet<>();
for (final Method method : type.getMethods()) {
if (BindingReflections.isNotificationCallback(method)) {
final Class<?> notification = method.getParameterTypes()[0];
final QName name = BindingReflections.findQName(notification);
ret.add(SchemaPath.create(true, name));
}
}
return ret;
}
use of org.opendaylight.yangtools.yang.common.QName in project controller by opendaylight.
the class CompositeModel method createTestContainer.
public static ContainerNode createTestContainer() {
final LeafSetEntryNode<Object> nike = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeWithValue<>(QName.create(TEST_QNAME, "shoe"), "nike")).withValue("nike").build();
final LeafSetEntryNode<Object> puma = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeWithValue<>(QName.create(TEST_QNAME, "shoe"), "puma")).withValue("puma").build();
final LeafSetNode<Object> shoes = ImmutableLeafSetNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(TEST_QNAME, "shoe"))).withChild(nike).withChild(puma).build();
final LeafSetEntryNode<Object> five = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeWithValue<>(QName.create(TEST_QNAME, "number"), 5)).withValue(5).build();
final LeafSetEntryNode<Object> fifteen = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeWithValue<>(QName.create(TEST_QNAME, "number"), 15)).withValue(15).build();
final LeafSetNode<Object> numbers = ImmutableLeafSetNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(TEST_QNAME, "number"))).withChild(five).withChild(fifteen).build();
Set<QName> childAugmentations = new HashSet<>();
childAugmentations.add(AUG_QNAME);
final YangInstanceIdentifier.AugmentationIdentifier augmentationIdentifier = new YangInstanceIdentifier.AugmentationIdentifier(childAugmentations);
final AugmentationNode augmentationNode = Builders.augmentationBuilder().withNodeIdentifier(augmentationIdentifier).withChild(ImmutableNodes.leafNode(AUG_QNAME, "First Test")).build();
return ImmutableContainerNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME)).withChild(ImmutableNodes.leafNode(DESC_QNAME, DESC)).withChild(augmentationNode).withChild(shoes).withChild(numbers).withChild(mapNodeBuilder(OUTER_LIST_QNAME).withChild(mapEntry(OUTER_LIST_QNAME, ID_QNAME, ONE_ID)).withChild(BAR_NODE).build()).build();
}
Aggregations