1 | package org.cardanofoundation.explorer.api.mapper; | |
2 | ||
3 | import java.util.Date; | |
4 | ||
5 | import org.mapstruct.Mapper; | |
6 | import org.mapstruct.Mapping; | |
7 | ||
8 | import org.cardanofoundation.explorer.api.model.response.governanceAction.GovernanceActionDetailsResponse; | |
9 | import org.cardanofoundation.explorer.api.model.response.governanceAction.GovernanceActionOverViewResponse; | |
10 | import org.cardanofoundation.explorer.api.model.response.governanceAction.GovernanceActionResponse; | |
11 | import org.cardanofoundation.explorer.api.projection.GovActionDetailsProjection; | |
12 | import org.cardanofoundation.explorer.api.projection.GovernanceActionOverviewProjection; | |
13 | import org.cardanofoundation.explorer.api.projection.GovernanceActionProjection; | |
14 | ||
15 | @Mapper(componentModel = "spring") | |
16 | public interface GovernanceActionMapper { | |
17 | ||
18 | @Mapping(source = "status", target = "status") | |
19 | @Mapping(source = "repeatVote", target = "isRepeatVote") | |
20 | @Mapping( | |
21 | target = "createdAt", | |
22 | expression = "java(fromLong(governanceActionProjection.getCreatedAt()))") | |
23 | GovernanceActionResponse fromGovernanceActionProjection( | |
24 | GovernanceActionProjection governanceActionProjection); | |
25 | ||
26 | @Mapping(source = "type", target = "govActionType") | |
27 | @Mapping( | |
28 | target = "submissionDate", | |
29 | expression = "java(fromLong(govActionDetailsProjection.getBlockTime()))") | |
30 | GovernanceActionDetailsResponse fromGovActionDetailsProjection( | |
31 | GovActionDetailsProjection govActionDetailsProjection); | |
32 | ||
33 | @Mapping(source = "abstract", target = "abstractContent") | |
34 | @Mapping( | |
35 | target = "dateCreated", | |
36 | expression = "java(fromLong(governanceActionOverviewProjection.getDateCreated()))") | |
37 | GovernanceActionOverViewResponse fromGovernanceActionOverviewProjection( | |
38 | GovernanceActionOverviewProjection governanceActionOverviewProjection); | |
39 | ||
40 | default Date fromLong(Long value) { | |
41 |
3
1. fromLong : negated conditional → KILLED 2. fromLong : replaced return value with null for org/cardanofoundation/explorer/api/mapper/GovernanceActionMapper::fromLong → KILLED 3. fromLong : Replaced long multiplication with division → KILLED |
return value == null ? null : new Date(value * 1000); |
42 | } | |
43 | } | |
Mutations | ||
41 |
1.1 2.2 3.3 |