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 * ===================================================================
24 package org.onap.clamp.clds.model.sdc;
26 import com.att.eelf.configuration.EELFLogger;
27 import com.att.eelf.configuration.EELFManager;
29 import java.math.BigDecimal;
31 public class SdcResourceBasicInfo implements Comparable<SdcResourceBasicInfo> {
33 protected static final EELFLogger logger = EELFManager.getInstance().getLogger(SdcResourceBasicInfo.class);
34 protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
37 private String invariantUUID;
39 private String version;
40 private String toscaModelURL;
41 private String category;
42 private String subCategory;
43 private String resourceType;
44 private String lifecycleState;
45 private String lastUpdaterUserId;
48 public int compareTo(SdcResourceBasicInfo in) {
49 // Compares this object with the specified object for order.
50 // Returns a negative integer, zero, or a positive integer as this
51 // object is less than, equal to, or greater than the specified object.
52 // first compare based on name
53 int rtn = name.compareToIgnoreCase(in.name);
56 BigDecimal myVersion = convertVersion(version);
57 BigDecimal inVersion = convertVersion(in.version);
58 rtn = myVersion.compareTo(inVersion);
64 public int hashCode() {
67 result = prime * result + ((name == null) ? 0 : name.hashCode());
68 result = prime * result + ((version == null) ? 0 : version.hashCode());
73 public boolean equals(Object obj) {
78 if (getClass() != obj.getClass())
80 SdcResourceBasicInfo other = (SdcResourceBasicInfo) obj;
82 if (other.name != null)
84 } else if (!name.equals(other.name))
86 if (version == null) {
87 if (other.version != null)
89 } else if (!version.equals(other.version))
95 * Convert version String into a BigDecimal
100 private BigDecimal convertVersion(String version) {
101 BigDecimal rtn = BigDecimal.valueOf(0.0);
103 rtn = new BigDecimal(version);
104 } catch (NumberFormatException nfe) {
105 logger.warn("SDC version=" + version + " is not decimal for name=" + name);
110 public String getUuid() {
114 public void setUuid(String uuid) {
118 public String getInvariantUUID() {
119 return invariantUUID;
122 public void setInvariantUUID(String invariantUUID) {
123 this.invariantUUID = invariantUUID;
126 public String getName() {
130 public void setName(String name) {
134 public String getVersion() {
138 public void setVersion(String version) {
139 this.version = version;
142 public String getToscaModelURL() {
143 return toscaModelURL;
146 public void setToscaModelURL(String toscaModelURL) {
147 this.toscaModelURL = toscaModelURL;
150 public String getCategory() {
154 public void setCategory(String category) {
155 this.category = category;
158 public String getSubCategory() {
162 public void setSubCategory(String subCategory) {
163 this.subCategory = subCategory;
166 public String getResourceType() {
170 public void setResourceType(String resourceType) {
171 this.resourceType = resourceType;
174 public String getLifecycleState() {
175 return lifecycleState;
178 public void setLifecycleState(String lifecycleState) {
179 this.lifecycleState = lifecycleState;
182 public String getLastUpdaterUserId() {
183 return lastUpdaterUserId;
186 public void setLastUpdaterUserId(String lastUpdaterUserId) {
187 this.lastUpdaterUserId = lastUpdaterUserId;
190 public EELFLogger getLOGGER() {