/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import lombok.NonNull;
import org.apache.commons.lang3.ObjectUtils;
-import org.onap.policy.common.utils.validation.Assertions;
import org.onap.policy.common.utils.validation.ParameterValidationUtils;
import org.onap.policy.models.base.PfAuthorative;
import org.onap.policy.models.base.PfConcept;
private PfConceptKey derivedFrom;
@ElementCollection
- private Map<String, String> metadata;
+ private Map<String, String> metadata = new TreeMap<>();
@Column
private String description;
*/
public JpaToscaEntityType(final JpaToscaEntityType<T> copyConcept) {
super(copyConcept);
+ this.key = new PfConceptKey(copyConcept.key);
+ this.derivedFrom = (copyConcept.derivedFrom != null ? new PfConceptKey(copyConcept.derivedFrom) : null);
+ this.metadata = (copyConcept.metadata != null ? new TreeMap<>(copyConcept.metadata) : null);
+ this.description = copyConcept.description;
}
/**
toscaEntity.setVersion(getKey().getVersion());
if (derivedFrom != null) {
- toscaEntity.setDerivedFrom(derivedFrom.getId());
+ toscaEntity.setDerivedFrom(derivedFrom.getName());
}
if (description != null) {
key.setVersion(toscaEntity.getVersion());
}
-
if (toscaEntity.getDerivedFrom() != null) {
// CHeck if the derived from field contains a name-version ID
if (toscaEntity.getDerivedFrom().contains(":")) {
return 0;
}
if (getClass() != otherConcept.getClass()) {
- return this.hashCode() - otherConcept.hashCode();
+ return getClass().getName().compareTo(otherConcept.getClass().getName());
}
@SuppressWarnings("unchecked")
return ObjectUtils.compare(description, other.description);
}
-
- @Override
- public PfConcept copyTo(@NonNull PfConcept target) {
- final Object copyObject = target;
- Assertions.instanceOf(copyObject, PfConcept.class);
-
- @SuppressWarnings("unchecked")
- final JpaToscaEntityType<T> copy = ((JpaToscaEntityType<T>) copyObject);
- copy.setKey(new PfConceptKey(key));
- copy.setDerivedFrom(derivedFrom != null ? new PfConceptKey(derivedFrom) : null);
-
- if (metadata != null) {
- final Map<String, String> newMatadata = new TreeMap<>();
- for (final Entry<String, String> metadataEntry : metadata.entrySet()) {
- newMatadata.put(metadataEntry.getKey(), metadataEntry.getValue());
- }
- copy.setMetadata(newMatadata);
- }
-
- copy.setDescription(description);
-
- return copy;
- }
}