class BBInputSetup implements JavaDelegate {

    protected void populateGenericVnf(BBInputSetupParameter parameter) {
        GenericVnf vnf = null;
        ModelInfo instanceGroupModelInfo = null;
        String instanceGroupId = null;
        String generatedVnfType = parameter.getVnfType();
        String replaceVnfModelCustomizationUUID = null;
        if (generatedVnfType == null || generatedVnfType.isEmpty()) {
            generatedVnfType =
                    parameter.getService().getModelName() + "/" + parameter.getModelInfo().getModelCustomizationName();
        }
        if (parameter.getRelatedInstanceList() != null) {
            for (RelatedInstanceList relatedInstList : parameter.getRelatedInstanceList()) {
                RelatedInstance relatedInstance = relatedInstList.getRelatedInstance();
                if (relatedInstance.getModelInfo().getModelType().equals(ModelType.networkInstanceGroup)) {
                    instanceGroupModelInfo = relatedInstance.getModelInfo();
                    instanceGroupId = relatedInstance.getInstanceId();
                }
                if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf) && parameter.getIsReplace()) {
                    replaceVnfModelCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationId();
                }
            }
        }
        for (GenericVnf vnfTemp : parameter.getServiceInstance().getVnfs()) {
            if (parameter.getLookupKeyMap().get(ResourceKey.GENERIC_VNF_ID) != null && vnfTemp.getVnfId()
                    .equalsIgnoreCase(parameter.getLookupKeyMap().get(ResourceKey.GENERIC_VNF_ID))) {
                String vnfModelCustId =
                        bbInputSetupUtils.getAAIGenericVnf(vnfTemp.getVnfId()).getModelCustomizationId();
                if (parameter.getIsReplace() && replaceVnfModelCustomizationUUID != null && vnfTemp.getVnfId()
                        .equalsIgnoreCase(parameter.getLookupKeyMap().get(ResourceKey.GENERIC_VNF_ID))) {
                    parameter.getModelInfo().setModelCustomizationUuid(replaceVnfModelCustomizationUUID);
                } else {
                    parameter.getModelInfo().setModelCustomizationUuid(vnfModelCustId);
                }
                vnf = vnfTemp;
                break;
            }
        }
        if (vnf == null && parameter.getBbName().equalsIgnoreCase(AssignFlows.VNF.toString())) {
            vnf = createGenericVnf(parameter.getLookupKeyMap(), parameter.getInstanceName(), parameter.getPlatform(),
                    parameter.getLineOfBusiness(), parameter.getResourceId(), generatedVnfType,
                    parameter.getInstanceParams(), parameter.getProductFamilyId(), parameter.getApplicationId());
            parameter.getServiceInstance().getVnfs().add(vnf);
            mapVnfcCollectionInstanceGroup(vnf, parameter.getModelInfo(), parameter.getService());
        }
        if (vnf != null) {
            mapCatalogVnf(vnf, parameter.getModelInfo(), parameter.getService());
            if (instanceGroupId != null && instanceGroupModelInfo != null
                    && instanceGroupModelInfo.getModelType().equals(ModelType.networkInstanceGroup)
                    && !instanceGroupInList(vnf, instanceGroupId)) {
                mapNetworkCollectionInstanceGroup(vnf, instanceGroupId);
            }
        }
    }

}