1 | package org.cardanofoundation.explorer.api.specification; | |
2 | ||
3 | import java.util.ArrayList; | |
4 | import java.util.List; | |
5 | ||
6 | import jakarta.persistence.criteria.Predicate; | |
7 | ||
8 | import org.springframework.data.jpa.domain.Specification; | |
9 | ||
10 | import org.cardanofoundation.explorer.api.model.request.script.nativescript.NativeScriptFilterRequest; | |
11 | import org.cardanofoundation.explorer.common.entity.explorer.NativeScriptInfo; | |
12 | import org.cardanofoundation.explorer.common.entity.explorer.NativeScriptInfo_; | |
13 | ||
14 | public class NativeScriptInfoSpecification { | |
15 | ||
16 | public static Specification<NativeScriptInfo> filter( | |
17 | Long currentSlot, NativeScriptFilterRequest filterRequest) { | |
18 |
1
1. filter : replaced return value with null for org/cardanofoundation/explorer/api/specification/NativeScriptInfoSpecification::filter → KILLED |
return (root, query, cb) -> { |
19 | final List<Specification<NativeScriptInfo>> predicates = new ArrayList<>(); | |
20 |
1
1. lambda$filter$8cecd285$1 : negated conditional → NO_COVERAGE |
if (filterRequest.getOpenTimeLocked() != null) { |
21 | predicates.add(filterByTimeLock(currentSlot, filterRequest.getOpenTimeLocked())); | |
22 | } | |
23 |
1
1. lambda$filter$8cecd285$1 : negated conditional → NO_COVERAGE |
if (filterRequest.getIsMultiSig() != null) { |
24 | predicates.add(filterByIsMultiSig(filterRequest.getIsMultiSig())); | |
25 | } | |
26 |
1
1. lambda$filter$8cecd285$1 : replaced return value with null for org/cardanofoundation/explorer/api/specification/NativeScriptInfoSpecification::lambda$filter$8cecd285$1 → NO_COVERAGE |
return cb.and( |
27 | predicates.stream() | |
28 |
1
1. lambda$filter$0 : replaced return value with null for org/cardanofoundation/explorer/api/specification/NativeScriptInfoSpecification::lambda$filter$0 → NO_COVERAGE |
.map(item -> item.toPredicate(root, query, cb)) |
29 |
1
1. lambda$filter$1 : replaced return value with null for org/cardanofoundation/explorer/api/specification/NativeScriptInfoSpecification::lambda$filter$1 → NO_COVERAGE |
.toArray(Predicate[]::new)); |
30 | }; | |
31 | } | |
32 | ||
33 | public static Specification<NativeScriptInfo> filterByTimeLock( | |
34 | Long currentSlot, Boolean openTimeLocked) { | |
35 |
1
1. filterByTimeLock : replaced return value with null for org/cardanofoundation/explorer/api/specification/NativeScriptInfoSpecification::filterByTimeLock → NO_COVERAGE |
return (root, query, cb) -> { |
36 |
1
1. lambda$filterByTimeLock$7eedb4d7$1 : negated conditional → NO_COVERAGE |
if (openTimeLocked == null) { |
37 | return null; | |
38 | } else { | |
39 | Predicate afterSlotIsNullPredicate = cb.isNull(root.get(NativeScriptInfo_.AFTER_SLOT)); | |
40 | Predicate beforeSlotIsNullPredicate = cb.isNull(root.get(NativeScriptInfo_.BEFORE_SLOT)); | |
41 | Predicate afterSlotIsLessThanCurrentSlotPredicate = | |
42 | cb.lessThan(root.get(NativeScriptInfo_.AFTER_SLOT), currentSlot); | |
43 | Predicate beforeSlotIsGreaterThanCurrentSlotPredicate = | |
44 | cb.greaterThan(root.get(NativeScriptInfo_.BEFORE_SLOT), currentSlot); | |
45 | Predicate afterSlotIsLessThanCurrentSlotAndBeforeSlotIsGreaterThanCurrentSlotPredicate = | |
46 | cb.and( | |
47 | afterSlotIsLessThanCurrentSlotPredicate, | |
48 | beforeSlotIsGreaterThanCurrentSlotPredicate); | |
49 | Predicate afterSlotIsNullAndBeforeSlotIsGreaterThanCurrentSlotPredicate = | |
50 | cb.and(afterSlotIsNullPredicate, beforeSlotIsGreaterThanCurrentSlotPredicate); | |
51 | Predicate afterSlotIsLessThanCurrentSlotAndBeforeSlotIsNullPredicate = | |
52 | cb.and(afterSlotIsLessThanCurrentSlotPredicate, beforeSlotIsNullPredicate); | |
53 | Predicate afterSlotIsNullAndBeforeSlotIsNullPredicate = | |
54 | cb.and(afterSlotIsNullPredicate, beforeSlotIsNullPredicate); | |
55 | Predicate openTimeLockedPredicate = | |
56 | cb.or( | |
57 | afterSlotIsLessThanCurrentSlotAndBeforeSlotIsGreaterThanCurrentSlotPredicate, | |
58 | afterSlotIsNullAndBeforeSlotIsGreaterThanCurrentSlotPredicate, | |
59 | afterSlotIsLessThanCurrentSlotAndBeforeSlotIsNullPredicate, | |
60 | afterSlotIsNullAndBeforeSlotIsNullPredicate); | |
61 |
1
1. lambda$filterByTimeLock$7eedb4d7$1 : negated conditional → NO_COVERAGE |
if (openTimeLocked) { |
62 |
1
1. lambda$filterByTimeLock$7eedb4d7$1 : replaced return value with null for org/cardanofoundation/explorer/api/specification/NativeScriptInfoSpecification::lambda$filterByTimeLock$7eedb4d7$1 → NO_COVERAGE |
return openTimeLockedPredicate; |
63 | } else { | |
64 |
1
1. lambda$filterByTimeLock$7eedb4d7$1 : replaced return value with null for org/cardanofoundation/explorer/api/specification/NativeScriptInfoSpecification::lambda$filterByTimeLock$7eedb4d7$1 → NO_COVERAGE |
return cb.not(openTimeLockedPredicate); |
65 | } | |
66 | } | |
67 | }; | |
68 | } | |
69 | ||
70 | public static Specification<NativeScriptInfo> filterByIsMultiSig(Boolean isMultiSig) { | |
71 |
1
1. filterByIsMultiSig : replaced return value with null for org/cardanofoundation/explorer/api/specification/NativeScriptInfoSpecification::filterByIsMultiSig → NO_COVERAGE |
return (root, query, cb) -> { |
72 |
1
1. lambda$filterByIsMultiSig$67844e7d$1 : negated conditional → NO_COVERAGE |
if (isMultiSig == null) { |
73 | return null; | |
74 |
1
1. lambda$filterByIsMultiSig$67844e7d$1 : negated conditional → NO_COVERAGE |
} else if (isMultiSig) { |
75 |
1
1. lambda$filterByIsMultiSig$67844e7d$1 : replaced return value with null for org/cardanofoundation/explorer/api/specification/NativeScriptInfoSpecification::lambda$filterByIsMultiSig$67844e7d$1 → NO_COVERAGE |
return cb.greaterThan(root.get(NativeScriptInfo_.NUMBER_SIG), 1L); |
76 | } else { | |
77 |
1
1. lambda$filterByIsMultiSig$67844e7d$1 : replaced return value with null for org/cardanofoundation/explorer/api/specification/NativeScriptInfoSpecification::lambda$filterByIsMultiSig$67844e7d$1 → NO_COVERAGE |
return cb.lessThanOrEqualTo(root.get(NativeScriptInfo_.NUMBER_SIG), 1L); |
78 | } | |
79 | }; | |
80 | } | |
81 | } | |
Mutations | ||
18 |
1.1 |
|
20 |
1.1 |
|
23 |
1.1 |
|
26 |
1.1 |
|
28 |
1.1 |
|
29 |
1.1 |
|
35 |
1.1 |
|
36 |
1.1 |
|
61 |
1.1 |
|
62 |
1.1 |
|
64 |
1.1 |
|
71 |
1.1 |
|
72 |
1.1 |
|
74 |
1.1 |
|
75 |
1.1 |
|
77 |
1.1 |