2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * ===================================================================
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
24 package org.onap.clamp.clds.model;
26 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
28 import java.math.BigDecimal;
29 import java.util.List;
30 import java.util.logging.Logger;
32 @JsonIgnoreProperties(ignoreUnknown = true)
33 public class CldsAsdcResource implements Comparable<CldsAsdcResource> {
34 private static final Logger logger = Logger.getLogger(CldsAsdcServiceInfo.class.getName());
36 private String resourceInstanceName;
37 private String resourceName;
38 private String resourceInvariantUUID;
39 private String resourceVersion;
40 private String resoucreType;
41 private String resourceUUID;
42 private List<CldsAsdcArtifact> artifacts;
44 public String getResourceInstanceName() {
45 return resourceInstanceName;
48 public void setResourceInstanceName(String resourceInstanceName) {
49 this.resourceInstanceName = resourceInstanceName;
52 public String getResourceName() {
56 public void setResourceName(String resourceName) {
57 this.resourceName = resourceName;
60 public String getResourceInvariantUUID() {
61 return resourceInvariantUUID;
64 public void setResourceInvariantUUID(String resourceInvariantUUID) {
65 this.resourceInvariantUUID = resourceInvariantUUID;
68 public String getResourceVersion() {
69 return resourceVersion;
72 public void setResourceVersion(String resourceVersion) {
73 this.resourceVersion = resourceVersion;
76 public String getResoucreType() {
80 public void setResoucreType(String resoucreType) {
81 this.resoucreType = resoucreType;
84 public String getResourceUUID() {
88 public void setResourceUUID(String resourceUUID) {
89 this.resourceUUID = resourceUUID;
92 public List<CldsAsdcArtifact> getArtifacts() {
96 public void setArtifacts(List<CldsAsdcArtifact> artifacts) {
97 this.artifacts = artifacts;
101 public int compareTo(CldsAsdcResource in) {
102 // Compares this object with the specified object for order.
103 // Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
105 // first compare based on name
106 int rtn = resourceInstanceName.compareToIgnoreCase(in.resourceInstanceName);
109 BigDecimal myVersion = convertVersion(resourceVersion);
110 BigDecimal inVersion = convertVersion(in.resourceVersion);
111 rtn = myVersion.compareTo(inVersion);
117 * Convert version String into a BigDecimal
122 private BigDecimal convertVersion(String versionText) {
123 BigDecimal rtn = new BigDecimal(0.0);
125 rtn = new BigDecimal(versionText);
126 } catch (NumberFormatException nfe) {
127 logger.warning("ASDC version=" + versionText + " is not decimal for name=" + resourceInstanceName);