use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.ResourcePathDTO in project carbon-apimgt by wso2.
the class APIMappingUtil method fromResourcePathListToDTO.
/**
* Converts a List object of API resource paths into a DTO.
*
* @param resourcePathList List of API resource paths
* @param limit maximum number of API resource paths to be returned
* @param offset starting index
* @return ResourcePathListDTO object containing ResourcePathDTOs
*/
public static ResourcePathListDTO fromResourcePathListToDTO(List<ResourcePath> resourcePathList, int limit, int offset) {
ResourcePathListDTO resourcePathListDTO = new ResourcePathListDTO();
List<ResourcePathDTO> resourcePathDTOs = new ArrayList<ResourcePathDTO>();
// identifying the proper start and end indexes
int size = resourcePathList.size();
int start = offset < size && offset >= 0 ? offset : Integer.MAX_VALUE;
int end = offset + limit - 1 <= size - 1 ? offset + limit - 1 : size - 1;
for (int i = start; i <= end; i++) {
ResourcePath path = resourcePathList.get(i);
ResourcePathDTO dto = new ResourcePathDTO();
dto.setId(path.getId());
dto.setResourcePath(path.getResourcePath());
dto.setHttpVerb(path.getHttpVerb());
resourcePathDTOs.add(dto);
}
resourcePathListDTO.setCount(resourcePathDTOs.size());
resourcePathListDTO.setList(resourcePathDTOs);
return resourcePathListDTO;
}
Aggregations