|
13 | 13 | @Singleton |
14 | 14 | public class InstrumentInfoConverter implements EventConverter<InstrumentInfoEvent, String> { |
15 | 15 |
|
16 | | - private final Gson gson; |
17 | | - |
18 | | - @Inject |
19 | | - InstrumentInfoConverter() { |
20 | | - GsonBuilder gsonBuilder = new GsonBuilder(); |
21 | | - gson = gsonBuilder.create(); |
22 | | - } |
23 | | - |
24 | | - @Override |
25 | | - public String convert(InstrumentInfoEvent entity) { |
26 | | - StringBuilder builder = new StringBuilder(); |
27 | | - JsonObject json = gson.toJsonTree(entity.supportedFeatures, Layer1ApiProviderSupportedFeatures.class).getAsJsonObject(); |
28 | | - |
29 | | - json.remove("tradingVia"); |
30 | | - json.remove("tradingFrom"); |
31 | | - json.remove("knownInstruments"); |
32 | | - json.remove("lookupInfo"); |
33 | | - json.remove("pipsFunction"); |
34 | | - json.remove("sizeMultiplierFunction"); |
35 | | - json.remove("subscriptionInfoFunction"); |
36 | | - json.remove("historicalDataInfo"); |
37 | | - json.remove("receiveCrossTradingStatusMessage"); |
38 | | - json.remove("isHistoricalAggregationDisabled"); |
39 | | - |
40 | | - builder.append(entity.type.code); |
41 | | - builder.append(FIELDS_DELIMITER); |
42 | | - builder.append(entity.alias); |
43 | | - builder.append(FIELDS_DELIMITER); |
44 | | - builder.append(entity.fullName); |
45 | | - builder.append(FIELDS_DELIMITER); |
46 | | - builder.append(entity.isCrypto ? 1 : 0); |
47 | | - builder.append(FIELDS_DELIMITER); |
48 | | - builder.append(entity.pips); |
49 | | - builder.append(FIELDS_DELIMITER); |
50 | | - builder.append(entity.sizeMultiplier); |
51 | | - builder.append(FIELDS_DELIMITER); |
52 | | - builder.append(entity.instrumentMultiplier); |
53 | | - builder.append(FIELDS_DELIMITER); |
54 | | - builder.append(json); |
55 | | - |
56 | | - return builder.toString(); |
57 | | - } |
| 16 | + private final Gson gson; |
| 17 | + |
| 18 | + @Inject |
| 19 | + InstrumentInfoConverter() { |
| 20 | + GsonBuilder gsonBuilder = new GsonBuilder(); |
| 21 | + gson = gsonBuilder.create(); |
| 22 | + } |
| 23 | + |
| 24 | + @Override |
| 25 | + public String convert(InstrumentInfoEvent entity) { |
| 26 | + StringBuilder builder = new StringBuilder(); |
| 27 | + |
| 28 | + builder.append(entity.type.code); |
| 29 | + builder.append(FIELDS_DELIMITER); |
| 30 | + builder.append(entity.alias); |
| 31 | + builder.append(FIELDS_DELIMITER); |
| 32 | + builder.append(entity.fullName); |
| 33 | + builder.append(FIELDS_DELIMITER); |
| 34 | + builder.append(entity.isCrypto ? 1 : 0); |
| 35 | + builder.append(FIELDS_DELIMITER); |
| 36 | + builder.append(entity.pips); |
| 37 | + builder.append(FIELDS_DELIMITER); |
| 38 | + builder.append(entity.sizeMultiplier); |
| 39 | + builder.append(FIELDS_DELIMITER); |
| 40 | + builder.append(entity.instrumentMultiplier); |
| 41 | + builder.append(FIELDS_DELIMITER); |
| 42 | + |
| 43 | + if (entity.supportedFeatures != null) { |
| 44 | + JsonObject json = gson.toJsonTree(entity.supportedFeatures, Layer1ApiProviderSupportedFeatures.class).getAsJsonObject(); |
| 45 | + json.remove("tradingVia"); |
| 46 | + json.remove("tradingFrom"); |
| 47 | + json.remove("knownInstruments"); |
| 48 | + json.remove("lookupInfo"); |
| 49 | + json.remove("pipsFunction"); |
| 50 | + json.remove("sizeMultiplierFunction"); |
| 51 | + json.remove("subscriptionInfoFunction"); |
| 52 | + json.remove("historicalDataInfo"); |
| 53 | + json.remove("receiveCrossTradingStatusMessage"); |
| 54 | + json.remove("isHistoricalAggregationDisabled"); |
| 55 | + builder.append(json); |
| 56 | + } else { |
| 57 | + builder.append("{}"); |
| 58 | + } |
| 59 | + |
| 60 | + return builder.toString(); |
| 61 | + } |
58 | 62 | } |
0 commit comments