Source:
<code>public static ApiPolicyListDTO fromApiPolicyToApiPolicyListDTO(List<APIPolicy> model) { ApiPolicyListDTO apiPolicyListDTO = new ApiPolicyListDTO(); if (model != null) { for (APIPolicy apiPolicyModel : model) { ApiPolicyDTO policyDTO = new ApiPolicyDTO(); policyDTO.setName(apiPolicyModel.getName()); policyDTO.setQuotaType(apiPolicyModel.getQuotaType()); policyDTO.setTenantId(apiPolicyModel.getTenantId()); apiPolicyListDTO.getList().add(policyDTO); List<APIPolicyConditionGroup> retrievedGroups = apiPolicyModel.getConditionGroups(); <START> List<ApiPolicyConditionGroupDTO> condGroups = new ArrayList<ApiPolicyConditionGroupDTO>(); <END> for (APIPolicyConditionGroup retGroup : retrievedGroups) { ApiPolicyConditionGroupDTO group = new ApiPolicyConditionGroupDTO(); group.setConditionGroupId(retGroup.getConditionGroupId()); group.setQuotaType(retGroup.getQuotaType()); group.setPolicyId(retGroup.getPolicyId()); List<org.wso2.carbon.apimgt.internal.service.dto.ConditionDTO> condition = new ArrayList<org.wso2.carbon.apimgt.internal.service.dto.ConditionDTO>(); List<ConditionDTO> retrievedConditions = retGroup.getConditionDTOS(); for (ConditionDTO retrievedCondition : retrievedConditions) { org.wso2.carbon.apimgt.internal.service.dto.ConditionDTO conditionDTO = new org.wso2.carbon.apimgt.internal.service.dto.ConditionDTO(); conditionDTO.setConditionType(retrievedCondition.getConditionType()); conditionDTO.setIsInverted(retrievedCondition.isInverted()); conditionDTO.setName(retrievedCondition.getConditionName()); conditionDTO.setValue(retrievedCondition.getConditionValue()); condition.add(conditionDTO); } group.setCondition(condition); condGroups.add(group); } policyDTO.setConditionGroups(condGroups); } apiPolicyListDTO.setCount(model.size()); } else { apiPolicyListDTO.setCount(0); } return apiPolicyListDTO; }</code><technical_language>set size of this list retrievedGroups length</technical_language>

Target:
public static ApiPolicyListDTO fromApiPolicyToApiPolicyListDTO(List<APIPolicy> model) { ApiPolicyListDTO apiPolicyListDTO = new ApiPolicyListDTO(); if (model != null) { for (APIPolicy apiPolicyModel : model) { ApiPolicyDTO policyDTO = new ApiPolicyDTO(); policyDTO.setName(apiPolicyModel.getName()); policyDTO.setQuotaType(apiPolicyModel.getQuotaType()); policyDTO.setTenantId(apiPolicyModel.getTenantId()); policyDTO.setApplicableLevel(apiPolicyModel.getApplicableLevel()); apiPolicyListDTO.getList().add(policyDTO); List<APIPolicyConditionGroup> retrievedGroups = apiPolicyModel.getConditionGroups(); List<ApiPolicyConditionGroupDTO> condGroups = new ArrayList<ApiPolicyConditionGroupDTO>(); for (APIPolicyConditionGroup retGroup : retrievedGroups) { ApiPolicyConditionGroupDTO group = new ApiPolicyConditionGroupDTO(); group.setConditionGroupId(retGroup.getConditionGroupId()); group.setQuotaType(retGroup.getQuotaType()); group.setPolicyId(retGroup.getPolicyId()); List<org.wso2.carbon.apimgt.internal.service.dto.ConditionDTO> condition = new ArrayList<org.wso2.carbon.apimgt.internal.service.dto.ConditionDTO>(); List<ConditionDTO> retrievedConditions = retGroup.getConditionDTOS(); for (ConditionDTO retrievedCondition : retrievedConditions) { org.wso2.carbon.apimgt.internal.service.dto.ConditionDTO conditionDTO = new org.wso2.carbon.apimgt.internal.service.dto.ConditionDTO(); conditionDTO.setConditionType(retrievedCondition.getConditionType()); conditionDTO.setIsInverted(retrievedCondition.isInverted()); conditionDTO.setName(retrievedCondition.getConditionName()); conditionDTO.setValue(retrievedCondition.getConditionValue()); condition.add(conditionDTO); } group.setCondition(condition); condGroups.add(group); } policyDTO.setConditionGroups(condGroups); } apiPolicyListDTO.setCount(model.size()); } else { apiPolicyListDTO.setCount(0); } return apiPolicyListDTO; }