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%2FToscaEntity.java;h=d5c098a2ef9d5b7e45a0a1020eb7de54470f3089;hb=938005505883cf7a636a8840e20e3dc8a0ad9176;hp=5c1167c7d79d399df871d10b358fbcadcac17920;hpb=b87e0242ce1a957740ee988bec3b82e3628adbed;p=policy%2Fmodels.git diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntity.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntity.java index 5c1167c7d..d5c098a2e 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntity.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntity.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP Policy Model * ================================================================================ - * Copyright (C) 2019-2020 Nordix Foundation. + * Copyright (C) 2019-2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,12 +23,11 @@ package org.onap.policy.models.tosca.authorative.concepts; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModelProperty; +import jakarta.ws.rs.core.Response; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import javax.ws.rs.core.Response; import lombok.Data; import lombok.NoArgsConstructor; import lombok.NonNull; @@ -47,11 +46,10 @@ public class ToscaEntity implements PfNameVersion { private String name = PfKey.NULL_KEY_NAME; private String version = PfKey.NULL_KEY_VERSION; - @ApiModelProperty(name = "derived_from") @SerializedName("derived_from") private String derivedFrom; - private Map metadata; + private Map metadata; private String description; /** @@ -67,7 +65,7 @@ public class ToscaEntity implements PfNameVersion { if (copyObject.metadata != null) { metadata = new LinkedHashMap<>(); - for (final Entry metadataEntry : copyObject.metadata.entrySet()) { + for (final Entry metadataEntry : copyObject.metadata.entrySet()) { metadata.put(metadataEntry.getKey(), metadataEntry.getValue()); } } @@ -104,13 +102,16 @@ public class ToscaEntity implements PfNameVersion { // Declare the return map Map entityMap = new LinkedHashMap<>(); + if (listOfMapsOfEntities == null) { + return entityMap; + } + for (Map mapOfEntities : listOfMapsOfEntities) { for (T entityEntry : mapOfEntities.values()) { if (entityMap.containsKey(entityEntry.getKey())) { throw new PfModelRuntimeException(Response.Status.INTERNAL_SERVER_ERROR, - "list of map of entities contains more than one entity with key " + entityEntry.getKey()); + "list of map of entities contains more than one entity with key " + entityEntry.getKey()); } - entityMap.put(entityEntry.getKey(), entityEntry); } } @@ -129,10 +130,14 @@ public class ToscaEntity implements PfNameVersion { // Declare the return map Map entityMap = new LinkedHashMap<>(); + if (mapOfEntities == null) { + return entityMap; + } + for (T entityEntry : mapOfEntities.values()) { if (entityMap.containsKey(entityEntry.getKey())) { throw new PfModelRuntimeException(Response.Status.INTERNAL_SERVER_ERROR, - "list of map of entities contains more than one entity with key " + entityEntry.getKey()); + "list of map of entities contains more than one entity with key " + entityEntry.getKey()); } entityMap.put(entityEntry.getKey(), entityEntry); @@ -140,4 +145,22 @@ public class ToscaEntity implements PfNameVersion { return entityMap; } + + /** + * Method that should be specialised to return the type of the entity if the entity has a type. + * + * @return the type of the entity or null if it has no type + */ + public String getType() { + return null; + } + + /** + * Method that should be specialised to return the type version of the entity if the entity has a type. + * + * @return the type of the entity or null if it has no type + */ + public String getTypeVersion() { + return null; + } }