package org.onap.policy.models.tosca.simple.concepts;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
-
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.EmbeddedId;
import javax.persistence.MappedSuperclass;
-
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
-
import org.apache.commons.lang3.ObjectUtils;
import org.onap.policy.common.utils.validation.ParameterValidationUtils;
import org.onap.policy.models.base.PfAuthorative;
private PfConceptKey derivedFrom;
@ElementCollection
- private Map<String, String> metadata = new TreeMap<>();
+ private Map<String, String> metadata;
@Column
private String description;
toscaEntity.setDescription(description);
}
- if (metadata != null) {
- Map<String, String> metadataMap = new LinkedHashMap<>();
-
- for (Entry<String, String> entry : metadata.entrySet()) {
- metadataMap.put(entry.getKey(), entry.getValue());
- }
-
- toscaEntity.setMetadata(metadataMap);
- }
+ toscaEntity.setMetadata(PfUtils.mapMap(metadata, item -> item));
return toscaEntity;
}
}
if (toscaEntity.getDerivedFrom() != null) {
- // CHeck if the derived from field contains a name-version ID
+ // Check if the derived from field contains a name-version ID
if (toscaEntity.getDerivedFrom().contains(":")) {
derivedFrom = new PfConceptKey(toscaEntity.getDerivedFrom());
} else {
description = toscaEntity.getDescription();
}
- if (toscaEntity.getMetadata() != null) {
- metadata = new LinkedHashMap<>();
-
- for (Entry<String, String> metadataEntry : toscaEntity.getMetadata().entrySet()) {
- metadata.put(metadataEntry.getKey(), metadataEntry.getValue());
- }
- }
+ metadata = PfUtils.mapMap(toscaEntity.getMetadata(), item -> item);
}
@Override
@SuppressWarnings("unchecked")
final JpaToscaEntityType<T> other = (JpaToscaEntityType<T>) otherConcept;
- if (!key.equals(other.key)) {
- return key.compareTo(other.key);
+
+ int result = key.compareTo(other.key);
+ if (result != 0) {
+ return result;
}
- int result = ObjectUtils.compare(derivedFrom, other.derivedFrom);
+ result = ObjectUtils.compare(derivedFrom, other.derivedFrom);
if (result != 0) {
return result;
}
- result = PfUtils.compareObjects(metadata, other.metadata);
+ result = PfUtils.compareMaps(metadata, other.metadata);
if (result != 0) {
return result;
}