Fixed the Sonar technical debt.
[policy/engine.git] / ONAP-REST / src / main / java / org / onap / policy / rest / jpa / PIPConfigParam.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP-REST
4  * ================================================================================
5  * Copyright (C) 2017 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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.onap.policy.rest.jpa;
22
23 import java.io.Serializable;
24
25 import javax.persistence.*;
26
27
28 /**
29  * The persistent class for the PIPConfigParams database table.
30  * 
31  */
32 @Entity
33 @Table(name="PIPConfigParams")
34 @NamedQuery(name="PIPConfigParam.findAll", query="SELECT p FROM PIPConfigParam p")
35 public class PIPConfigParam implements Serializable {
36         private static final long serialVersionUID = 1L;
37
38         @Id
39         @GeneratedValue(strategy=GenerationType.AUTO)
40         @Column(name="id")
41         private int id;
42
43         @Column(name="PARAM_NAME", nullable=false, length=1024)
44         private String paramName;
45
46         @Column(name="PARAM_VALUE", nullable=false, length=2048)
47         private String paramValue;
48
49         @Column(name="PARAM_DEFAULT", nullable=true, length=2048)
50         private String paramDefault = null;
51         
52         @Column(name="REQUIRED", nullable=false)
53         private char required = '0';
54
55         //bi-directional many-to-one association to PIPConfiguration
56         @ManyToOne
57         @JoinColumn(name="PIP_ID")
58         private PIPConfiguration pipconfiguration;
59
60         public PIPConfigParam() {
61                 //An empty constructor
62         }
63
64         public PIPConfigParam(String param) {
65                 this.paramName = param;
66         }
67
68         public PIPConfigParam(String param, String value) {
69                 this(param);
70                 this.paramValue = value;
71         }
72
73         public PIPConfigParam(PIPConfigParam param) {
74                 this(param.getParamName(), param.getParamValue());
75                 this.paramDefault = param.getParamDefault();
76                 this.required = param.required;
77         }
78
79         public int getId() {
80                 return this.id;
81         }
82
83         public void setId(int id) {
84                 this.id = id;
85         }
86
87         public String getParamName() {
88                 return this.paramName;
89         }
90
91         public void setParamName(String paramName) {
92                 this.paramName = paramName;
93         }
94
95         public String getParamValue() {
96                 return this.paramValue;
97         }
98
99         public void setParamValue(String paramValue) {
100                 this.paramValue = paramValue;
101         }
102
103         public String getParamDefault() {
104                 return paramDefault;
105         }
106
107         public void setParamDefault(String paramDefault) {
108                 this.paramDefault = paramDefault;
109         }
110
111         public char getRequired() {
112                 return required;
113         }
114
115         public void setRequired(char required) {
116                 this.required = required;
117         }
118
119         public PIPConfiguration getPipconfiguration() {
120                 return this.pipconfiguration;
121         }
122
123         public void setPipconfiguration(PIPConfiguration pipconfiguration) {
124                 this.pipconfiguration = pipconfiguration;
125         }
126
127         @Transient
128         public boolean isRequired() {
129                 return this.required == '1';
130         }
131         
132         @Transient
133         public void setRequired(boolean required) {
134                 if (required) {
135                         this.setRequired('1');
136                 } else {
137                         this.setRequired('0');
138                 }
139         }
140
141         @Transient
142         @Override
143         public String toString() {
144                 return "PIPConfigParam [id=" + id + ", paramName=" + paramName
145                                 + ", paramValue=" + paramValue + ", required=" + required + "]";
146         }
147
148 }