Add seed code from Open-O
[cli.git] / framework / src / main / java / org / onap / cli / fw / output / OnapCommandResultAttributeScope.java
1 /*
2  * Copyright 2017 Huawei Technologies Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.onap.cli.fw.output;
18
19 import org.onap.cli.fw.error.OnapCommandInvalidResultAttributeScope;
20
21 /**
22  * Onap command supports to print output with given set of defined attributes, and each attributes are marked with this
23  * visibility.
24  *
25  */
26 public enum OnapCommandResultAttributeScope {
27     /**
28      * By default, all output attributes which are tagged with short would be printed.
29      */
30     SHORT,
31     /**
32      * When user provides --long or -l, all attributes including short tagged will be printed. otherwise, attributes
33      * tagged with long, whould be ignored as part of output
34      */
35     LONG;
36
37     /**
38      * get attribute scope enum type.
39      *
40      * @param name
41      *            scope
42      * @return type
43      * @throws OnapCommandInvalidResultAttributeScope
44      *             exception
45      */
46     public static OnapCommandResultAttributeScope get(String name) throws OnapCommandInvalidResultAttributeScope {
47         if (LONG.name().equalsIgnoreCase(name)) {
48             return LONG;
49         } else if (SHORT.name().equalsIgnoreCase(name)) {
50             return SHORT;
51         }
52
53         throw new OnapCommandInvalidResultAttributeScope(name);
54     }
55 }