2 * Copyright (c) 2015 Cisco Systems, Inc. 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.lispflowmapping.implementation.util;
11 import java.util.ArrayList;
12 import java.util.List;
14 import org.opendaylight.lispflowmapping.interfaces.dao.Subscriber;
15 import org.opendaylight.lispflowmapping.lisp.type.MappingData;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingChange;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingChanged;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingChangedBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.changed.SubscriberItem;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.changed.SubscriberItemBuilder;
24 * Utility class to convert a mapping change into a notification.
26 * @author Florin Coras
29 public final class MSNotificationInputUtil {
30 // Utility class, should not be instantiated
31 private MSNotificationInputUtil() {
34 public static MappingChanged toMappingChanged(Mapping input, MappingChange change) {
35 return new MappingChangedBuilder().setMappingRecord(input.getMappingRecord())
36 .setChangeType(change).build();
39 public static MappingChanged toMappingChanged(MappingData mapping, Set<Subscriber> subscribers,
40 MappingChange change) {
41 List<SubscriberItem> subscriberList = new ArrayList<SubscriberItem>();
42 for (Subscriber subscriber : subscribers) {
43 subscriberList.add(new SubscriberItemBuilder().setSubscriberData(
44 subscriber.getSubscriberData()).build());
46 return new MappingChangedBuilder().setMappingRecord(mapping.getRecord()).setSubscriberItem(subscriberList)
47 .setChangeType(change).build();