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.item;
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.FlowCapableNode;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterAdded;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterAddedBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterRemoved;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterRemovedBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterUpdated;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterUpdatedBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterRef;
24 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
27 * Implementation define a contract between {@link Meter} data object
28 * and {@link MeterAdded}, {@link MeterUpdated} and {@link MeterRemoved} notifications.
30 public class MeterNotificationSupplierImpl extends
31 AbstractNotificationSupplierForItem<Meter, MeterAdded, MeterUpdated, MeterRemoved> {
33 private static final InstanceIdentifier<Meter> wildCardedInstanceIdent = getNodeWildII().augmentation(FlowCapableNode.class).child(Meter.class);
36 * Constructor register supplier as DataChangeLister and create wildCarded InstanceIdentifier.
38 * @param notifProviderService - {@link NotificationProviderService}
39 * @param db - {@link DataBroker}
41 public MeterNotificationSupplierImpl(final NotificationProviderService notifProviderService, final DataBroker db) {
42 super(notifProviderService, db, Meter.class);
46 public InstanceIdentifier<Meter> getWildCardPath() {
47 return wildCardedInstanceIdent;
51 public MeterAdded createNotification(final Meter o, final InstanceIdentifier<Meter> path) {
52 Preconditions.checkArgument(o != null);
53 Preconditions.checkArgument(path != null);
54 final MeterAddedBuilder builder = new MeterAddedBuilder(o);
55 builder.setMeterRef(new MeterRef(path));
56 builder.setNode(createNodeRef(path));
57 return builder.build();
61 public MeterUpdated updateNotification(final Meter o, final InstanceIdentifier<Meter> path) {
62 Preconditions.checkArgument(o != null);
63 Preconditions.checkArgument(path != null);
64 final MeterUpdatedBuilder builder = new MeterUpdatedBuilder(o);
65 builder.setMeterRef(new MeterRef(path));
66 builder.setNode(createNodeRef(path));
67 return builder.build();
71 public MeterRemoved deleteNotification(final InstanceIdentifier<Meter> path) {
72 Preconditions.checkArgument(path != null);
73 final MeterRemovedBuilder builder = new MeterRemovedBuilder();
74 builder.setMeterId(path.firstKeyOf(Meter.class, MeterKey.class).getMeterId());
75 builder.setMeterRef(new MeterRef(path));
76 builder.setNode(createNodeRef(path));
77 return builder.build();