2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
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.tosca.authorative.concepts;
23 import com.google.gson.annotations.SerializedName;
25 import lombok.NoArgsConstructor;
26 import lombok.NonNull;
27 import org.apache.commons.lang3.ObjectUtils;
30 * Policy identifier with an optional version; only the "name" is required.
34 public class ToscaPolicyIdentifierOptVersion implements Comparable<ToscaPolicyIdentifierOptVersion> {
37 @SerializedName("policy-id")
40 @SerializedName("policy-version")
41 private String version;
44 public ToscaPolicyIdentifierOptVersion(@NonNull String name, String version) {
46 this.version = version;
49 public ToscaPolicyIdentifierOptVersion(ToscaPolicyIdentifierOptVersion source) {
50 this.name = source.name;
51 this.version = source.version;
55 * Determines if the version is null/missing.
57 * @return {@code true} if the version is null/missing, {@code false}
59 public boolean isNullVersion() {
60 return (version == null);
64 public int compareTo(ToscaPolicyIdentifierOptVersion other) {
73 int result = ObjectUtils.compare(getName(), other.getName());
78 return ObjectUtils.compare(getVersion(), other.getVersion());