Skip to content

Commit f1f2bd8

Browse files
committed
Misc Cleanup
1 parent ae3a8ed commit f1f2bd8

File tree

2 files changed

+11
-133
lines changed

2 files changed

+11
-133
lines changed

xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TransactionDeserializer.java

Lines changed: 11 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -28,69 +28,39 @@
2828
import com.fasterxml.jackson.databind.node.ObjectNode;
2929
import org.xrpl.xrpl4j.model.transactions.Transaction;
3030
import org.xrpl.xrpl4j.model.transactions.TransactionType;
31-
import org.xrpl.xrpl4j.model.transactions.UnknownTransaction;
3231
import org.xrpl.xrpl4j.model.transactions.UnlModify;
3332

3433
import java.io.IOException;
35-
import java.util.Objects;
3634

3735
/**
3836
* Custom deserializer for {@link Transaction}s, which deserializes to a specific {@link Transaction} type based on the
3937
* TransactionType JSON field.
4038
*/
4139
public class TransactionDeserializer<T extends Transaction> extends StdDeserializer<T> {
42-
43-
private final Class<T> clazz;
44-
40+
4541
/**
4642
* No-args constructor.
4743
*/
4844
protected TransactionDeserializer() {
4945
super(Transaction.class);
50-
this.clazz = (Class<T>) Transaction.class;
5146
}
52-
53-
/**
54-
* No-args constructor.
55-
*/
56-
protected TransactionDeserializer(final Class<T> clazz) {
57-
super(Transaction.class);
58-
this.clazz = Objects.requireNonNull(clazz);
59-
}
60-
47+
6148
@Override
6249
public T deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException {
6350
ObjectMapper objectMapper = (ObjectMapper) jsonParser.getCodec();
6451
ObjectNode objectNode = objectMapper.readTree(jsonParser);
65-
52+
6653
JsonNode node = objectNode.get("TransactionType");
6754
TransactionType transactionType = TransactionType.forValue(node.asText());
55+
@SuppressWarnings("unchecked")
6856
Class<T> transactionTypeClass = (Class<T>) Transaction.typeMap.inverse().get(transactionType);
69-
70-
// TODO: DELETE (no longer needed
71-
// If the transaction is of type `UnknownTransaction`, the `TransactionType` property must _not_ be removed. Thi
72-
// is so that the derived functions related to `TransactionType` in that class operate properly. However, for all
73-
// _other_ transaction types, the `TransactionType` property _must_ be removed so that it doesn't errantly show up
74-
// in the `unknownTransactionType` map. This approach works because every subclass of `Transaction` has a derived
75-
// Java method that specifies the type (thus allowing us to ignore this fiele in the general case).
76-
// if (!UnknownTransaction.class.isAssignableFrom(transactionTypeClass)) {
77-
// objectNode.remove("TransactionType");
78-
// }
79-
80-
// If the transaction is of type `UnlModify`, then remove the `Account` property. This is because the JSON returned
81-
// by the rippled/clio API v1 has a bug where the account value is often an empty string. For this particular
82-
// transaction type (i.e., `UnlModify`) the Java value for the account is always set to ACCOUNT_ZERO via a default
83-
// method, so we remove this value from the JSON before deserialization because (1) it's not needed (the default
84-
// method handles population in Java) and (2) if not removed, this field will end up in the `unknownFields`
85-
// property, which is incorrect.
86-
// if (UnlModify.class.isAssignableFrom(transactionTypeClass)) {
87-
// // if (objectNode.get("Account").isEmpty()) {
88-
// if (objectNode.has("Account")) {
89-
// //objectNode.remove("Account");
90-
// }
91-
// }
92-
93-
// TODO: Verify, and document if keeping.
57+
58+
// Remove the `Account` property from any incoming UnlModify JSON about to be deserialized. This is because the JSON
59+
// returned by the rippled/clio API v1 has a bug where the account value is an empty string. For this particular
60+
// For `UnlModify` only, the Java value for the Account is always set to ACCOUNT_ZERO via a default
61+
// method, so this value is removed from the JSON before deserialization because it's not needed (the default
62+
// method handles population in Java) and if not removed, this field will end up in the `unknownFields`
63+
// map of the ultimate Java object, which is incorrect.
9464
if (UnlModify.class.isAssignableFrom(transactionTypeClass)) {
9565
objectNode.remove("Account");
9666
}

xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/UnlModifyTransactionSerializer.java

Lines changed: 0 additions & 92 deletions
This file was deleted.

0 commit comments

Comments
 (0)