1 | package org.cardanofoundation.explorer.api.mapper; | |
2 | ||
3 | import java.sql.Timestamp; | |
4 | import java.time.Duration; | |
5 | import java.time.LocalDateTime; | |
6 | import java.util.Date; | |
7 | import java.util.GregorianCalendar; | |
8 | import javax.annotation.processing.Generated; | |
9 | import javax.xml.datatype.DatatypeConfigurationException; | |
10 | import javax.xml.datatype.DatatypeConstants; | |
11 | import javax.xml.datatype.DatatypeFactory; | |
12 | import javax.xml.datatype.XMLGregorianCalendar; | |
13 | import org.cardanofoundation.explorer.api.model.response.token.TokenMintTxResponse; | |
14 | import org.cardanofoundation.explorer.api.model.response.tx.TxMintingResponse; | |
15 | import org.cardanofoundation.explorer.api.projection.AddressInputOutputProjection; | |
16 | import org.cardanofoundation.explorer.api.projection.MintProjection; | |
17 | import org.cardanofoundation.explorer.api.util.HexUtils; | |
18 | import org.cardanofoundation.explorer.common.entity.ledgersync.Block; | |
19 | import org.cardanofoundation.explorer.common.entity.ledgersync.MaTxMint; | |
20 | import org.cardanofoundation.explorer.common.entity.ledgersync.Tx; | |
21 | import org.springframework.stereotype.Component; | |
22 | ||
23 | @Generated( | |
24 | value = "org.mapstruct.ap.MappingProcessor", | |
25 | date = "2024-11-05T06:00:27+0000", | |
26 | comments = "version: 1.5.3.Final, compiler: javac, environment: Java 18.0.2.1 (Eclipse Adoptium)" | |
27 | ) | |
28 | @Component | |
29 | public class MaTxMintMapperImpl extends MaTxMintMapper { | |
30 | ||
31 | private final DatatypeFactory datatypeFactory; | |
32 | ||
33 | public MaTxMintMapperImpl() { | |
34 | try { | |
35 | datatypeFactory = DatatypeFactory.newInstance(); | |
36 | } | |
37 | catch ( DatatypeConfigurationException ex ) { | |
38 | throw new RuntimeException( ex ); | |
39 | } | |
40 | } | |
41 | ||
42 | @Override | |
43 | public TxMintingResponse fromAddressInputOutputProjection(AddressInputOutputProjection input) { | |
44 |
1
1. fromAddressInputOutputProjection : negated conditional → NO_COVERAGE |
if ( input == null ) { |
45 | return null; | |
46 | } | |
47 | ||
48 | TxMintingResponse.TxMintingResponseBuilder txMintingResponse = TxMintingResponse.builder(); | |
49 | ||
50 | txMintingResponse.assetQuantity( input.getAssetQuantity() ); | |
51 | txMintingResponse.multiAssetId( input.getMultiAssetId() ); | |
52 | ||
53 | txMintingResponse.assetName( HexUtils.fromHex(input.getAssetName(), input.getAssetId()) ); | |
54 | txMintingResponse.assetId( input.getAssetId() ); | |
55 | ||
56 |
1
1. fromAddressInputOutputProjection : replaced return value with null for org/cardanofoundation/explorer/api/mapper/MaTxMintMapperImpl::fromAddressInputOutputProjection → NO_COVERAGE |
return txMintingResponse.build(); |
57 | } | |
58 | ||
59 | @Override | |
60 | public TokenMintTxResponse fromMaTxMintToTokenMintTx(MaTxMint maTxMint) { | |
61 |
1
1. fromMaTxMintToTokenMintTx : negated conditional → NO_COVERAGE |
if ( maTxMint == null ) { |
62 | return null; | |
63 | } | |
64 | ||
65 | TokenMintTxResponse tokenMintTxResponse = new TokenMintTxResponse(); | |
66 | ||
67 |
1
1. fromMaTxMintToTokenMintTx : negated conditional → NO_COVERAGE |
if ( maTxMint.getQuantity() != null ) { |
68 |
1
1. fromMaTxMintToTokenMintTx : removed call to org/cardanofoundation/explorer/api/model/response/token/TokenMintTxResponse::setAmount → NO_COVERAGE |
tokenMintTxResponse.setAmount( maTxMint.getQuantity().toString() ); |
69 | } | |
70 |
1
1. fromMaTxMintToTokenMintTx : removed call to org/cardanofoundation/explorer/api/model/response/token/TokenMintTxResponse::setTime → NO_COVERAGE |
tokenMintTxResponse.setTime( xmlGregorianCalendarToLocalDateTime( dateToXmlGregorianCalendar( maTxMintTxBlockTime( maTxMint ) ) ) ); |
71 | ||
72 |
1
1. fromMaTxMintToTokenMintTx : removed call to org/cardanofoundation/explorer/api/model/response/token/TokenMintTxResponse::setTxHash → NO_COVERAGE |
tokenMintTxResponse.setTxHash( maTxMint.getTx().getHash() ); |
73 | ||
74 |
1
1. fromMaTxMintToTokenMintTx : replaced return value with null for org/cardanofoundation/explorer/api/mapper/MaTxMintMapperImpl::fromMaTxMintToTokenMintTx → NO_COVERAGE |
return tokenMintTxResponse; |
75 | } | |
76 | ||
77 | @Override | |
78 | public TxMintingResponse fromMintProjectionToTxMintingResponse(MintProjection mintProjection) { | |
79 |
1
1. fromMintProjectionToTxMintingResponse : negated conditional → NO_COVERAGE |
if ( mintProjection == null ) { |
80 | return null; | |
81 | } | |
82 | ||
83 | TxMintingResponse.TxMintingResponseBuilder txMintingResponse = TxMintingResponse.builder(); | |
84 | ||
85 | txMintingResponse.policy( mintProjection.getPolicy() ); | |
86 | txMintingResponse.assetQuantity( mintProjection.getAssetQuantity() ); | |
87 | txMintingResponse.assetId( mintProjection.getFingerprint() ); | |
88 | ||
89 | txMintingResponse.assetName( HexUtils.fromHex(mintProjection.getName(), mintProjection.getFingerprint()) ); | |
90 | txMintingResponse.metadata( getMetadata(mintProjection) ); | |
91 | ||
92 |
1
1. fromMintProjectionToTxMintingResponse : replaced return value with null for org/cardanofoundation/explorer/api/mapper/MaTxMintMapperImpl::fromMintProjectionToTxMintingResponse → NO_COVERAGE |
return txMintingResponse.build(); |
93 | } | |
94 | ||
95 | private XMLGregorianCalendar dateToXmlGregorianCalendar( Date date ) { | |
96 |
1
1. dateToXmlGregorianCalendar : negated conditional → NO_COVERAGE |
if ( date == null ) { |
97 | return null; | |
98 | } | |
99 | ||
100 | GregorianCalendar c = new GregorianCalendar(); | |
101 |
1
1. dateToXmlGregorianCalendar : removed call to java/util/GregorianCalendar::setTime → NO_COVERAGE |
c.setTime( date ); |
102 |
1
1. dateToXmlGregorianCalendar : replaced return value with null for org/cardanofoundation/explorer/api/mapper/MaTxMintMapperImpl::dateToXmlGregorianCalendar → NO_COVERAGE |
return datatypeFactory.newXMLGregorianCalendar( c ); |
103 | } | |
104 | ||
105 | private static LocalDateTime xmlGregorianCalendarToLocalDateTime( XMLGregorianCalendar xcal ) { | |
106 |
1
1. xmlGregorianCalendarToLocalDateTime : negated conditional → NO_COVERAGE |
if ( xcal == null ) { |
107 | return null; | |
108 | } | |
109 | ||
110 |
1
1. xmlGregorianCalendarToLocalDateTime : negated conditional → NO_COVERAGE |
if ( xcal.getYear() != DatatypeConstants.FIELD_UNDEFINED |
111 |
1
1. xmlGregorianCalendarToLocalDateTime : negated conditional → NO_COVERAGE |
&& xcal.getMonth() != DatatypeConstants.FIELD_UNDEFINED |
112 |
1
1. xmlGregorianCalendarToLocalDateTime : negated conditional → NO_COVERAGE |
&& xcal.getDay() != DatatypeConstants.FIELD_UNDEFINED |
113 |
1
1. xmlGregorianCalendarToLocalDateTime : negated conditional → NO_COVERAGE |
&& xcal.getHour() != DatatypeConstants.FIELD_UNDEFINED |
114 |
1
1. xmlGregorianCalendarToLocalDateTime : negated conditional → NO_COVERAGE |
&& xcal.getMinute() != DatatypeConstants.FIELD_UNDEFINED |
115 | ) { | |
116 |
1
1. xmlGregorianCalendarToLocalDateTime : negated conditional → NO_COVERAGE |
if ( xcal.getSecond() != DatatypeConstants.FIELD_UNDEFINED |
117 |
1
1. xmlGregorianCalendarToLocalDateTime : negated conditional → NO_COVERAGE |
&& xcal.getMillisecond() != DatatypeConstants.FIELD_UNDEFINED ) { |
118 |
1
1. xmlGregorianCalendarToLocalDateTime : replaced return value with null for org/cardanofoundation/explorer/api/mapper/MaTxMintMapperImpl::xmlGregorianCalendarToLocalDateTime → NO_COVERAGE |
return LocalDateTime.of( |
119 | xcal.getYear(), | |
120 | xcal.getMonth(), | |
121 | xcal.getDay(), | |
122 | xcal.getHour(), | |
123 | xcal.getMinute(), | |
124 | xcal.getSecond(), | |
125 | Duration.ofMillis( xcal.getMillisecond() ).getNano() | |
126 | ); | |
127 | } | |
128 |
1
1. xmlGregorianCalendarToLocalDateTime : negated conditional → NO_COVERAGE |
else if ( xcal.getSecond() != DatatypeConstants.FIELD_UNDEFINED ) { |
129 |
1
1. xmlGregorianCalendarToLocalDateTime : replaced return value with null for org/cardanofoundation/explorer/api/mapper/MaTxMintMapperImpl::xmlGregorianCalendarToLocalDateTime → NO_COVERAGE |
return LocalDateTime.of( |
130 | xcal.getYear(), | |
131 | xcal.getMonth(), | |
132 | xcal.getDay(), | |
133 | xcal.getHour(), | |
134 | xcal.getMinute(), | |
135 | xcal.getSecond() | |
136 | ); | |
137 | } | |
138 | else { | |
139 |
1
1. xmlGregorianCalendarToLocalDateTime : replaced return value with null for org/cardanofoundation/explorer/api/mapper/MaTxMintMapperImpl::xmlGregorianCalendarToLocalDateTime → NO_COVERAGE |
return LocalDateTime.of( |
140 | xcal.getYear(), | |
141 | xcal.getMonth(), | |
142 | xcal.getDay(), | |
143 | xcal.getHour(), | |
144 | xcal.getMinute() | |
145 | ); | |
146 | } | |
147 | } | |
148 | return null; | |
149 | } | |
150 | ||
151 | private Timestamp maTxMintTxBlockTime(MaTxMint maTxMint) { | |
152 |
1
1. maTxMintTxBlockTime : negated conditional → NO_COVERAGE |
if ( maTxMint == null ) { |
153 | return null; | |
154 | } | |
155 | Tx tx = maTxMint.getTx(); | |
156 |
1
1. maTxMintTxBlockTime : negated conditional → NO_COVERAGE |
if ( tx == null ) { |
157 | return null; | |
158 | } | |
159 | Block block = tx.getBlock(); | |
160 |
1
1. maTxMintTxBlockTime : negated conditional → NO_COVERAGE |
if ( block == null ) { |
161 | return null; | |
162 | } | |
163 | Timestamp time = block.getTime(); | |
164 |
1
1. maTxMintTxBlockTime : negated conditional → NO_COVERAGE |
if ( time == null ) { |
165 | return null; | |
166 | } | |
167 |
1
1. maTxMintTxBlockTime : replaced return value with null for org/cardanofoundation/explorer/api/mapper/MaTxMintMapperImpl::maTxMintTxBlockTime → NO_COVERAGE |
return time; |
168 | } | |
169 | } | |
Mutations | ||
44 |
1.1 |
|
56 |
1.1 |
|
61 |
1.1 |
|
67 |
1.1 |
|
68 |
1.1 |
|
70 |
1.1 |
|
72 |
1.1 |
|
74 |
1.1 |
|
79 |
1.1 |
|
92 |
1.1 |
|
96 |
1.1 |
|
101 |
1.1 |
|
102 |
1.1 |
|
106 |
1.1 |
|
110 |
1.1 |
|
111 |
1.1 |
|
112 |
1.1 |
|
113 |
1.1 |
|
114 |
1.1 |
|
116 |
1.1 |
|
117 |
1.1 |
|
118 |
1.1 |
|
128 |
1.1 |
|
129 |
1.1 |
|
139 |
1.1 |
|
152 |
1.1 |
|
156 |
1.1 |
|
160 |
1.1 |
|
164 |
1.1 |
|
167 |
1.1 |