4118c4db3ff6fece7cb08a21850454795e95a33b
[policy/models.git] / models-tosca / src / main / java / org / onap / policy / models / tosca / simple / concepts / JpaToscaCapabilityType.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * Copyright (C) 2020 Nordix Foundation.
4  * Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
5  * ================================================================================
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * SPDX-License-Identifier: Apache-2.0
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.models.tosca.simple.concepts;
23
24 import javax.persistence.Entity;
25 import javax.persistence.Inheritance;
26 import javax.persistence.InheritanceType;
27 import javax.persistence.Table;
28 import lombok.Data;
29 import lombok.EqualsAndHashCode;
30 import lombok.NoArgsConstructor;
31 import lombok.NonNull;
32 import org.onap.policy.common.parameters.BeanValidationResult;
33 import org.onap.policy.models.base.PfConceptKey;
34 import org.onap.policy.models.tosca.authorative.concepts.ToscaCapabilityType;
35
36 /**
37  * Class to represent the capability type in TOSCA definition.
38  */
39
40 @Entity
41 @Table(name = "ToscaCapabilityType")
42 @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
43 @Data
44 @EqualsAndHashCode(callSuper = true)
45 @NoArgsConstructor
46 public class JpaToscaCapabilityType extends JpaToscaWithToscaProperties<ToscaCapabilityType> {
47     private static final long serialVersionUID = -563659852901842616L;
48
49     /**
50      * The Key Constructor creates a {@link JpaToscaCapabilityType} object with the given concept key.
51      *
52      * @param key the key
53      */
54     public JpaToscaCapabilityType(@NonNull final PfConceptKey key) {
55         super(key);
56     }
57
58     /**
59      * Copy constructor.
60      *
61      * @param copyConcept the concept to copy from
62      */
63     public JpaToscaCapabilityType(final JpaToscaCapabilityType copyConcept) {
64         super(copyConcept);
65     }
66
67     /**
68      * Authorative constructor.
69      *
70      * @param authorativeConcept the authorative concept to copy from
71      */
72     public JpaToscaCapabilityType(final ToscaCapabilityType authorativeConcept) {
73         super(authorativeConcept);
74     }
75
76     @Override
77     public ToscaCapabilityType toAuthorative() {
78         super.setToscaEntity(new ToscaCapabilityType());
79         return super.toAuthorative();
80     }
81
82     @Override
83     public BeanValidationResult validate(@NonNull String fieldName) {
84         return validateWithKey(fieldName);
85     }
86 }