Move integration tests to mdsal-it-parent
[lispflowmapping.git] / mappingservice / implementation / src / main / java / org / opendaylight / lispflowmapping / implementation / util / MapNotifyBuilderHelper.java
1 /*
2  * Copyright (c) 2014 Contextream, 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.lispflowmapping.implementation.util;
9
10 import java.util.ArrayList;
11 import java.util.Arrays;
12
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.MapRegister;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.eidtolocatorrecords.EidToLocatorRecord;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.mapnotifymessage.MapNotifyBuilder;
16
17 public class MapNotifyBuilderHelper {
18
19     public static void setFromMapRegister(MapNotifyBuilder builder, MapRegister mapRegister) {
20         if (builder.getEidToLocatorRecord() == null) {
21             builder.setEidToLocatorRecord(new ArrayList<EidToLocatorRecord>());
22         }
23         builder.setNonce(mapRegister.getNonce());
24         builder.setKeyId(mapRegister.getKeyId());
25         byte[] authenticationData = mapRegister.getAuthenticationData();
26         if (authenticationData != null) {
27             authenticationData = authenticationData.clone();
28             Arrays.fill(authenticationData, (byte) 0);
29         }
30         builder.setAuthenticationData(authenticationData);
31
32         for (EidToLocatorRecord eidToLocator : mapRegister.getEidToLocatorRecord()) {
33             builder.getEidToLocatorRecord().add(eidToLocator);
34         }
35     }
36 }