X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=models-tosca%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fmodels%2Ftosca%2Fauthorative%2Fconcepts%2FToscaConceptIdentifierOptVersion.java;h=62c1ed7ef0a1a0af7552a591f8ba7a3209d0a419;hb=7e4f9950ed004042e36e7e1f6f78224d62888e74;hp=c23c04fe819511549626d536726f367d930b7bd9;hpb=f2b0318f53abf9f2345a5cdca74f3dd635aa9b60;p=policy%2Fmodels.git diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifierOptVersion.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifierOptVersion.java index c23c04fe8..62c1ed7ef 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifierOptVersion.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifierOptVersion.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP Policy Models * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2020-2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,58 +21,34 @@ package org.onap.policy.models.tosca.authorative.concepts; -import lombok.Data; +import java.io.Serializable; +import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import lombok.NonNull; -import org.apache.commons.lang3.ObjectUtils; /** - * Concept identifier with an optional version; only the "name" is required. + * Concept identifier with an optional name and version. */ -@Data +@EqualsAndHashCode(callSuper = true) @NoArgsConstructor -public class ToscaConceptIdentifierOptVersion implements Comparable { - - @NonNull - private String name; - - private String version; +public class ToscaConceptIdentifierOptVersion extends ToscaNameVersion + implements Serializable, Comparable { + private static final long serialVersionUID = 8010649773816325786L; public ToscaConceptIdentifierOptVersion(@NonNull String name, String version) { - this.name = name; - this.version = version; + super(name, version); } public ToscaConceptIdentifierOptVersion(ToscaConceptIdentifierOptVersion source) { - this.name = source.name; - this.version = source.version; + super(source); } public ToscaConceptIdentifierOptVersion(ToscaConceptIdentifier source) { - this.name = source.getName(); - this.version = source.getVersion(); + super(source.getName(), source.getVersion()); } @Override public int compareTo(ToscaConceptIdentifierOptVersion other) { - if (this == other) { - return 0; - } - - if (other == null) { - return 1; - } - - int result = ObjectUtils.compare(getName(), other.getName()); - if (result != 0) { - return result; - } - - return ObjectUtils.compare(getVersion(), other.getVersion()); - } - - @Override - public String toString() { - return this.name + " " + this.version; + return commonCompareTo(other); } }