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 lombok.NonNull;
25 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
26 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
29 * Policy identifier with an optional version; only the "name" is required.
31 * <p>Note that there are deliberately no setters or getters on this class, it is use purely for GSON serialization and
34 public class PapPolicyIdentifier {
36 @SerializedName("policy-id")
39 @SerializedName("policy-version")
40 private String version;
42 public PapPolicyIdentifier(final String name, final String version) {
44 this.version = version;
47 public PapPolicyIdentifier(@NonNull final ToscaConceptIdentifier identifier) {
48 this(identifier.getName(), identifier.getVersion());
51 public PapPolicyIdentifier(@NonNull final ToscaConceptIdentifierOptVersion identifier) {
52 this(identifier.getName(), identifier.getVersion());
55 public ToscaConceptIdentifierOptVersion getGenericIdentifier() {
56 return name == null ? new ToscaConceptIdentifierOptVersion()
57 : new ToscaConceptIdentifierOptVersion(name, version);