diff --git a/beekeeper-api/src/main/java/com/expediagroup/beekeeper/api/response/PathResponseConverter.java b/beekeeper-api/src/main/java/com/expediagroup/beekeeper/api/response/PathResponseConverter.java index b948610f..73c80d61 100644 --- a/beekeeper-api/src/main/java/com/expediagroup/beekeeper/api/response/PathResponseConverter.java +++ b/beekeeper-api/src/main/java/com/expediagroup/beekeeper/api/response/PathResponseConverter.java @@ -30,35 +30,29 @@ but currently projections do not support using Specification (See https://github Therefore, this is a 'manual' conversion of the HousekeepingPath object, which will be used in the API. */ -public class PathResponseConverter { - - private static HousekeepingPathResponse convertToHousekeepingPathResponse(HousekeepingPath housekeepingPath) { - return HousekeepingPathResponse - .builder() - .path(housekeepingPath.getPath()) - .databaseName(housekeepingPath.getDatabaseName()) - .tableName(housekeepingPath.getTableName()) - .housekeepingStatus(housekeepingPath.getHousekeepingStatus()) - .creationTimestamp(housekeepingPath.getCreationTimestamp()) - .modifiedTimestamp(housekeepingPath.getModifiedTimestamp()) - .cleanupTimestamp(housekeepingPath.getCleanupTimestamp()) - .cleanupDelay(housekeepingPath.getCleanupDelay().toString()) - .cleanupAttempts(housekeepingPath.getCleanupAttempts()) - .lifecycleType(housekeepingPath.getLifecycleType()) - .build(); - } - - public static Page convertToHousekeepingPathResponsePage( - Page housekeepingPathPage) { - List housekeepingPathList = housekeepingPathPage.getContent(); - List housekeepingPathResponseList = new ArrayList<>(); - for (HousekeepingPath housekeepingPath : housekeepingPathList) { - HousekeepingPathResponse housekeepingPathResponse = convertToHousekeepingPathResponse(housekeepingPath); - housekeepingPathResponseList.add(housekeepingPathResponse); +public class PathResponseFacade { + + public static HousekeepingPathResponse convert(HousekeepingPath housekeepingPath) { + return HousekeepingPathResponse + .builder() + .path(housekeepingPath.getPath()) + .databaseName(housekeepingPath.getDatabaseName()) + .tableName(housekeepingPath.getTableName()) + .housekeepingStatus(housekeepingPath.getHousekeepingStatus()) + .creationTimestamp(housekeepingPath.getCreationTimestamp()) + .modifiedTimestamp(housekeepingPath.getModifiedTimestamp()) + .cleanupTimestamp(housekeepingPath.getCleanupTimestamp()) + .cleanupDelay(housekeepingPath.getCleanupDelay().toString()) + .cleanupAttempts(housekeepingPath.getCleanupAttempts()) + .lifecycleType(housekeepingPath.getLifecycleType()) + .build(); } - PageImpl housekeepingPathResponses = new PageImpl<>( - housekeepingPathResponseList, housekeepingPathPage.getPageable(), housekeepingPathPage.getTotalElements()); - return housekeepingPathResponses; - } + public static Page convertPage(Page housekeepingPathPage) { + List responses = new ArrayList<>(); + for (HousekeepingPath housekeepingPath : housekeepingPathPage.getContent()) { + responses.add(convert(housekeepingPath)); + } + return new PageImpl<>(responses, housekeepingPathPage.getPageable(), housekeepingPathPage.getTotalElements()); + } }