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.sdc;
26 import com.att.eelf.configuration.EELFLogger;
27 import com.att.eelf.configuration.EELFManager;
28 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
30 import java.math.BigDecimal;
32 @JsonIgnoreProperties(ignoreUnknown = true)
33 public class SdcResourceBasicInfo implements Comparable<SdcResourceBasicInfo> {
35 protected static final EELFLogger logger = EELFManager.getInstance()
36 .getLogger(SdcResourceBasicInfo.class);
37 protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
40 private String invariantUUID;
42 private String version;
43 private String toscaModelURL;
44 private String category;
45 private String subCategory;
46 private String resourceType;
47 private String lifecycleState;
48 private String lastUpdaterUserId;
51 public int compareTo(SdcResourceBasicInfo in) {
52 // Compares this object with the specified object for order.
53 // Returns a negative integer, zero, or a positive integer as this
54 // object is less than, equal to, or greater than the specified object.
55 // first compare based on name
56 int rtn = name.compareToIgnoreCase(in.name);
59 BigDecimal myVersion = convertVersion(version);
60 BigDecimal inVersion = convertVersion(in.version);
61 rtn = myVersion.compareTo(inVersion);
67 public int hashCode() {
70 result = prime * result + ((name == null) ? 0 : name.hashCode());
71 result = prime * result + ((version == null) ? 0 : version.hashCode());
76 public boolean equals(Object obj) {
81 if (getClass() != obj.getClass())
83 SdcResourceBasicInfo other = (SdcResourceBasicInfo) obj;
85 if (other.name != null)
87 } else if (!name.equals(other.name))
89 if (version == null) {
90 if (other.version != null)
92 } else if (!version.equals(other.version))
98 * Convert version String into a BigDecimal
103 private BigDecimal convertVersion(String version) {
104 BigDecimal rtn = BigDecimal.valueOf(0.0);
106 rtn = new BigDecimal(version);
107 } catch (NumberFormatException nfe) {
108 logger.warn("SDC version=" + version + " is not decimal for name=" + name);
113 public String getUuid() {
117 public void setUuid(String uuid) {
121 public String getInvariantUUID() {
122 return invariantUUID;
125 public void setInvariantUUID(String invariantUUID) {
126 this.invariantUUID = invariantUUID;
129 public String getName() {
133 public void setName(String name) {
137 public String getVersion() {
141 public void setVersion(String version) {
142 this.version = version;
145 public String getToscaModelURL() {
146 return toscaModelURL;
149 public void setToscaModelURL(String toscaModelURL) {
150 this.toscaModelURL = toscaModelURL;
153 public String getCategory() {
157 public void setCategory(String category) {
158 this.category = category;
161 public String getSubCategory() {
165 public void setSubCategory(String subCategory) {
166 this.subCategory = subCategory;
169 public String getResourceType() {
173 public void setResourceType(String resourceType) {
174 this.resourceType = resourceType;
177 public String getLifecycleState() {
178 return lifecycleState;
181 public void setLifecycleState(String lifecycleState) {
182 this.lifecycleState = lifecycleState;
185 public String getLastUpdaterUserId() {
186 return lastUpdaterUserId;
189 public void setLastUpdaterUserId(String lastUpdaterUserId) {
190 this.lastUpdaterUserId = lastUpdaterUserId;
193 public EELFLogger getLOGGER() {