Vxlan/Gre co-existence,Alarms,tunnelstate,TR fixes
[vpnservice.git] / itm / itm-impl / src / main / java / org / opendaylight / vpnservice / itm / cli / ItmCliUtils.java
1 /*
2  * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. 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
9 package org.opendaylight.vpnservice.itm.cli;
10
11 import java.math.BigInteger;
12 import java.util.ArrayList;
13 import java.util.List;
14
15 import org.apache.commons.lang3.StringUtils;
16
17 import com.google.common.base.Preconditions;
18
19 /**
20  * The Utility class for ITM CLI.
21  */
22 public final class ItmCliUtils {
23
24     /**
25      * Construct dpn id list.
26      *
27      * @param dpnIds
28      *            the dpn ids
29      * @return the list
30      */
31     public static List<BigInteger> constructDpnIdList(final String dpnIds) {
32         final List<BigInteger> lstDpnIds = new ArrayList<>();
33         if (StringUtils.isNotBlank(dpnIds)) {
34             final String[] arrDpnIds = StringUtils.split(dpnIds, ',');
35             for (String dpn : arrDpnIds) {
36                 if (StringUtils.isNumeric(StringUtils.trim(dpn))) {
37                     lstDpnIds.add(new BigInteger(StringUtils.trim(dpn)));
38                 } else {
39                     Preconditions.checkArgument(false, String.format("DPN ID [%s] is not a numeric value.", dpn));
40                 }
41             }
42         }
43         return lstDpnIds;
44     }
45 }