Remove annotations in models
[policy/models.git] / models-pap / src / main / java / org / onap / policy / models / pap / concepts / PapPolicyIdentifier.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP Policy Models
4  * ================================================================================
5  * Copyright (C) 2021 Nordix Foundation.
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.models.pap.concepts;
22
23 import com.google.gson.annotations.SerializedName;
24 import lombok.NonNull;
25 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
26 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
27
28 /**
29  * Policy identifier with an optional version; only the "name" is required.
30  *
31  * <p>Note that there are deliberately no setters or getters on this class, it is use purely for GSON serialization and
32  * deserializaiton
33  */
34 public class PapPolicyIdentifier {
35     @NonNull
36     @SerializedName("policy-id")
37     private String name;
38
39     @SerializedName("policy-version")
40     private String version;
41
42     public PapPolicyIdentifier(final String name, final String version) {
43         this.name = name;
44         this.version = version;
45     }
46
47     public PapPolicyIdentifier(@NonNull final ToscaConceptIdentifier identifier) {
48         this(identifier.getName(), identifier.getVersion());
49     }
50
51     public PapPolicyIdentifier(@NonNull final ToscaConceptIdentifierOptVersion identifier) {
52         this(identifier.getName(), identifier.getVersion());
53     }
54
55     public ToscaConceptIdentifierOptVersion getGenericIdentifier() {
56         return name == null ? new ToscaConceptIdentifierOptVersion()
57                 : new ToscaConceptIdentifierOptVersion(name, version);
58     }
59 }