2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.policy.models.pap.concepts;
23 import com.google.gson.annotations.SerializedName;
24 import io.swagger.annotations.ApiModelProperty;
25 import lombok.NonNull;
26 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
27 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
30 * Policy identifier with an optional version; only the "name" is required.
32 * <p>Note that there are deliberately no setters or getters on this class, it is use purely for GSON serialization and
35 public class PapPolicyIdentifier {
37 @ApiModelProperty(name = "policy-id")
38 @SerializedName("policy-id")
41 @ApiModelProperty(name = "policy-version")
42 @SerializedName("policy-version")
43 private String version;
45 public PapPolicyIdentifier(final String name, final String version) {
47 this.version = version;
50 public PapPolicyIdentifier(@NonNull final ToscaConceptIdentifier identifier) {
51 this(identifier.getName(), identifier.getVersion());
54 public PapPolicyIdentifier(@NonNull final ToscaConceptIdentifierOptVersion identifier) {
55 this(identifier.getName(), identifier.getVersion());
58 public ToscaConceptIdentifierOptVersion getGenericIdentifier() {
59 return name == null ? new ToscaConceptIdentifierOptVersion()
60 : new ToscaConceptIdentifierOptVersion(name, version);