Enable SpotBugs enforcement in yang-validation-tool
[yangtools.git] / yang-validation-tool / src / main / java / org / opendaylight / yangtools / yang / validation / tool / ParamsUtil.java
1 /*
2  * Copyright (c) 2014 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.yangtools.yang.validation.tool;
9
10 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
11 import net.sourceforge.argparse4j.inf.ArgumentParser;
12 import net.sourceforge.argparse4j.inf.ArgumentParserException;
13
14 final class ParamsUtil {
15     private ParamsUtil() {
16
17     }
18
19     @SuppressFBWarnings(value = "DM_EXIT", justification = "We do expect to terminate the JVM")
20     static Params parseArgs(final String[] args, final ArgumentParser parser) {
21         final Params params = new Params();
22         try {
23             parser.parseArgs(args, params);
24             return params;
25         } catch (final ArgumentParserException e) {
26             parser.handleError(e);
27         }
28         System.exit(1);
29         return null;
30     }
31 }