Remove redundant type specifiers
[openflowplugin.git] / applications / notification-supplier / src / main / java / org / opendaylight / openflowplugin / applications / notification / supplier / impl / item / stat / MeterStatNotificationSupplierImpl.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.stat;
9
10 import com.google.common.base.Preconditions;
11 import java.util.Collections;
12 import org.opendaylight.mdsal.binding.api.DataBroker;
13 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
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.meter.statistics.rev131111.MeterStatisticsUpdated;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterStatisticsUpdatedBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterStatistics;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.nodes.node.meter.MeterStatistics;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsBuilder;
21 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
22
23 /**
24  * Implementation define a contract between {@link MeterStatistics} data object
25  * and {@link MeterStatisticsUpdated} notification.
26  */
27 public class MeterStatNotificationSupplierImpl extends AbstractNotificationSupplierForItemStat<MeterStatistics,
28         MeterStatisticsUpdated> {
29
30     private static final InstanceIdentifier<MeterStatistics> METER_STATISTICS_INSTANCE_IDENTIFIER = getNodeWildII()
31             .augmentation(FlowCapableNode.class).child(Meter.class).augmentation(NodeMeterStatistics.class)
32             .child(MeterStatistics.class);
33
34     /**
35      * Constructor register supplier as DataTreeChangeListener and create wildCarded InstanceIdentifier.
36      *
37      * @param notifProviderService - {@link NotificationPublishService}
38      * @param db                   - {@link DataBroker}
39      */
40     public MeterStatNotificationSupplierImpl(final NotificationPublishService notifProviderService,
41                                              final DataBroker db) {
42         super(notifProviderService, db, MeterStatistics.class);
43     }
44
45     @Override
46     public InstanceIdentifier<MeterStatistics> getWildCardPath() {
47         return METER_STATISTICS_INSTANCE_IDENTIFIER;
48     }
49
50     @Override
51     public MeterStatisticsUpdated createNotification(final MeterStatistics meterStatistics,
52                                                      final InstanceIdentifier<MeterStatistics> path) {
53         Preconditions.checkArgument(meterStatistics != null);
54         Preconditions.checkArgument(path != null);
55
56         final MeterStatisticsUpdatedBuilder builder = new MeterStatisticsUpdatedBuilder();
57         builder.setId(getNodeId(path));
58         builder.setMoreReplies(Boolean.FALSE);
59         // TODO : fix if it needs, but we have to ask DataStore for the NodeConnector list
60         builder.setNodeConnector(Collections.emptyList());
61         builder.setMeterStats(Collections.singletonList(new MeterStatsBuilder(meterStatistics).build()));
62         return builder.build();
63     }
64 }
65