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
8 package org.opendaylight.openflowplugin.applications.notification.supplier.impl;
10 import com.google.common.base.Preconditions;
11 import org.opendaylight.mdsal.binding.api.DataBroker;
12 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorUpdated;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorUpdatedBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemovedBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdatedBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
22 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
25 * Implementation define a contract between {@link FlowCapableNodeConnector} data object
26 * and {@link NodeConnectorUpdated} and {@link NodeConnectorRemoved} notifications.
28 public class NodeConnectorNotificationSupplierImpl extends
29 AbstractNotificationSupplierForItemRoot<FlowCapableNodeConnector, NodeConnectorUpdated, NodeConnectorRemoved> {
31 private static final InstanceIdentifier<FlowCapableNodeConnector> FLOW_CAPABLE_NODE_CONNECTOR_INSTANCE_IDENTIFIER
32 = getNodeWildII().child(NodeConnector.class).augmentation(FlowCapableNodeConnector.class);
35 * Constructor register supplier as DataTreeChangeListener and create wildCarded InstanceIdentifier.
37 * @param notifProviderService - {@link NotificationPublishService}
38 * @param db - {@link DataBroker}
40 public NodeConnectorNotificationSupplierImpl(final NotificationPublishService notifProviderService,
41 final DataBroker db) {
42 super(notifProviderService, db, FlowCapableNodeConnector.class);
46 public InstanceIdentifier<FlowCapableNodeConnector> getWildCardPath() {
47 return FLOW_CAPABLE_NODE_CONNECTOR_INSTANCE_IDENTIFIER;
51 public NodeConnectorUpdated createNotification(final FlowCapableNodeConnector flowCapableNodeConnector,
52 final InstanceIdentifier<FlowCapableNodeConnector> path) {
53 Preconditions.checkArgument(flowCapableNodeConnector != null);
54 Preconditions.checkArgument(path != null);
55 final NodeConnectorUpdatedBuilder notifBuilder = new NodeConnectorUpdatedBuilder();
56 final FlowCapableNodeConnectorUpdatedBuilder connNotifBuilder = new FlowCapableNodeConnectorUpdatedBuilder(
57 flowCapableNodeConnector);
58 notifBuilder.setId(path.firstKeyOf(NodeConnector.class).getId());
59 notifBuilder.setNodeConnectorRef(new NodeConnectorRef(path));
60 notifBuilder.addAugmentation(FlowCapableNodeConnectorUpdated.class, connNotifBuilder.build());
61 return notifBuilder.build();
65 public NodeConnectorRemoved deleteNotification(final InstanceIdentifier<FlowCapableNodeConnector> path) {
66 Preconditions.checkArgument(path != null);
67 final NodeConnectorRemovedBuilder notifBuilder = new NodeConnectorRemovedBuilder();
68 notifBuilder.setNodeConnectorRef(new NodeConnectorRef(path));
69 return notifBuilder.build();