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.HistoryVote; | |
9 | import org.cardanofoundation.explorer.api.projection.VotingProcedureProjection; | |
10 | ||
11 | @Mapper(componentModel = "spring") | |
12 | public interface VotingProcedureMapper { | |
13 | ||
14 | @Mapping(source = "votingProcedureTxHash", target = "txHash") | |
15 | @Mapping(source = "votingProcedureTxIndex", target = "txIndex") | |
16 | @Mapping( | |
17 | target = "timestamp", | |
18 | expression = "java(fromLong(votingProcedureProjection.getBlockTime()))") | |
19 | HistoryVote fromVotingProcedureProjection(VotingProcedureProjection votingProcedureProjection); | |
20 | ||
21 | default Date fromLong(Long value) { | |
22 |
3
1. fromLong : Replaced long multiplication with division → SURVIVED 2. fromLong : negated conditional → SURVIVED 3. fromLong : replaced return value with null for org/cardanofoundation/explorer/api/mapper/VotingProcedureMapper::fromLong → SURVIVED |
return value == null ? null : new Date(value * 1000); |
23 | } | |
24 | } | |
Mutations | ||
22 |
1.1 2.2 3.3 |