8dec7915a249517ef2c71fbd9facc846eb93873f
[policy/engine.git] / ONAP-REST / src / main / java / org / onap / policy / rest / jpa / PIPResolverParam.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 PIPResolverParams database table.
30  * 
31  */
32 @Entity
33 @Table(name="PIPResolverParams")
34 @NamedQuery(name="PIPResolverParam.findAll", query="SELECT p FROM PIPResolverParam p")
35 public class PIPResolverParam 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;
51                 
52         @Column(name="REQUIRED", nullable=false)
53         private char required = '0';
54
55         //bi-directional many-to-one association to PIPResolver
56         @ManyToOne
57         @JoinColumn(name="ID_RESOLVER")
58         private PIPResolver pipresolver;
59
60         public PIPResolverParam() {
61         }
62
63         public PIPResolverParam(String name) {
64                 this.paramName = name;
65         }
66
67         public PIPResolverParam(String name, String value) {
68                 this(name);
69                 this.paramValue = value;
70         }
71
72         public PIPResolverParam(PIPResolverParam param) {
73                 this(param.getParamName(), param.getParamValue());
74                 this.paramDefault = param.getParamDefault();
75                 this.required = param.required;
76         }
77
78         public int getId() {
79                 return this.id;
80         }
81
82         public void setId(int id) {
83                 this.id = id;
84         }
85
86         public String getParamName() {
87                 return this.paramName;
88         }
89
90         public void setParamName(String paramName) {
91                 this.paramName = paramName;
92         }
93
94         public String getParamValue() {
95                 return this.paramValue;
96         }
97
98         public void setParamValue(String paramValue) {
99                 this.paramValue = paramValue;
100         }
101
102         public String getParamDefault() {
103                 return paramDefault;
104         }
105
106         public void setParamDefault(String paramDefault) {
107                 this.paramDefault = paramDefault;
108         }
109
110         public char getRequired() {
111                 return required;
112         }
113
114         public void setRequired(char required) {
115                 this.required = required;
116         }
117
118         public PIPResolver getPipresolver() {
119                 return this.pipresolver;
120         }
121
122         public void setPipresolver(PIPResolver pipresolver) {
123                 this.pipresolver = pipresolver;
124         }
125
126         @Transient
127         public boolean isRequired() {
128                 return this.required == '1';
129         }
130         
131         @Transient
132         public void setRequired(boolean required) {
133                 if (required) {
134                         this.required = '1';
135                 } else {
136                         this.required = '0';
137                 }
138         }
139
140         @Transient
141         @Override
142         public String toString() {
143                 return "PIPResolverParam [id=" + id + ", paramName=" + paramName
144                                 + ", paramValue=" + paramValue + ", required=" + required + "]";
145         }
146
147 }