Fix checkstyle
[genius.git] / itm / itm-impl / src / main / java / org / opendaylight / genius / 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.genius.itm.cli;
10
11 import com.google.common.base.Preconditions;
12 import java.math.BigInteger;
13 import java.util.ArrayList;
14 import java.util.List;
15 import org.apache.commons.lang3.StringUtils;
16
17 /**
18  * The Utility class for ITM CLI.
19  */
20 public final class ItmCliUtils {
21     private ItmCliUtils() {
22
23     }
24
25     /**
26      * Construct dpn id list.
27      *
28      * @param dpnIds
29      *            the dpn ids
30      * @return the list
31      */
32     public static List<BigInteger> constructDpnIdList(final String dpnIds) {
33         final List<BigInteger> lstDpnIds = new ArrayList<>();
34         if (StringUtils.isNotBlank(dpnIds)) {
35             final String[] arrDpnIds = StringUtils.split(dpnIds, ',');
36             for (String dpn : arrDpnIds) {
37                 String trimmedDpn = StringUtils.trim(dpn);
38                 Preconditions.checkArgument(StringUtils.isNumeric(trimmedDpn),
39                     "DPN ID [" + dpn + "] is not a numeric value.");
40                 lstDpnIds.add(new BigInteger(trimmedDpn));
41             }
42         }
43         return lstDpnIds;
44     }
45 }