c00c88b192e5f79a0d8d3f958782409578836fe4
[cli.git] / framework / src / main / java / org / onap / cli / fw / output / OnapCommandResultAttribute.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 java.util.ArrayList;
20 import java.util.Arrays;
21 import java.util.List;
22
23 import org.onap.cli.fw.input.OnapCommandParameterType;
24
25 /**
26  * Oclip command output records, helps to define the title and its description while command is defined and during run
27  * time, it captures the value of the output as well.
28  */
29 public class OnapCommandResultAttribute {
30
31     /*
32      * Output name
33      */
34     private String outName;
35
36     /*
37      * Output description
38      */
39     private String outDescription;
40
41     /*
42      * Output values, in case list out, it holds values for all rows for show output, it will have one value
43      */
44     private List<String> values = new ArrayList<>();
45
46     /*
47      * default value, useful to set when a command want to set the default value for a output attributes.
48      */
49     private String defaultValue = "";
50
51     /*
52      * Output scope
53      */
54     private OnapCommandResultAttributeScope outScope = OnapCommandResultAttributeScope.SHORT;
55
56     private OnapCommandParameterType paramType = OnapCommandParameterType.STRING;
57
58     private boolean isSecured = false;
59
60     public void setValues(List<String> values) {
61         this.values = values;
62     }
63
64     public String getName() {
65         return outName;
66     }
67
68     public void setName(String name) {
69         this.outName = name;
70     }
71
72     public String getDescription() {
73         return outDescription;
74     }
75
76     public void setDescription(String description) {
77         this.outDescription = description;
78     }
79
80     public List<String> getValues() {
81         if (this.values.isEmpty() && !this.defaultValue.isEmpty()) {
82             return Arrays.asList(new String [] {this.defaultValue});
83         }
84         return values;
85     }
86
87     public OnapCommandResultAttributeScope getScope() {
88         return outScope;
89     }
90
91     public void setScope(OnapCommandResultAttributeScope scope) {
92         this.outScope = scope;
93     }
94
95     public OnapCommandParameterType getType() {
96         return paramType;
97     }
98
99     public void setType(OnapCommandParameterType type) {
100         this.paramType = type;
101     }
102
103     public boolean isSecured() {
104         return isSecured;
105     }
106
107     public void setSecured(boolean isSecured) {
108         this.isSecured = isSecured;
109     }
110
111     public String getDefaultValue() {
112         return defaultValue;
113     }
114
115     public void setDefaultValue(String defaultValue) {
116         this.defaultValue = defaultValue;
117     }
118
119 }