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) {
80 if (getClass() != obj.getClass()) {
83 SdcResourceBasicInfo other = (SdcResourceBasicInfo) obj;
85 if (other.name != null) {
88 } else if (!name.equals(other.name)) {
91 if (version == null) {
92 if (other.version != null) {
95 } else if (!version.equals(other.version)) {
102 * Convert version String into a BigDecimal.
104 * @param version version
105 * @return version in BigDecimal
107 private BigDecimal convertVersion(String version) {
108 BigDecimal rtn = BigDecimal.valueOf(0.0);
110 rtn = new BigDecimal(version);
111 } catch (NumberFormatException nfe) {
112 logger.warn("SDC version=" + version + " is not decimal for name=" + name);
117 public String getUuid() {
121 public void setUuid(String uuid) {
125 public String getInvariantUUID() {
126 return invariantUUID;
129 public void setInvariantUUID(String invariantUUID) {
130 this.invariantUUID = invariantUUID;
133 public String getName() {
137 public void setName(String name) {
141 public String getVersion() {
145 public void setVersion(String version) {
146 this.version = version;
149 public String getToscaModelURL() {
150 return toscaModelURL;
153 public void setToscaModelURL(String toscaModelURL) {
154 this.toscaModelURL = toscaModelURL;
157 public String getCategory() {
161 public void setCategory(String category) {
162 this.category = category;
165 public String getSubCategory() {
169 public void setSubCategory(String subCategory) {
170 this.subCategory = subCategory;
173 public String getResourceType() {
177 public void setResourceType(String resourceType) {
178 this.resourceType = resourceType;
181 public String getLifecycleState() {
182 return lifecycleState;
185 public void setLifecycleState(String lifecycleState) {
186 this.lifecycleState = lifecycleState;
189 public String getLastUpdaterUserId() {
190 return lastUpdaterUserId;
193 public void setLastUpdaterUserId(String lastUpdaterUserId) {
194 this.lastUpdaterUserId = lastUpdaterUserId;
197 public EELFLogger getLOGGER() {