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 SdcServiceInfo implements Comparable<SdcServiceInfo> {
33 protected static final EELFLogger logger = EELFManager.getInstance().getLogger(SdcServiceInfo.class);
34 protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
37 private String invariantUUID;
39 private String version;
40 private String toscaModelURL;
41 private String category;
42 private String lifecycleState;
43 private String lastUpdaterUserId;
44 private String distributionStatus;
46 public String getUuid() {
50 public void setUuid(String uuid) {
54 public String getInvariantUUID() {
58 public void setInvariantUUID(String invariantUUID) {
59 this.invariantUUID = invariantUUID;
62 public String getName() {
66 public void setName(String name) {
70 public String getVersion() {
74 public void setVersion(String version) {
75 this.version = version;
78 public String getToscaModelURL() {
82 public void setToscaModelURL(String toscaModelURL) {
83 this.toscaModelURL = toscaModelURL;
86 public String getCategory() {
90 public void setCategory(String category) {
91 this.category = category;
94 public String getLifecycleState() {
95 return lifecycleState;
98 public void setLifecycleState(String lifecycleState) {
99 this.lifecycleState = lifecycleState;
102 public String getLastUpdaterUserId() {
103 return lastUpdaterUserId;
106 public void setLastUpdaterUserId(String lastUpdaterUserId) {
107 this.lastUpdaterUserId = lastUpdaterUserId;
110 public String getDistributionStatus() {
111 return distributionStatus;
114 public void setDistributionStatus(String distributionStatus) {
115 this.distributionStatus = distributionStatus;
119 * Compare using name and then version. Version is converted to a decimal.
122 public int compareTo(SdcServiceInfo in) {
123 // Compares this object with the specified object for order.
124 // Returns a negative integer, zero, or a positive integer as this
125 // object is less than, equal to, or greater than the specified object.
126 // first compare based on name
127 int rtn = name.compareToIgnoreCase(in.name);
130 BigDecimal myVersion = convertVersion(version);
131 BigDecimal inVersion = convertVersion(in.version);
132 rtn = myVersion.compareTo(inVersion);
139 public int hashCode() {
140 final int prime = 31;
142 result = prime * result + ((name == null) ? 0 : name.hashCode());
143 result = prime * result + ((version == null) ? 0 : version.hashCode());
148 public boolean equals(Object obj) {
155 if (getClass() != obj.getClass()) {
158 SdcServiceInfo other = (SdcServiceInfo) obj;
160 if (other.name != null) {
163 } else if (!name.equals(other.name)) {
166 if (version == null) {
167 if (other.version != null) {
170 } else if (!version.equals(other.version)) {
177 * Convert version String into a BigDecimal.
179 * @param versionText version
180 * @return version in BigDecimal
182 private BigDecimal convertVersion(String versionText) {
184 return new BigDecimal(versionText);
185 } catch (NumberFormatException nfe) {
186 logger.warn("SDC version=" + versionText + " is not decimal for name=" + name);
188 return BigDecimal.valueOf(0.0);