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;
24 import lombok.NoArgsConstructor;
25 import lombok.NonNull;
26 import org.apache.commons.lang3.ObjectUtils;
27 import org.onap.policy.common.parameters.BeanValidationResult;
28 import org.onap.policy.common.parameters.ValidationResult;
31 * Identifies a policy. Both the name and version must be non-null.
35 public class ToscaPolicyIdentifier implements Comparable<ToscaPolicyIdentifier> {
41 private String version;
44 public ToscaPolicyIdentifier(@NonNull String name, @NonNull String version) {
46 this.version = version;
49 public ToscaPolicyIdentifier(ToscaPolicyIdentifier source) {
50 this.name = source.name;
51 this.version = source.version;
55 * Validates that appropriate fields are populated for an incoming call to the PAP
58 * @return the validation result
60 public ValidationResult validatePapRest() {
61 BeanValidationResult result = new BeanValidationResult("group", this);
63 result.validateNotNull("name", name);
64 result.validateNotNull("version", version);
70 public int compareTo(ToscaPolicyIdentifier other) {
79 int result = ObjectUtils.compare(getName(), other.getName());
84 return ObjectUtils.compare(getVersion(), other.getVersion());