From 46a7358c2281ba2932b1f29fa1d458690e88d6f3 Mon Sep 17 00:00:00 2001 From: Serghei Motpan Date: Wed, 1 May 2024 11:46:36 +0300 Subject: [PATCH] Add Java Doc on Domain Events --- .../io/myfinbox/account/AccountCreated.java | 13 ++++++++++++- .../io/myfinbox/expense/ExpenseCreated.java | 16 ++++++++++++++++ .../io/myfinbox/expense/ExpenseDeleted.java | 16 ++++++++++++++++ .../io/myfinbox/expense/ExpenseUpdated.java | 16 ++++++++++++++++ .../io/myfinbox/income/IncomeCreated.java | 19 ++++++++++++++++++- .../io/myfinbox/income/IncomeDeleted.java | 16 ++++++++++++++++ .../io/myfinbox/income/IncomeUpdated.java | 16 ++++++++++++++++ 7 files changed, 110 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/io/myfinbox/account/AccountCreated.java b/server/src/main/java/io/myfinbox/account/AccountCreated.java index 27b184e..c5a819b 100644 --- a/server/src/main/java/io/myfinbox/account/AccountCreated.java +++ b/server/src/main/java/io/myfinbox/account/AccountCreated.java @@ -9,7 +9,10 @@ import static io.myfinbox.shared.Guards.notNull; /** - * Represents an event indicating that an account has been created. + * Represents a domain event for the creation of an account. + * + *

This record captures information about the creation of an account, including its unique identifier, + * email address, first name, and last name.

*/ @Builder public record AccountCreated(UUID accountId, @@ -17,6 +20,14 @@ public record AccountCreated(UUID accountId, String firstName, String lastName) implements DomainEvent { + /** + * Constructor for the AccountCreated record. + * + * @param accountId The unique identifier of the account. + * @param emailAddress The email address associated with the account. + * @param firstName The first name of the account holder. + * @param lastName The last name of the account holder. + */ public AccountCreated { notNull(accountId, "accountIdentifier cannot be null"); notBlank(emailAddress, "emailAddress cannot be blank"); diff --git a/server/src/main/java/io/myfinbox/expense/ExpenseCreated.java b/server/src/main/java/io/myfinbox/expense/ExpenseCreated.java index 754cec1..1498701 100644 --- a/server/src/main/java/io/myfinbox/expense/ExpenseCreated.java +++ b/server/src/main/java/io/myfinbox/expense/ExpenseCreated.java @@ -10,6 +10,12 @@ import static io.myfinbox.shared.Guards.notNull; +/** + * Represents a domain event for the creation of an expense. + * + *

This record captures information about the creation of an expense, including its unique identifier, + * the associated account and category, the amount, date, and payment type.

+ */ @Builder public record ExpenseCreated(UUID expenseId, UUID accountId, @@ -18,6 +24,16 @@ public record ExpenseCreated(UUID expenseId, LocalDate expenseDate, PaymentType paymentType) implements DomainEvent { + /** + * Constructor for the ExpenseCreated record. + * + * @param expenseId The unique identifier of the expense. + * @param accountId The identifier of the account associated with the expense. + * @param categoryId The identifier of the category associated with the expense. + * @param amount The amount of the expense. + * @param expenseDate The date of the expense. + * @param paymentType The payment type of the expense. + */ public ExpenseCreated { notNull(expenseId, "expenseId cannot be null."); notNull(accountId, "accountId cannot be null."); diff --git a/server/src/main/java/io/myfinbox/expense/ExpenseDeleted.java b/server/src/main/java/io/myfinbox/expense/ExpenseDeleted.java index 0a9550d..6b5f8ed 100644 --- a/server/src/main/java/io/myfinbox/expense/ExpenseDeleted.java +++ b/server/src/main/java/io/myfinbox/expense/ExpenseDeleted.java @@ -10,6 +10,12 @@ import static io.myfinbox.shared.Guards.notNull; +/** + * Represents a domain event for the deletion of an expense. + * + *

This record captures information about the deletion of an expense, including its unique identifier, + * the associated account and category, the amount, date, and payment type.

+ */ @Builder public record ExpenseDeleted(UUID expenseId, UUID accountId, @@ -18,6 +24,16 @@ public record ExpenseDeleted(UUID expenseId, LocalDate expenseDate, PaymentType paymentType) implements DomainEvent { + /** + * Constructor for the ExpenseDeleted record. + * + * @param expenseId The unique identifier of the expense. + * @param accountId The identifier of the account associated with the expense. + * @param categoryId The identifier of the category associated with the expense. + * @param amount The amount of the expense. + * @param expenseDate The date of the expense. + * @param paymentType The payment type of the expense. + */ public ExpenseDeleted { notNull(expenseId, "expenseId cannot be null."); notNull(accountId, "accountId cannot be null."); diff --git a/server/src/main/java/io/myfinbox/expense/ExpenseUpdated.java b/server/src/main/java/io/myfinbox/expense/ExpenseUpdated.java index 908d1fb..dfe803b 100644 --- a/server/src/main/java/io/myfinbox/expense/ExpenseUpdated.java +++ b/server/src/main/java/io/myfinbox/expense/ExpenseUpdated.java @@ -10,6 +10,12 @@ import static io.myfinbox.shared.Guards.notNull; +/** + * Represents a domain event for the update of an expense. + * + *

This record captures information about the update of an expense, including its unique identifier, + * the associated account and category, the amount, date, and payment type.

+ */ @Builder public record ExpenseUpdated(UUID expenseId, UUID accountId, @@ -18,6 +24,16 @@ public record ExpenseUpdated(UUID expenseId, LocalDate expenseDate, PaymentType paymentType) implements DomainEvent { + /** + * Constructor for the ExpenseUpdated record. + * + * @param expenseId The unique identifier of the expense. + * @param accountId The identifier of the account associated with the expense. + * @param categoryId The identifier of the category associated with the expense. + * @param amount The amount of the expense. + * @param expenseDate The date of the expense. + * @param paymentType The payment type of the expense. + */ public ExpenseUpdated { notNull(expenseId, "expenseId cannot be null."); notNull(accountId, "accountId cannot be null."); diff --git a/server/src/main/java/io/myfinbox/income/IncomeCreated.java b/server/src/main/java/io/myfinbox/income/IncomeCreated.java index 95b15c8..004e69f 100644 --- a/server/src/main/java/io/myfinbox/income/IncomeCreated.java +++ b/server/src/main/java/io/myfinbox/income/IncomeCreated.java @@ -10,6 +10,12 @@ import static io.myfinbox.shared.Guards.notNull; +/** + * Represents a domain event for the creation of income. + * + *

This record captures information about the creation of income, including its unique identifier, + * the associated account and income source, the amount, date, and payment type.

+ */ @Builder public record IncomeCreated(UUID incomeId, UUID accountId, @@ -18,7 +24,18 @@ public record IncomeCreated(UUID incomeId, LocalDate incomeDate, PaymentType paymentType) implements DomainEvent { + /** + * Constructor for the IncomeCreated record. + * + * @param incomeId The unique identifier of the income. + * @param accountId The identifier of the account associated with the income. + * @param incomeSourceId The identifier of the income source associated with the income. + * @param amount The amount of the income. + * @param incomeDate The date of the income. + * @param paymentType The payment type of the income. + */ public IncomeCreated { + // Validate non-null fields notNull(incomeId, "incomeId cannot be null."); notNull(accountId, "accountId cannot be null."); notNull(incomeSourceId, "incomeSourceId cannot be null."); @@ -26,4 +43,4 @@ public record IncomeCreated(UUID incomeId, notNull(incomeDate, "incomeDate cannot be null."); notNull(paymentType, "paymentType cannot be null."); } -} +} \ No newline at end of file diff --git a/server/src/main/java/io/myfinbox/income/IncomeDeleted.java b/server/src/main/java/io/myfinbox/income/IncomeDeleted.java index 1b8606f..223b305 100644 --- a/server/src/main/java/io/myfinbox/income/IncomeDeleted.java +++ b/server/src/main/java/io/myfinbox/income/IncomeDeleted.java @@ -10,6 +10,12 @@ import static io.myfinbox.shared.Guards.notNull; +/** + * Represents a domain event for the deletion of income. + * + *

This record captures information about the deletion of income, including its unique identifier, + * the associated account and income source, the amount, date, and payment type.

+ */ @Builder public record IncomeDeleted(UUID incomeId, UUID accountId, @@ -18,6 +24,16 @@ public record IncomeDeleted(UUID incomeId, LocalDate incomeDate, PaymentType paymentType) implements DomainEvent { + /** + * Constructor for the IncomeDeleted record. + * + * @param incomeId The unique identifier of the income. + * @param accountId The identifier of the account associated with the income. + * @param incomeSourceId The identifier of the income source associated with the income. + * @param amount The amount of the income. + * @param incomeDate The date of the income. + * @param paymentType The payment type of the income. + */ public IncomeDeleted { notNull(incomeId, "incomeId cannot be null."); notNull(accountId, "accountId cannot be null."); diff --git a/server/src/main/java/io/myfinbox/income/IncomeUpdated.java b/server/src/main/java/io/myfinbox/income/IncomeUpdated.java index 0daefec..954d445 100644 --- a/server/src/main/java/io/myfinbox/income/IncomeUpdated.java +++ b/server/src/main/java/io/myfinbox/income/IncomeUpdated.java @@ -10,6 +10,12 @@ import static io.myfinbox.shared.Guards.notNull; +/** + * Represents a domain event for the update of income. + * + *

This record captures information about the update of income, including its unique identifier, + * the associated account and income source, the amount, date, and payment type.

+ */ @Builder public record IncomeUpdated(UUID incomeId, UUID accountId, @@ -18,6 +24,16 @@ public record IncomeUpdated(UUID incomeId, LocalDate incomeDate, PaymentType paymentType) implements DomainEvent { + /** + * Constructor for the IncomeUpdated record. + * + * @param incomeId The unique identifier of the income. + * @param accountId The identifier of the account associated with the income. + * @param incomeSourceId The identifier of the income source associated with the income. + * @param amount The amount of the income. + * @param incomeDate The date of the income. + * @param paymentType The payment type of the income. + */ public IncomeUpdated { notNull(incomeId, "incomeId cannot be null."); notNull(accountId, "accountId cannot be null.");