JUnit/SONAR/Checkstyle in ONAP-REST
[policy/engine.git] / ONAP-REST / src / main / java / org / onap / policy / rest / jpa / PipType.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP-REST
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * Modifications Copyright (C) 2019 Nordix Foundation.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.rest.jpa;
23
24 import java.io.Serializable;
25 import java.util.Set;
26
27 import javax.persistence.Column;
28 import javax.persistence.Entity;
29 import javax.persistence.GeneratedValue;
30 import javax.persistence.GenerationType;
31 import javax.persistence.Id;
32 import javax.persistence.NamedQuery;
33 import javax.persistence.OneToMany;
34 import javax.persistence.Table;
35 import javax.persistence.Transient;
36
37 import lombok.Getter;
38 import lombok.NoArgsConstructor;
39 import lombok.Setter;
40
41 /**
42  * The persistent class for the PipType database table.
43  *
44  */
45 @Entity
46 @Table(name = "PipType")
47 @NamedQuery(name = "PipType.findAll", query = "SELECT p FROM PipType p")
48 @Getter
49 @Setter
50 @NoArgsConstructor
51 public class PipType implements Serializable {
52     private static final long serialVersionUID = 1L;
53
54     public static final String TYPE_SQL = "SQL";
55     public static final String TYPE_LDAP = "LDAP";
56     public static final String TYPE_CSV = "CSV";
57     public static final String TYPE_HYPERCSV = "Hyper-CSV";
58     public static final String TYPE_CUSTOM = "Custom";
59
60     @Id
61     @GeneratedValue(strategy = GenerationType.AUTO)
62     @Column(name = "id")
63     private int id;
64
65     @Column(name = "type", nullable = false, length = 45)
66     private String type;
67
68     // bi-directional many-to-one association to PipConfiguration
69     @OneToMany(mappedBy = "piptype")
70     private Set<PipConfiguration> pipconfigurations;
71
72     /**
73      * Adds the pipconfiguration.
74      *
75      * @param pipconfiguration the pipconfiguration
76      * @return the PIP configuration
77      */
78     public PipConfiguration addPipconfiguration(PipConfiguration pipconfiguration) {
79         getPipconfigurations().add(pipconfiguration);
80         pipconfiguration.setPiptype(this);
81
82         return pipconfiguration;
83     }
84
85     /**
86      * Removes the pipconfiguration.
87      *
88      * @param pipconfiguration the pipconfiguration
89      * @return the PIP configuration
90      */
91     public PipConfiguration removePipconfiguration(PipConfiguration pipconfiguration) {
92         getPipconfigurations().remove(pipconfiguration);
93         pipconfiguration.setPiptype(null);
94
95         return pipconfiguration;
96     }
97
98     /**
99      * Checks if is sql.
100      *
101      * @return true, if is sql
102      */
103     @Transient
104     public boolean isSql() {
105         return this.type.equals(TYPE_SQL);
106     }
107
108     /**
109      * Checks if is ldap.
110      *
111      * @return true, if is ldap
112      */
113     @Transient
114     public boolean isLdap() {
115         return this.type.equals(TYPE_LDAP);
116     }
117
118     /**
119      * Checks if is csv.
120      *
121      * @return true, if is csv
122      */
123     @Transient
124     public boolean isCsv() {
125         return this.type.equals(TYPE_CSV);
126     }
127
128     /**
129      * Checks if is hyper CSV.
130      *
131      * @return true, if is hyper CSV
132      */
133     @Transient
134     public boolean isHyperCsv() {
135         return this.type.equals(TYPE_HYPERCSV);
136     }
137
138     /**
139      * Checks if is custom.
140      *
141      * @return true, if is custom
142      */
143     @Transient
144     public boolean isCustom() {
145         return this.type.equals(TYPE_CUSTOM);
146     }
147
148 }