1 | package org.cardanofoundation.explorer.api.model.response; | |
2 | ||
3 | import java.io.Serializable; | |
4 | import java.util.List; | |
5 | ||
6 | import lombok.AllArgsConstructor; | |
7 | import lombok.Builder; | |
8 | import lombok.Getter; | |
9 | import lombok.NoArgsConstructor; | |
10 | import lombok.Setter; | |
11 | ||
12 | import org.springframework.data.domain.Page; | |
13 | import org.springframework.data.domain.PageImpl; | |
14 | import org.springframework.data.domain.Pageable; | |
15 | ||
16 | @Getter | |
17 | @Setter | |
18 | @AllArgsConstructor | |
19 | @NoArgsConstructor | |
20 |
8
1. toString : replaced return value with "" for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse$BaseFilterResponseBuilder::toString → NO_COVERAGE 2. currentPage : replaced return value with null for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse$BaseFilterResponseBuilder::currentPage → NO_COVERAGE 3. build : replaced return value with null for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse$BaseFilterResponseBuilder::build → NO_COVERAGE 4. data : replaced return value with null for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse$BaseFilterResponseBuilder::data → NO_COVERAGE 5. totalItems : replaced return value with null for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse$BaseFilterResponseBuilder::totalItems → NO_COVERAGE 6. totalPages : replaced return value with null for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse$BaseFilterResponseBuilder::totalPages → NO_COVERAGE 7. builder : replaced return value with null for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse::builder → NO_COVERAGE 8. isDataOverSize : replaced return value with null for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse$BaseFilterResponseBuilder::isDataOverSize → NO_COVERAGE |
@Builder |
21 | public class BaseFilterResponse<T> implements Serializable { | |
22 | ||
23 |
1
1. getData : replaced return value with Collections.emptyList for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse::getData → KILLED |
private List<T> data; |
24 |
1
1. getTotalItems : replaced long return with 0 for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse::getTotalItems → KILLED |
private long totalItems; |
25 |
1
1. getTotalPages : replaced int return with 0 for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse::getTotalPages → KILLED |
private int totalPages; |
26 |
1
1. getCurrentPage : replaced int return with 0 for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse::getCurrentPage → SURVIVED |
private int currentPage; |
27 |
2
1. getIsDataOverSize : replaced Boolean return with False for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse::getIsDataOverSize → SURVIVED 2. getIsDataOverSize : replaced Boolean return with True for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse::getIsDataOverSize → SURVIVED |
private Boolean isDataOverSize; |
28 | ||
29 | public BaseFilterResponse(Page<T> page) { | |
30 | this.data = page.getContent(); | |
31 | this.totalItems = page.getTotalElements(); | |
32 | this.totalPages = page.getTotalPages(); | |
33 | this.currentPage = page.getNumber(); | |
34 | } | |
35 | ||
36 | public <S> BaseFilterResponse(Page<S> page, List<T> data) { | |
37 | this.data = data; | |
38 | this.totalItems = page.getTotalElements(); | |
39 | this.totalPages = page.getTotalPages(); | |
40 | this.currentPage = page.getNumber(); | |
41 | } | |
42 | ||
43 | public <S> BaseFilterResponse(List<T> data, long totalItems) { | |
44 | this.data = data; | |
45 | this.totalItems = totalItems; | |
46 | } | |
47 | ||
48 | public <S> BaseFilterResponse(List<T> data, long totalItems, int totalPages, int currentPage) { | |
49 | this.data = data; | |
50 | this.totalItems = totalItems; | |
51 | this.totalPages = totalPages; | |
52 | this.currentPage = currentPage; | |
53 | } | |
54 | ||
55 | public BaseFilterResponse(Page<T> page, boolean isDataOverSize) { | |
56 | this.data = page.getContent(); | |
57 | this.totalItems = page.getTotalElements(); | |
58 | this.totalPages = page.getTotalPages(); | |
59 | this.currentPage = page.getNumber(); | |
60 | this.isDataOverSize = isDataOverSize; | |
61 | } | |
62 | ||
63 | public static <T> Page<T> getPageImpl(List<T> lst, Pageable pageable) { | |
64 | final int start = (int) pageable.getOffset(); | |
65 |
1
1. getPageImpl : Replaced integer addition with subtraction → KILLED |
final int end = Math.min((start + pageable.getPageSize()), lst.size()); |
66 |
2
1. getPageImpl : changed conditional boundary → SURVIVED 2. getPageImpl : negated conditional → KILLED |
if (start > lst.size()) { |
67 |
1
1. getPageImpl : replaced return value with null for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse::getPageImpl → NO_COVERAGE |
return Page.empty(); |
68 | } | |
69 |
1
1. getPageImpl : replaced return value with null for org/cardanofoundation/explorer/api/model/response/BaseFilterResponse::getPageImpl → KILLED |
return new PageImpl<>(lst.subList(start, end), pageable, lst.size()); |
70 | } | |
71 | } | |
Mutations | ||
20 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
23 |
1.1 |
|
24 |
1.1 |
|
25 |
1.1 |
|
26 |
1.1 |
|
27 |
1.1 2.2 |
|
65 |
1.1 |
|
66 |
1.1 2.2 |
|
67 |
1.1 |
|
69 |
1.1 |