|
19 | 19 | package org.spacious_team.broker.pojo; |
20 | 20 |
|
21 | 21 | import com.fasterxml.jackson.annotation.JsonInclude; |
22 | | -import com.fasterxml.jackson.core.JsonProcessingException; |
23 | | -import com.fasterxml.jackson.core.type.TypeReference; |
24 | | -import com.fasterxml.jackson.databind.ObjectMapper; |
| 22 | +import io.swagger.v3.oas.annotations.media.Schema; |
25 | 23 | import lombok.Builder; |
26 | 24 | import lombok.EqualsAndHashCode; |
27 | 25 | import lombok.Getter; |
|
30 | 28 |
|
31 | 29 | import java.math.BigDecimal; |
32 | 30 | import java.time.Instant; |
33 | | -import java.util.Collection; |
34 | | -import java.util.stream.Collectors; |
35 | 31 |
|
36 | 32 | import static lombok.EqualsAndHashCode.CacheStrategy.LAZY; |
37 | 33 |
|
|
42 | 38 | @Builder(toBuilder = true) |
43 | 39 | @EqualsAndHashCode(cacheStrategy = LAZY) |
44 | 40 | @JsonInclude(JsonInclude.Include.NON_NULL) |
| 41 | +@Schema(name = "Остаток денежных средств") |
45 | 42 | public class PortfolioCash { |
46 | | - private static final ObjectMapper objectMapper = new ObjectMapper(); |
47 | | - |
48 | 43 | //@Nullable // autoincrement |
| 44 | + @Schema(description = "Внутренний идентификатор", example = "123", nullable = true) |
49 | 45 | private final Integer id; |
| 46 | + |
| 47 | + @Schema(description = "Номер счета в системе учета брокера", example = "10200I", required = true) |
50 | 48 | private final String portfolio; |
| 49 | + |
| 50 | + @Schema(description = "Значение актуально на дату", example = "2021-01-23T12:00:00+03:00", required = true) |
51 | 51 | private final Instant timestamp; |
52 | | - private final String section; |
53 | | - private final BigDecimal value; |
54 | | - private final String currency; |
55 | 52 |
|
56 | | - /** |
57 | | - * Serializes in format: |
58 | | - * <pre> |
59 | | - * [ |
60 | | - * { |
61 | | - * "section": "forts", |
62 | | - * "value": "1000", |
63 | | - * "currency": "RUB" |
64 | | - * } |
65 | | - * ] |
66 | | - * </pre> |
67 | | - * {@code Portfolio} and {@code timestamp} fields are not serialized. |
68 | | - * Used to serialize portfolio cash for {@link PortfolioProperty.PortfolioPropertyBuilder#value(String)}. |
69 | | - */ |
70 | | - @Deprecated |
71 | | - public static String serialize(Collection<PortfolioCash> cash) { |
72 | | - try { |
73 | | - cash = cash.stream() |
74 | | - .map(PortfolioCash::toBuilder) |
75 | | - .map(builder -> builder.portfolio(null)) |
76 | | - .map(builder -> builder.timestamp(null)) |
77 | | - .map(PortfolioCashBuilder::build) |
78 | | - .collect(Collectors.toList()); |
79 | | - return objectMapper.writeValueAsString(cash); |
80 | | - } catch (JsonProcessingException e) { |
81 | | - throw new IllegalArgumentException("Can't serialize portfolio cash", e); |
82 | | - } |
83 | | - } |
| 53 | + @Schema(description = "Рынок", example = "Фондовый", nullable = true) |
| 54 | + private final String market; |
| 55 | + |
| 56 | + @Schema(description = "Остаток денежных средств", example = "102.30", required = true) |
| 57 | + private final BigDecimal value; |
84 | 58 |
|
85 | | - /** |
86 | | - * Used to deserialize portfolio cash from {@link PortfolioProperty#getValue()}. |
87 | | - */ |
88 | | - @Deprecated |
89 | | - public static Collection<PortfolioCash> deserialize(String value) { |
90 | | - try { |
91 | | - return objectMapper.readValue(value, new TypeReference<>() { |
92 | | - }); |
93 | | - } catch (Exception e) { |
94 | | - throw new IllegalArgumentException("Can't deserialize portfolio cash", e); |
95 | | - } |
96 | | - } |
| 59 | + @Schema(description = "Валюта", example = "RUB", required = true) |
| 60 | + private final String currency; |
97 | 61 | } |
0 commit comments