039427ca541bd3f6316d39df0c95d9c065b06143
[sdc/sdc-workflow-designer.git] /
1 /**
2  * Copyright (c) 2017 ZTE Corporation.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the Apache License, Version 2.0
5  * and the Eclipse Public License v1.0 which both accompany this distribution,
6  * and are available at http://www.eclipse.org/legal/epl-v10.html
7  * and http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Contributors:
10  *     ZTE - initial API and implementation and/or initial documentation
11  */
12 package org.onap.sdc.workflowdesigner.model;
13
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
16
17 import com.fasterxml.jackson.annotation.JsonInclude;
18 import com.fasterxml.jackson.annotation.JsonInclude.Include;
19 import com.fasterxml.jackson.core.JsonProcessingException;
20 import com.fasterxml.jackson.databind.ObjectMapper;
21
22 public class Parameter {
23     private static Logger log = LoggerFactory.getLogger(Parameter.class);
24     private String description = "";
25     private String name;
26     private String position;
27     private boolean required;
28     private String type;
29
30     // body parameter may be a json object
31     private Object value;
32
33     @JsonInclude(Include.NON_NULL)
34     private String valueSource;
35
36     public String getDescription() {
37         return description;
38     }
39
40     public void setDescription(String description) {
41         this.description = description;
42     }
43
44     public String getName() {
45         return name;
46     }
47
48     public void setName(String name) {
49         this.name = name;
50     }
51
52     public String getPosition() {
53         return position;
54     }
55
56     public void setPosition(String position) {
57         this.position = position;
58     }
59
60     public boolean isRequired() {
61         return required;
62     }
63
64     public void setRequired(boolean required) {
65         this.required = required;
66     }
67
68     public String getType() {
69         return type;
70     }
71
72     public void setType(String type) {
73         this.type = type;
74     }
75
76     public Object getValue() {
77         return value;
78     }
79
80     public void setValue(Object value) {
81         this.value = value;
82     }
83
84     public String getValueSource() {
85         return valueSource;
86     }
87
88     public void setValueSource(String valueSource) {
89         this.valueSource = valueSource;
90     }
91
92     public String toString() {
93         ObjectMapper mapper = new ObjectMapper();
94         String result = null;
95         try {
96             result = mapper.writeValueAsString(this);
97         } catch (JsonProcessingException e) {
98             log.error("fail to convert parameter to json string", e);
99         }
100         return result;
101     }
102
103 }