Skip to content

Commit

Permalink
restore jakarta validation annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
vananiev committed Nov 6, 2024
1 parent 4bde784 commit 5d3902a
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package ru.investbook.web.forms.model;

import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive;
import lombok.Data;
import org.checkerframework.checker.nullness.qual.Nullable;
Expand All @@ -41,17 +42,17 @@ public class EventCashFlowModel {
private @NotEmpty String portfolio;

@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate date = LocalDate.now();
private @NotNull LocalDate date = LocalDate.now();

@DateTimeFormat(pattern = "HH:mm:ss")
private LocalTime time = LocalTime.NOON;
private @NotNull LocalTime time = LocalTime.NOON;

private CashFlowType type;
private @NotNull CashFlowType type;

/**
* Negative value for cash out, otherwise - positive
*/
private BigDecimal value;
private @NotNull BigDecimal value;

private @NotEmpty String valueCurrency = "RUB";

Expand Down Expand Up @@ -114,7 +115,8 @@ public class AttachedSecurity {
*/
private @Nullable String security;

private @Nullable @Positive Integer count;
private @Nullable
@Positive Integer count;

public boolean isValid() {
return hasLength(security) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package ru.investbook.web.forms.model;

import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
Expand All @@ -34,9 +35,10 @@ public class ForeignExchangeRateModel {

private @NotEmpty String baseCurrency;

@NotEmpty String quoteCurrency;
@NotEmpty
String quoteCurrency;

private @Positive BigDecimal rate;
private @Positive @NotNull BigDecimal rate;

public void setBaseCurrency(String currency) {
this.baseCurrency = currency.toUpperCase();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package ru.investbook.web.forms.model;

import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.checkerframework.checker.nullness.qual.Nullable;
Expand All @@ -39,12 +40,12 @@ public class PortfolioCashModel {
private @Nullable String market;

@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate date = LocalDate.now();
private @NotNull LocalDate date = LocalDate.now();

@DateTimeFormat(pattern = "HH:mm:ss")
private LocalTime time = LocalTime.NOON;
private @NotNull LocalTime time = LocalTime.NOON;

private BigDecimal cash = BigDecimal.ZERO;
private @NotNull BigDecimal cash = BigDecimal.ZERO;

private String currency = "RUB";
private @NotEmpty String currency = "RUB";
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package ru.investbook.web.forms.model;

import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.springframework.format.annotation.DateTimeFormat;
Expand All @@ -34,8 +35,8 @@ public abstract class PortfolioPropertyModel {
private @NotEmpty String portfolio;

@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate date = LocalDate.now();
private @NotNull LocalDate date = LocalDate.now();

@DateTimeFormat(pattern = "HH:mm:ss")
private LocalTime time = LocalTime.NOON;
private @NotNull LocalTime time = LocalTime.NOON;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package ru.investbook.web.forms.model;

import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.spacious_team.broker.pojo.PortfolioPropertyType;
Expand All @@ -31,9 +32,9 @@
@EqualsAndHashCode(callSuper = true)
public class PortfolioPropertyTotalAssetsModel extends PortfolioPropertyModel {

private BigDecimal totalAssets;
private @NotNull BigDecimal totalAssets;

private Currency totalAssetsCurrency;
private @NotNull Currency totalAssetsCurrency;

public enum Currency {
RUB, USD;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package ru.investbook.web.forms.model;

import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.checkerframework.checker.nullness.qual.Nullable;

Expand All @@ -31,9 +32,9 @@ public class SecurityDescriptionModel {
*/
private @NotEmpty String security = "Наименование (RU0000000000)";

private @Nullable @NotEmpty String sector;
private @NotEmpty String sector;

private SecurityType securityType;
private @NotNull SecurityType securityType;

public void setSecurity(Integer securityId, @Nullable String securityIsin, @Nullable String securityName, SecurityType securityType) {
this.securityId = securityId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package ru.investbook.web.forms.model;

import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.PositiveOrZero;
import lombok.Data;
import org.checkerframework.checker.nullness.qual.Nullable;
Expand All @@ -39,10 +40,10 @@ public class SecurityEventCashFlowModel {
private @NotEmpty String portfolio;

@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate date = LocalDate.now();
private @NotNull LocalDate date = LocalDate.now();

@DateTimeFormat(pattern = "HH:mm:ss")
private LocalTime time = LocalTime.NOON;
private @NotNull LocalTime time = LocalTime.NOON;

/**
* In "name (isin)" or "contract-name" format
Expand All @@ -51,9 +52,9 @@ public class SecurityEventCashFlowModel {

private int count;

private CashFlowType type;
private @NotNull CashFlowType type;

private BigDecimal value;
private @NotNull BigDecimal value;

private @NotEmpty String valueCurrency = "RUB";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package ru.investbook.web.forms.model;

import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive;
import jakarta.validation.constraints.PositiveOrZero;
import lombok.Data;
Expand All @@ -41,11 +42,11 @@ public class SecurityQuoteModel {
*/
private @NotEmpty String security;

private SecurityType securityType;
private @NotNull SecurityType securityType;

private Instant timestamp = LocalDate.now().atTime(LocalTime.NOON).atZone(systemDefault()).toInstant();
private @NotNull Instant timestamp = LocalDate.now().atTime(LocalTime.NOON).atZone(systemDefault()).toInstant();

private @Positive BigDecimal quote;
private @NotNull @Positive BigDecimal quote;

private @Nullable @Positive BigDecimal price;

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/ru/investbook/web/forms/model/SplitModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package ru.investbook.web.forms.model;

import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive;
import lombok.Data;
import org.checkerframework.checker.nullness.qual.Nullable;
Expand All @@ -36,10 +37,10 @@ public class SplitModel {
private @NotEmpty String portfolio;

@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate date = LocalDate.now();
private @NotNull LocalDate date = LocalDate.now();

@DateTimeFormat(pattern = "HH:mm")
private LocalTime time = LocalTime.NOON;
private @NotNull LocalTime time = LocalTime.NOON;

/**
* In "name (isin)" format
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package ru.investbook.web.forms.model;

import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive;
import jakarta.validation.constraints.PositiveOrZero;
import jakarta.xml.bind.DatatypeConverter;
Expand Down Expand Up @@ -59,17 +60,17 @@ public class TransactionModel {
private Action action;

@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate date = LocalDate.now();
private @NotNull LocalDate date = LocalDate.now();

@DateTimeFormat(pattern = "HH:mm:ss")
private LocalTime time = LocalTime.NOON;
private @NotNull LocalTime time = LocalTime.NOON;

/**
* In "name (isin)" or "contract-name" format
*/
private @NotEmpty String security;

private SecurityType securityType;
private @NotNull SecurityType securityType;

private @Positive int count;

Expand Down

0 comments on commit 5d3902a

Please sign in to comment.