Fixed the Sonar technical debt.
[policy/engine.git] / ONAP-REST / src / main / java / org / onap / policy / rest / jpa / FunctionArgument.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 FunctionArguments database table.
30  * 
31  */
32 @Entity
33 @Table(name="FunctionArguments")
34 @NamedQuery(name="FunctionArgument.findAll", query="SELECT f FROM FunctionArgument f")
35 public class FunctionArgument 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="is_bag", nullable=false)
44         private int isBag;
45
46         //bi-directional many-to-one association to FunctionDefinition
47         @ManyToOne
48         @JoinColumn(name="function_id")
49         private FunctionDefinition functionDefinition;
50
51         @Column(name="arg_index", nullable=false)
52         private int argIndex;
53
54         //bi-directional many-to-one association to Datatype
55         @ManyToOne
56         @JoinColumn(name="datatype_id")
57         private Datatype datatypeBean;
58
59         public FunctionArgument() {
60                 //An empty constructor
61         }
62
63         public FunctionArgument(final FunctionArgument argument) {
64                 this.argIndex = argument.argIndex;
65                 this.datatypeBean = argument.datatypeBean;
66                 this.isBag = argument.isBag;
67                 this.functionDefinition = argument.functionDefinition;
68         }
69
70         public int getId() {
71                 return this.id;
72         }
73
74         public void setId(int id) {
75                 this.id = id;
76         }
77
78         public int getArgIndex() {
79                 return this.argIndex;
80         }
81
82         public void setArgIndex(int argIndex) {
83                 this.argIndex = argIndex;
84         }
85
86         public Datatype getDatatypeBean() {
87                 return this.datatypeBean;
88         }
89
90         public void setDatatypeBean(Datatype datatypeBean) {
91                 this.datatypeBean = datatypeBean;
92         }
93
94         public FunctionDefinition getFunctionDefinition() {
95                 return this.functionDefinition;
96         }
97
98         public int getIsBag() {
99                 return isBag;
100         }
101
102         public void setIsBag(int isBag) {
103                 this.isBag = isBag;
104         }
105
106         public void setFunctionDefinition(FunctionDefinition functionDefinition) {
107                 this.functionDefinition = functionDefinition;
108         }
109
110         @Transient
111         @Override
112         public String toString() {
113                 return "FunctionArgument [id=" + id + ", argIndex=" + argIndex
114                                 + ", datatypeBean=" + datatypeBean + ", isBag=" + isBag
115                                 + ", functionDefinition=" + functionDefinition + "]";
116         }
117         
118         @Transient
119         public boolean isBag() {
120                 return this.isBag == 1;
121         }
122
123 }