diff options
author | grabinsk <maciej.grabinski@nokia.com> | 2019-04-05 10:13:48 +0200 |
---|---|---|
committer | grabinsk <maciej.grabinski@nokia.com> | 2019-05-22 15:36:41 +0200 |
commit | 41216decc9e167ee85aff6391f67dcf4b94f489c (patch) | |
tree | 4aceeba43aef18bb58121b20acf6dad34bc814cd /prh-commons/src/main | |
parent | 2cf649dda43c7fc7650b5d0047ccc57108918724 (diff) |
replace generated model classes with immutables
Change-Id: I5a1330e356522d2e315f7e243a2e65b90e4f6ddd
Issue-ID: DCAEGEN2-1391
Signed-off-by: grabinsk <maciej.grabinski@nokia.com>
Diffstat (limited to 'prh-commons/src/main')
-rw-r--r-- | prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/AaiPnfResultModel.java | 414 | ||||
-rw-r--r-- | prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/AaiServiceInstanceResultModel.java | 473 | ||||
-rw-r--r-- | prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/Relationship.java | 61 | ||||
-rw-r--r-- | prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/RelationshipData.java | 53 | ||||
-rw-r--r-- | prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/RelationshipDict.java | 103 | ||||
-rw-r--r-- | prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/utils/PrhModelAwareGsonBuilder.java (renamed from prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/utils/GsonSerializer.java) | 16 |
6 files changed, 232 insertions, 888 deletions
diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/AaiPnfResultModel.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/AaiPnfResultModel.java index e6d813f7..424d7f83 100644 --- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/AaiPnfResultModel.java +++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/AaiPnfResultModel.java @@ -21,438 +21,186 @@ package org.onap.dcaegen2.services.prh.model; import com.google.gson.annotations.SerializedName; +import org.immutables.gson.Gson; +import org.immutables.value.Value; +import org.springframework.lang.Nullable; + /** * PNF represents a physical network function. typically equipment used in the D1 world. in 1607, this will be populated by SDN-C to represent a premises router that a uCPE connects to. But this can be used to represent any physical device that is not an AIC node or uCPE. ###### Related Nodes - TO complex( pnf LocatedIn complex, MANY2ONE) - TO instance-group( pnf MemberOf instance-group, MANY2MANY) - TO zone( pnf LocatedIn zone, MANY2ONE) - FROM configuration( configuration AppliesTo pnf, ONE2MANY) - FROM esr-thirdparty-sdnc( esr-thirdparty-sdnc AppliesTo pnf, ONE2MANY) - FROM generic-vnf( generic-vnf HostedOn pnf, MANY2MANY) - FROM lag-interface (CHILD of pnf, lag-interface BindsTo pnf, MANY2ONE)(1) - FROM logical-link( logical-link BridgedTo pnf, MANY2MANY) - FROM p-interface (CHILD of pnf, p-interface BindsTo pnf, MANY2ONE)(1) - FROM service-instance( service-instance ComposedOf pnf, ONE2MANY) -(1) IF this PNF node is deleted, this FROM node is DELETED also */ - -public class AaiPnfResultModel { - @SerializedName("pnf-name") - private String pnfName = null; - - @SerializedName("pnf-name2") - private String pnfName2 = null; - - @SerializedName("selflink") - private String selflink = null; - - @SerializedName("pnf-name2-source") - private String pnfName2Source = null; - - @SerializedName("pnf-id") - private String pnfId = null; - - @SerializedName("equip-type") - private String equipType = null; - - @SerializedName("equip-vendor") - private String equipVendor = null; - - @SerializedName("equip-model") - private String equipModel = null; - - @SerializedName("management-option") - private String managementOption = null; - - @SerializedName("ipaddress-v4-oam") - private String ipaddressV4Oam = null; - - @SerializedName("sw-version") - private String swVersion = null; - - @SerializedName("in-maint") - private Boolean inMaint = null; - - @SerializedName("frame-id") - private String frameId = null; - - @SerializedName("serial-number") - private String serialNumber = null; - - @SerializedName("ipaddress-v4-loopback-0") - private String ipaddressV4Loopback0 = null; - - @SerializedName("ipaddress-v6-loopback-0") - private String ipaddressV6Loopback0 = null; - - @SerializedName("ipaddress-v4-aim") - private String ipaddressV4Aim = null; - - @SerializedName("ipaddress-v6-aim") - private String ipaddressV6Aim = null; - - @SerializedName("ipaddress-v6-oam") - private String ipaddressV6Oam = null; - - @SerializedName("inv-status") - private String invStatus = null; - - @SerializedName("resource-version") - private String resourceVersion = null; - - @SerializedName("prov-status") - private String provStatus = null; - - @SerializedName("nf-role") - private String nfRole = null; - - @SerializedName("relationship-list") - private Relationship relationshipList = null; +@Value.Immutable +@Gson.TypeAdapters(fieldNamingStrategy = true) +public interface AaiPnfResultModel { /** * unique name of Physical Network Function. - * - * @return pnfName **/ - public String getPnfName() { - return pnfName; - } - - public void setPnfName(String pnfName) { - this.pnfName = pnfName; - } + @Nullable + @SerializedName("pnf-name") + String getPnfName(); /** * name of Physical Network Function. - * - * @return pnfName2 **/ - public String getPnfName2() { - return pnfName2; - } - - public void setPnfName2(String pnfName2) { - this.pnfName2 = pnfName2; - } + @Nullable + @SerializedName("pnf-name2") + String getPnfName2(); /** * URL to endpoint where AAI can get more details. - * - * @return selflink **/ - public String getSelflink() { - return selflink; - } - - public void setSelflink(String selflink) { - this.selflink = selflink; - } + @Nullable + @SerializedName("selflink") + String getSelflink(); /** * source of name2 - * - * @return pnfName2Source **/ - public String getPnfName2Source() { - return pnfName2Source; - } - - public void setPnfName2Source(String pnfName2Source) { - this.pnfName2Source = pnfName2Source; - } + @Nullable + @SerializedName("pnf-name2-source") + String getPnfName2Source(); /** * id of pnf - * - * @return pnfId **/ - public String getPnfId() { - return pnfId; - } - - public void setPnfId(String pnfId) { - this.pnfId = pnfId; - } + @Nullable + @SerializedName("pnf-id") + String getPnfId(); /** * Equipment type. Source of truth should define valid values. - * - * @return equipType **/ - public String getEquipType() { - return equipType; - } - - public void setEquipType(String equipType) { - this.equipType = equipType; - } + @Nullable + @SerializedName("equip-type") + String getEquipType(); /** * Equipment vendor. Source of truth should define valid values. - * - * @return equipVendor **/ - public String getEquipVendor() { - return equipVendor; - } - - public void setEquipVendor(String equipVendor) { - this.equipVendor = equipVendor; - } + @Nullable + @SerializedName("equip-vendor") + String getEquipVendor(); /** * Equipment model. Source of truth should define valid values. - * - * @return equipModel **/ - public String getEquipModel() { - return equipModel; - } - - public void setEquipModel(String equipModel) { - this.equipModel = equipModel; - } + @Nullable + @SerializedName("equip-model") + String getEquipModel(); /** * identifier of managed by ATT or customer - * - * @return managementOption **/ - public String getManagementOption() { - return managementOption; - } - - public void setManagementOption(String managementOption) { - this.managementOption = managementOption; - } + @Nullable + @SerializedName("management-option") + String getManagementOption(); /** * ipv4-oam-address with new naming convention for IP addresses - * - * @return ipaddressV4Oam **/ - public String getIpaddressV4Oam() { - return ipaddressV4Oam; - } - - public void setIpaddressV4Oam(String ipaddressV4Oam) { - this.ipaddressV4Oam = ipaddressV4Oam; - } + @Nullable + @SerializedName("ipaddress-v4-oam") + String getIpaddressV4Oam(); /** * sw-version is the version of SW for the hosted application on the PNF. - * - * @return swVersion **/ - public String getSwVersion() { - return swVersion; - } - - public void setSwVersion(String swVersion) { - this.swVersion = swVersion; - } + @Nullable + @SerializedName("sw-version") + String getSwVersion(); /** * Used to indicate whether or not this object is in maintenance mode (maintenance mode = true). This field (in conjunction with prov-status) is used to suppress alarms and vSCL on VNFs/VMs. - * - * @return inMaint **/ - public Boolean isInMaint() { - return inMaint; - } - - public void setInMaint(Boolean inMaint) { - this.inMaint = inMaint; - } + @Nullable + @SerializedName("in-maint") + Boolean isInMaint(); /** * ID of the physical frame (relay rack) where pnf is installed. - * - * @return frameId **/ - public String getFrameId() { - return frameId; - } - - public void setFrameId(String frameId) { - this.frameId = frameId; - } + @Nullable + @SerializedName("frame-id") + String getFrameId(); /** * Serial number of the device - * - * @return serialNumber **/ - public String getSerialNumber() { - return serialNumber; - } - - public void setSerialNumber(String serialNumber) { - this.serialNumber = serialNumber; - } + @Nullable + @SerializedName("serial-number") + String getSerialNumber(); /** * IPV4 Loopback 0 address - * - * @return ipaddressV4Loopback0 **/ - public String getIpaddressV4Loopback0() { - return ipaddressV4Loopback0; - } - - public void setIpaddressV4Loopback0(String ipaddressV4Loopback0) { - this.ipaddressV4Loopback0 = ipaddressV4Loopback0; - } + @Nullable + @SerializedName("ipaddress-v4-loopback-0") + String getIpaddressV4Loopback0(); /** * IPV6 Loopback 0 address - * - * @return ipaddressV6Loopback0 **/ - public String getIpaddressV6Loopback0() { - return ipaddressV6Loopback0; - } - - public void setIpaddressV6Loopback0(String ipaddressV6Loopback0) { - this.ipaddressV6Loopback0 = ipaddressV6Loopback0; - } + @Nullable + @SerializedName("ipaddress-v6-loopback-0") + String getIpaddressV6Loopback0(); /** * IPV4 AIM address - * - * @return ipaddressV4Aim **/ - public String getIpaddressV4Aim() { - return ipaddressV4Aim; - } - - public void setIpaddressV4Aim(String ipaddressV4Aim) { - this.ipaddressV4Aim = ipaddressV4Aim; - } + @Nullable + @SerializedName("ipaddress-v4-aim") + String getIpaddressV4Aim(); /** * IPV6 AIM address - * - * @return ipaddressV6Aim **/ - public String getIpaddressV6Aim() { - return ipaddressV6Aim; - } - - public void setIpaddressV6Aim(String ipaddressV6Aim) { - this.ipaddressV6Aim = ipaddressV6Aim; - } + @Nullable + @SerializedName("ipaddress-v6-aim") + String getIpaddressV6Aim(); /** * IPV6 OAM address - * - * @return ipaddressV6Oam **/ - public String getIpaddressV6Oam() { - return ipaddressV6Oam; - } - - public void setIpaddressV6Oam(String ipaddressV6Oam) { - this.ipaddressV6Oam = ipaddressV6Oam; - } + @Nullable + @SerializedName("ipaddress-v6-oam") + String getIpaddressV6Oam(); /** * CANOPI's inventory status. Only set with values exactly as defined by CANOPI. - * - * @return invStatus **/ - public String getInvStatus() { - return invStatus; - } - - public void setInvStatus(String invStatus) { - this.invStatus = invStatus; - } + @Nullable + @SerializedName("inv-status") + String getInvStatus(); /** - * Used for optimistic concurrency. Must be empty on create, valid on update and delete. - * - * @return resourceVersion + * Used for optimistic concurrency. Must be empty on createGson, valid on update and delete. **/ - public String getResourceVersion() { - return resourceVersion; - } - - public void setResourceVersion(String resourceVersion) { - this.resourceVersion = resourceVersion; - } + @Nullable + @SerializedName("resource-version") + String getResourceVersion(); /** * Prov Status of this device (not under canopi control) Valid values [PREPROV/NVTPROV/PROV] - * - * @return provStatus **/ - public String getProvStatus() { - return provStatus; - } - - public void setProvStatus(String provStatus) { - this.provStatus = provStatus; - } + @Nullable + @SerializedName("prov-status") + String getProvStatus(); /** * Nf Role is the role performed by this instance in the network. - * - * @return nfRole **/ - public String getNfRole() { - return nfRole; - } - - public void setNfRole(String nfRole) { - this.nfRole = nfRole; - } + @Nullable + @SerializedName("nf-role") + String getNfRole(); /** * Get relationshipList - * - * @return relationshipList **/ - public Relationship getRelationshipList() { - return relationshipList; - } - - public void setRelationshipList(Relationship relationshipList) { - this.relationshipList = relationshipList; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class AaiPnfResultModel {\n"); - - sb.append(" pnfName: ").append(toIndentedString(pnfName)).append("\n"); - sb.append(" pnfName2: ").append(toIndentedString(pnfName2)).append("\n"); - sb.append(" selflink: ").append(toIndentedString(selflink)).append("\n"); - sb.append(" pnfName2Source: ").append(toIndentedString(pnfName2Source)).append("\n"); - sb.append(" pnfId: ").append(toIndentedString(pnfId)).append("\n"); - sb.append(" equipType: ").append(toIndentedString(equipType)).append("\n"); - sb.append(" equipVendor: ").append(toIndentedString(equipVendor)).append("\n"); - sb.append(" equipModel: ").append(toIndentedString(equipModel)).append("\n"); - sb.append(" managementOption: ").append(toIndentedString(managementOption)).append("\n"); - sb.append(" ipaddressV4Oam: ").append(toIndentedString(ipaddressV4Oam)).append("\n"); - sb.append(" swVersion: ").append(toIndentedString(swVersion)).append("\n"); - sb.append(" inMaint: ").append(toIndentedString(inMaint)).append("\n"); - sb.append(" frameId: ").append(toIndentedString(frameId)).append("\n"); - sb.append(" serialNumber: ").append(toIndentedString(serialNumber)).append("\n"); - sb.append(" ipaddressV4Loopback0: ").append(toIndentedString(ipaddressV4Loopback0)).append("\n"); - sb.append(" ipaddressV6Loopback0: ").append(toIndentedString(ipaddressV6Loopback0)).append("\n"); - sb.append(" ipaddressV4Aim: ").append(toIndentedString(ipaddressV4Aim)).append("\n"); - sb.append(" ipaddressV6Aim: ").append(toIndentedString(ipaddressV6Aim)).append("\n"); - sb.append(" ipaddressV6Oam: ").append(toIndentedString(ipaddressV6Oam)).append("\n"); - sb.append(" invStatus: ").append(toIndentedString(invStatus)).append("\n"); - sb.append(" resourceVersion: ").append(toIndentedString(resourceVersion)).append("\n"); - sb.append(" provStatus: ").append(toIndentedString(provStatus)).append("\n"); - sb.append(" nfRole: ").append(toIndentedString(nfRole)).append("\n"); - sb.append(" relationshipList: ").append(toIndentedString(relationshipList)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + @SerializedName("relationship-list") + @Value.Default + default Relationship getRelationshipList() { + return ImmutableRelationship.builder().build(); } } diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/AaiServiceInstanceResultModel.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/AaiServiceInstanceResultModel.java index 7bf8e2e4..67d6ff90 100644 --- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/AaiServiceInstanceResultModel.java +++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/AaiServiceInstanceResultModel.java @@ -21,452 +21,189 @@ package org.onap.dcaegen2.services.prh.model; import com.google.gson.annotations.SerializedName; +import org.immutables.gson.Gson; +import org.immutables.value.Value; +import org.springframework.lang.Nullable; -public class AaiServiceInstanceResultModel { - @SerializedName("service-instance-id") - private String serviceInstanceId = null; - - @SerializedName("service-instance-name") - private String serviceInstanceName = null; - - @SerializedName("service-type") - private String serviceType = null; - - @SerializedName("service-role") - private String serviceRole = null; - - @SerializedName("environment-context") - private String environmentContext = null; - - @SerializedName("workload-context") - private String workloadContext = null; - - @SerializedName("created-at") - private String createdAt = null; - - @SerializedName("updated-at") - private String updatedAt = null; - - @SerializedName("description") - private String description = null; - - @SerializedName("model-invariant-id") - private String modelInvariantId = null; - - @SerializedName("model-version-id") - private String modelVersionId = null; - - @SerializedName("persona-model-version") - private String personaModelVersion = null; - - @SerializedName("widget-model-id") - private String widgetModelId = null; - - @SerializedName("widget-model-version") - private String widgetModelVersion = null; - - @SerializedName("bandwidth-total") - private String bandwidthTotal = null; - - @SerializedName("bandwidth-up-wan1") - private String bandwidthUpWan1 = null; - - @SerializedName("bandwidth-down-wan1") - private String bandwidthDownWan1 = null; - - @SerializedName("bandwidth-up-wan2") - private String bandwidthUpWan2 = null; - - @SerializedName("bandwidth-down-wan2") - private String bandwidthDownWan2 = null; - - @SerializedName("vhn-portal-url") - private String vhnPortalUrl = null; - - @SerializedName("service-instance-location-id") - private String serviceInstanceLocationId = null; - - @SerializedName("resource-version") - private String resourceVersion = null; - - @SerializedName("selflink") - private String selflink = null; - - @SerializedName("orchestration-status") - private String orchestrationStatus = null; - - @SerializedName("relationship-list") - private Relationship relationshipList = null; +@Value.Immutable +@Gson.TypeAdapters(fieldNamingStrategy = true) +public interface AaiServiceInstanceResultModel { /** * Uniquely identifies this instance of a service - * - * @return serviceInstanceId **/ - public String getServiceInstanceId() { - return serviceInstanceId; - } - - public void setServiceInstanceId(String serviceInstanceId) { - this.serviceInstanceId = serviceInstanceId; - } + @Nullable + @SerializedName("service-instance-id") + String getServiceInstanceId(); /** * This field will store a name assigned to the service-instance. - * - * @return serviceInstanceName **/ - public String getServiceInstanceName() { - return serviceInstanceName; - } - - public void setServiceInstanceName(String serviceInstanceName) { - this.serviceInstanceName = serviceInstanceName; - } + @Nullable + @SerializedName("service-instance-name") + String getServiceInstanceName(); /** * String capturing type of service. - * - * @return serviceType **/ - public String getServiceType() { - return serviceType; - } - - public void setServiceType(String serviceType) { - this.serviceType = serviceType; - } + @Nullable + @SerializedName("service-type") + String getServiceType(); /** * String capturing the service role. - * - * @return serviceRole **/ - public String getServiceRole() { - return serviceRole; - } - - public void setServiceRole(String serviceRole) { - this.serviceRole = serviceRole; - } + @Nullable + @SerializedName("service-role") + String getServiceRole(); /** * This field will store the environment context assigned to the service-instance. - * - * @return environmentContext - **/ - public String getEnvironmentContext() { - return environmentContext; - } - - public void setEnvironmentContext(String environmentContext) { - this.environmentContext = environmentContext; - } + **/ + @Nullable + @SerializedName("environment-context") + String getEnvironmentContext(); /** * This field will store the workload context assigned to the service-instance. - * - * @return workloadContext - **/ - public String getWorkloadContext() { - return workloadContext; - } - - public void setWorkloadContext(String workloadContext) { - this.workloadContext = workloadContext; - } + **/ + @Nullable + @SerializedName("workload-context") + String getWorkloadContext(); /** - * create time of Network Service. - * - * @return createdAt - **/ - public String getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(String createdAt) { - this.createdAt = createdAt; - } + * createGson time of Network Service. + **/ + @Nullable + @SerializedName("created-at") + String getCreatedAt(); /** * last update of Network Service. - * - * @return updatedAt - **/ - public String getUpdatedAt() { - return updatedAt; - } - - public void setUpdatedAt(String updatedAt) { - this.updatedAt = updatedAt; - } + **/ + @Nullable + @SerializedName("updated-at") + String getUpdatedAt(); /** * short description for service-instance. - * - * @return description - **/ - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } + **/ + @Nullable + @SerializedName("description") + String getDescription(); /** * the ASDC model id for this resource or service model. - * - * @return modelInvariantId - **/ - public String getModelInvariantId() { - return modelInvariantId; - } - - public void setModelInvariantId(String modelInvariantId) { - this.modelInvariantId = modelInvariantId; - } + **/ + @Nullable + @SerializedName("model-invariant-id") + String getModelInvariantId(); /** * the ASDC model version for this resource or service model. - * - * @return modelVersionId - **/ - public String getModelVersionId() { - return modelVersionId; - } - - public void setModelVersionId(String modelVersionId) { - this.modelVersionId = modelVersionId; - } + **/ + @Nullable + @SerializedName("model-version-id") + String getModelVersionId(); /** * the ASDC model version for this resource or service model. - * - * @return personaModelVersion - **/ - public String getPersonaModelVersion() { - return personaModelVersion; - } - - public void setPersonaModelVersion(String personaModelVersion) { - this.personaModelVersion = personaModelVersion; - } + **/ + @Nullable + @SerializedName("persona-model-version") + String getPersonaModelVersion(); /** * the ASDC data dictionary widget model. This maps directly to the A&AI widget. - * - * @return widgetModelId - **/ - public String getWidgetModelId() { - return widgetModelId; - } - - public void setWidgetModelId(String widgetModelId) { - this.widgetModelId = widgetModelId; - } + **/ + @Nullable + @SerializedName("widget-model-id") + String getWidgetModelId(); /** * the ASDC data dictionary version of the widget model.This maps directly to the A&AI version of the widget. - * - * @return widgetModelVersion - **/ - public String getWidgetModelVersion() { - return widgetModelVersion; - } - - public void setWidgetModelVersion(String widgetModelVersion) { - this.widgetModelVersion = widgetModelVersion; - } + **/ + @Nullable + @SerializedName("widget-model-version") + String getWidgetModelVersion(); /** * Indicates the total bandwidth to be used for this service. - * - * @return bandwidthTotal - **/ - public String getBandwidthTotal() { - return bandwidthTotal; - } - - public void setBandwidthTotal(String bandwidthTotal) { - this.bandwidthTotal = bandwidthTotal; - } + **/ + @Nullable + @SerializedName("bandwidth-total") + String getBandwidthTotal(); /** * indicates the upstream bandwidth this service will use on the WAN1 port of the physical device. - * - * @return bandwidthUpWan1 - **/ - public String getBandwidthUpWan1() { - return bandwidthUpWan1; - } - - public void setBandwidthUpWan1(String bandwidthUpWan1) { - this.bandwidthUpWan1 = bandwidthUpWan1; - } + **/ + @Nullable + @SerializedName("bandwidth-up-wan1") + String getBandwidthUpWan1(); /** * indicates the downstream bandwidth this service will use on the WAN1 port of the physical device. - * - * @return bandwidthDownWan1 - **/ - public String getBandwidthDownWan1() { - return bandwidthDownWan1; - } - - public void setBandwidthDownWan1(String bandwidthDownWan1) { - this.bandwidthDownWan1 = bandwidthDownWan1; - } + **/ + @Nullable + @SerializedName("bandwidth-down-wan1") + String getBandwidthDownWan1(); /** * indicates the upstream bandwidth this service will use on the WAN2 port of the physical device. - * - * @return bandwidthUpWan2 - **/ - public String getBandwidthUpWan2() { - return bandwidthUpWan2; - } - - public void setBandwidthUpWan2(String bandwidthUpWan2) { - this.bandwidthUpWan2 = bandwidthUpWan2; - } + **/ + @Nullable + @SerializedName("bandwidth-up-wan2") + String getBandwidthUpWan2(); /** * indicates the downstream bandwidth this service will use on the WAN2 port of the physical device. - * - * @return bandwidthDownWan2 - **/ - public String getBandwidthDownWan2() { - return bandwidthDownWan2; - } - - public void setBandwidthDownWan2(String bandwidthDownWan2) { - this.bandwidthDownWan2 = bandwidthDownWan2; - } + **/ + @Nullable + @SerializedName("bandwidth-down-wan2") + String getBandwidthDownWan2(); /** * URL customers will use to access the vHN Portal. - * - * @return vhnPortalUrl - **/ - public String getVhnPortalUrl() { - return vhnPortalUrl; - } - - public void setVhnPortalUrl(String vhnPortalUrl) { - this.vhnPortalUrl = vhnPortalUrl; - } + **/ + @Nullable + @SerializedName("vhn-portal-url") + String getVhnPortalUrl(); /** * An identifier that customers assign to the location where this service is being used. - * - * @return serviceInstanceLocationId - **/ - public String getServiceInstanceLocationId() { - return serviceInstanceLocationId; - } - - public void setServiceInstanceLocationId(String serviceInstanceLocationId) { - this.serviceInstanceLocationId = serviceInstanceLocationId; - } + **/ + @Nullable + @SerializedName("service-instance-location-id") + String getServiceInstanceLocationId(); /** - * Used for optimistic concurrency. Must be empty on create, valid on update and delete. - * - * @return resourceVersion - **/ - public String getResourceVersion() { - return resourceVersion; - } - - public void setResourceVersion(String resourceVersion) { - this.resourceVersion = resourceVersion; - } + * Used for optimistic concurrency. Must be empty on createGson, valid on update and delete. + **/ + @Nullable + @SerializedName("resource-version") + String getResourceVersion(); /** * Path to the controller object. - * - * @return selflink - **/ - public String getSelflink() { - return selflink; - } - - public void setSelflink(String selflink) { - this.selflink = selflink; - } + **/ + @Nullable + @SerializedName("selflink") + String getSelflink(); /** * Orchestration status of this service. - * - * @return orchestrationStatus - **/ - public String getOrchestrationStatus() { - return orchestrationStatus; - } - - public void setOrchestrationStatus(String orchestrationStatus) { - this.orchestrationStatus = orchestrationStatus; - } - + **/ + @Nullable + @SerializedName("orchestration-status") + String getOrchestrationStatus(); /** * Get relationshipList - * - * @return relationshipList - **/ - public Relationship getRelationshipList() { - return relationshipList; - } - - public void setRelationshipList(Relationship relationshipList) { - this.relationshipList = relationshipList; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class AaiServiceInstanceResultModel {\n"); - - sb.append(" serviceInstanceId: ").append(toIndentedString(serviceInstanceId)).append("\n"); - sb.append(" serviceInstanceName: ").append(toIndentedString(serviceInstanceName)).append("\n"); - sb.append(" serviceType: ").append(toIndentedString(serviceType)).append("\n"); - sb.append(" serviceRole: ").append(toIndentedString(serviceRole)).append("\n"); - sb.append(" environmentContext: ").append(toIndentedString(environmentContext)).append("\n"); - sb.append(" workloadContext: ").append(toIndentedString(workloadContext)).append("\n"); - sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); - sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n"); - sb.append(" description: ").append(toIndentedString(description)).append("\n"); - sb.append(" modelInvariantId: ").append(toIndentedString(modelInvariantId)).append("\n"); - sb.append(" modelVersionId: ").append(toIndentedString(modelVersionId)).append("\n"); - sb.append(" personaModelVersion: ").append(toIndentedString(personaModelVersion)).append("\n"); - sb.append(" widgetModelId: ").append(toIndentedString(widgetModelId)).append("\n"); - sb.append(" widgetModelVersion: ").append(toIndentedString(widgetModelVersion)).append("\n"); - sb.append(" bandwidthTotal: ").append(toIndentedString(bandwidthTotal)).append("\n"); - sb.append(" bandwidthUpWan1: ").append(toIndentedString(bandwidthUpWan1)).append("\n"); - sb.append(" bandwidthDownWan1: ").append(toIndentedString(bandwidthDownWan1)).append("\n"); - sb.append(" bandwidthUpWan2: ").append(toIndentedString(bandwidthUpWan2)).append("\n"); - sb.append(" bandwidthDownWan2: ").append(toIndentedString(bandwidthDownWan2)).append("\n"); - sb.append(" vhnPortalUrl: ").append(toIndentedString(vhnPortalUrl)).append("\n"); - sb.append(" serviceInstanceLocationId: ").append(toIndentedString(serviceInstanceLocationId)).append("\n"); - sb.append(" resourceVersion: ").append(toIndentedString(resourceVersion)).append("\n"); - sb.append(" selflink: ").append(toIndentedString(selflink)).append("\n"); - sb.append(" orchestrationStatus: ").append(toIndentedString(orchestrationStatus)).append("\n"); - sb.append(" relationshipList: ").append(toIndentedString(relationshipList)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + **/ + @SerializedName("relationship-list") + @Value.Default + default Relationship getRelationshipList() { + return ImmutableRelationship.builder().build(); } }
\ No newline at end of file diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/Relationship.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/Relationship.java index 094e1a62..d92b7c75 100644 --- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/Relationship.java +++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/Relationship.java @@ -21,62 +21,15 @@ package org.onap.dcaegen2.services.prh.model; import com.google.gson.annotations.SerializedName; +import org.immutables.gson.Gson; +import org.immutables.value.Value; -import java.util.ArrayList; import java.util.List; -/** - * dictionary of relationship - */ -public class Relationship { - @SerializedName("relationship") - private List<RelationshipDict> relationship = null; - - public Relationship relationship(List<RelationshipDict> relationship) { - this.relationship = relationship; - return this; - } - - public Relationship addRelationshipItem(RelationshipDict relationshipItem) { - if (this.relationship == null) { - this.relationship = new ArrayList<>(); - } - this.relationship.add(relationshipItem); - return this; - } - - /** - * Get relationship - * - * @return relationship - **/ - public List<RelationshipDict> getRelationship() { - return relationship; - } - - public void setRelationship(List<RelationshipDict> relationship) { - this.relationship = relationship; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Relationship {\n"); - - sb.append(" relationship: ").append(toIndentedString(relationship)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } +@Value.Immutable +@Gson.TypeAdapters(fieldNamingStrategy = true) +public interface Relationship { + @SerializedName("relationship") + List<RelationshipDict> getRelationship(); }
\ No newline at end of file diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/RelationshipData.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/RelationshipData.java index 8b33b650..4b1670c6 100644 --- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/RelationshipData.java +++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/RelationshipData.java @@ -21,64 +21,29 @@ package org.onap.dcaegen2.services.prh.model; import com.google.gson.annotations.SerializedName; +import org.immutables.gson.Gson; +import org.immutables.value.Value; /** * RelationshipData */ -public class RelationshipData { - @SerializedName("relationship-key") - private String relationshipKey = null; - - @SerializedName("relationship-value") - private String relationshipValue = null; +@Value.Immutable +@Gson.TypeAdapters(fieldNamingStrategy = true) +public interface RelationshipData { /** * A keyword provided by A&AI to indicate an attribute. * * @return relationshipKey **/ - public String getRelationshipKey() { - return relationshipKey; - } - - public void setRelationshipKey(String relationshipKey) { - this.relationshipKey = relationshipKey; - } + @SerializedName("relationship-key") + String getRelationshipKey(); /** * Value of the attribute. * * @return relationshipValue **/ - public String getRelationshipValue() { - return relationshipValue; - } - - public void setRelationshipValue(String relationshipValue) { - this.relationshipValue = relationshipValue; - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class RelationshipData {\n"); - - sb.append(" relationshipKey: ").append(toIndentedString(relationshipKey)).append("\n"); - sb.append(" relationshipValue: ").append(toIndentedString(relationshipValue)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - + @SerializedName("relationship-value") + String getRelationshipValue(); }
\ No newline at end of file diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/RelationshipDict.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/RelationshipDict.java index 0a7a9459..007f371b 100644 --- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/RelationshipDict.java +++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/RelationshipDict.java @@ -21,109 +21,48 @@ package org.onap.dcaegen2.services.prh.model; import com.google.gson.annotations.SerializedName; +import org.immutables.gson.Gson; +import org.immutables.value.Value; +import org.springframework.lang.Nullable; -import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** * RelationshipDict */ -public class RelationshipDict { - @SerializedName("related-to") - private String relatedTo = null; - - @SerializedName("relationship-label") - private String relationshipLabel = null; - - @SerializedName("related-link") - private String relatedLink = null; - - @SerializedName("relationship-data") - private List<RelationshipData> relationshipData = null; +@Value.Immutable +@Gson.TypeAdapters(fieldNamingStrategy = true) +public interface RelationshipDict { /** * A keyword provided by A&AI to indicate type of node. - * - * @return relatedTo **/ - public String getRelatedTo() { - return relatedTo; - } - - public void setRelatedTo(String relatedTo) { - this.relatedTo = relatedTo; - } + @Nullable + @SerializedName("related-to") + String getRelatedTo(); /** * The edge label for this relationship. - * - * @return relationshipLabel **/ - public String getRelationshipLabel() { - return relationshipLabel; - } - - public void setRelationshipLabel(String relationshipLabel) { - this.relationshipLabel = relationshipLabel; - } + @Nullable + @SerializedName("relationship-label") + String getRelationshipLabel(); /** * URL to the object in A&AI. - * - * @return relatedLink **/ - public String getRelatedLink() { - return relatedLink; - } - - public void setRelatedLink(String relatedLink) { - this.relatedLink = relatedLink; - } - - public RelationshipDict addRelationshipDataItem(RelationshipData relationshipDataItem) { - if (this.relationshipData == null) { - this.relationshipData = new ArrayList<RelationshipData>(); - } - this.relationshipData.add(relationshipDataItem); - return this; - } + @Nullable + @SerializedName("related-link") + String getRelatedLink(); /** - * Get relationshipData - * - * @return relationshipData + * relationship Data **/ - public List<RelationshipData> getRelationshipData() { - return relationshipData; - } - - public void setRelationshipData(List<RelationshipData> relationshipData) { - this.relationshipData = relationshipData; - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class RelationshipDict {\n"); - - sb.append(" relatedTo: ").append(toIndentedString(relatedTo)).append("\n"); - sb.append(" relationshipLabel: ").append(toIndentedString(relationshipLabel)).append("\n"); - sb.append(" relatedLink: ").append(toIndentedString(relatedLink)).append("\n"); - sb.append(" relationshipData: ").append(toIndentedString(relationshipData)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + @SerializedName("relationship-data") + @Value.Default + default List<RelationshipData> getRelationshipData() { + return Collections.emptyList(); } }
\ No newline at end of file diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/utils/GsonSerializer.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/utils/PrhModelAwareGsonBuilder.java index 9b6a7e60..1974f6da 100644 --- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/utils/GsonSerializer.java +++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/utils/PrhModelAwareGsonBuilder.java @@ -20,18 +20,20 @@ package org.onap.dcaegen2.services.prh.model.utils; +import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapterFactory; + import java.util.ServiceLoader; -public class GsonSerializer { +public final class PrhModelAwareGsonBuilder { - private GsonSerializer() { - } + private static final Iterable<TypeAdapterFactory> TYPE_ADAPTER_FACTORIES = + ServiceLoader.load(TypeAdapterFactory.class); - public static <T> String createJsonBody(T type) { + public static Gson createGson() { GsonBuilder gsonBuilder = new GsonBuilder(); - ServiceLoader.load(TypeAdapterFactory.class).forEach(gsonBuilder::registerTypeAdapterFactory); - return gsonBuilder.create().toJson(type); + TYPE_ADAPTER_FACTORIES.forEach(gsonBuilder::registerTypeAdapterFactory); + return gsonBuilder.create(); } -}
\ No newline at end of file +} |