2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6 * ===========================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END====================================================
22 package org.onap.aaf.auth.cmd;
24 import java.util.ArrayList;
25 import java.util.List;
27 import org.onap.aaf.cadi.CadiException;
28 import org.onap.aaf.cadi.LocatorException;
29 import org.onap.aaf.misc.env.APIException;
32 public class BaseCmd<CMD extends Cmd> extends Cmd {
33 protected List<Cmd> cmds;
35 public BaseCmd(AAFcli aafcli, String name, Param ... params) {
36 super(aafcli, null, name, params);
37 cmds = new ArrayList<>();
40 public BaseCmd(CMD parent, String name, Param ... params) {
41 super(parent.aafcli, parent, name, params);
42 cmds = new ArrayList<>();
47 public int _exec( int idx, final String ... args) throws CadiException, APIException, LocatorException {
48 if (args.length-idx<1) {
49 pw().println(build(new StringBuilder(),null).toString());
56 if (name==null && empty==null) { // Mark with Command is null, and take the first one.
58 } else if (s.equalsIgnoreCase(c.getName()))
59 return c.exec(idx+1, args);
62 return empty.exec(idx, args); // If name is null, don't account for it on command line. Jonathan 4-29
64 pw().println("Instructions not understood.");