2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowplugin.applications.notification.supplier.impl;
11 import com.google.common.base.Preconditions;
12 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
13 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorUpdated;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorUpdatedBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemovedBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdatedBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
23 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
26 * Implementation define a contract between {@link FlowCapableNodeConnector} data object
27 * and {@link NodeConnectorUpdated} and {@link NodeConnectorRemoved} notifications.
29 public class NodeConnectorNotificationSupplierImpl extends
30 AbstractNotificationSupplierForItemRoot<FlowCapableNodeConnector, NodeConnectorUpdated, NodeConnectorRemoved> {
32 private static final InstanceIdentifier<FlowCapableNodeConnector> FLOW_CAPABLE_NODE_CONNECTOR_INSTANCE_IDENTIFIER
33 = getNodeWildII().child(NodeConnector.class).augmentation(FlowCapableNodeConnector.class);
36 * Constructor register supplier as DataTreeChangeListener and create wildCarded InstanceIdentifier.
38 * @param notifProviderService - {@link NotificationProviderService}
39 * @param db - {@link DataBroker}
41 public NodeConnectorNotificationSupplierImpl(final NotificationProviderService notifProviderService,
42 final DataBroker db) {
43 super(notifProviderService, db, FlowCapableNodeConnector.class);
47 public InstanceIdentifier<FlowCapableNodeConnector> getWildCardPath() {
48 return FLOW_CAPABLE_NODE_CONNECTOR_INSTANCE_IDENTIFIER;
52 public NodeConnectorUpdated createNotification(final FlowCapableNodeConnector flowCapableNodeConnector,
53 final InstanceIdentifier<FlowCapableNodeConnector> path) {
54 Preconditions.checkArgument(flowCapableNodeConnector != null);
55 Preconditions.checkArgument(path != null);
56 final NodeConnectorUpdatedBuilder notifBuilder = new NodeConnectorUpdatedBuilder();
57 final FlowCapableNodeConnectorUpdatedBuilder connNotifBuilder = new FlowCapableNodeConnectorUpdatedBuilder(
58 flowCapableNodeConnector);
59 notifBuilder.setId(path.firstKeyOf(NodeConnector.class).getId());
60 notifBuilder.setNodeConnectorRef(new NodeConnectorRef(path));
61 notifBuilder.addAugmentation(FlowCapableNodeConnectorUpdated.class, connNotifBuilder.build());
62 return notifBuilder.build();
66 public NodeConnectorRemoved deleteNotification(final InstanceIdentifier<FlowCapableNodeConnector> path) {
67 Preconditions.checkArgument(path != null);
68 final NodeConnectorRemovedBuilder notifBuilder = new NodeConnectorRemovedBuilder();
69 notifBuilder.setNodeConnectorRef(new NodeConnectorRef(path));
70 return notifBuilder.build();