Skip to content

Commit

Permalink
Add Java Doc on Domain Events
Browse files Browse the repository at this point in the history
  • Loading branch information
semotpan committed May 1, 2024
1 parent 62cf0e1 commit 46a7358
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 2 deletions.
13 changes: 12 additions & 1 deletion server/src/main/java/io/myfinbox/account/AccountCreated.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,25 @@
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.
*
* <p>This record captures information about the creation of an account, including its unique identifier,
* email address, first name, and last name.</p>
*/
@Builder
public record AccountCreated(UUID accountId,
String emailAddress,
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");
Expand Down
16 changes: 16 additions & 0 deletions server/src/main/java/io/myfinbox/expense/ExpenseCreated.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@

import static io.myfinbox.shared.Guards.notNull;

/**
* Represents a domain event for the creation of an expense.
*
* <p>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.</p>
*/
@Builder
public record ExpenseCreated(UUID expenseId,
UUID accountId,
Expand All @@ -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.");
Expand Down
16 changes: 16 additions & 0 deletions server/src/main/java/io/myfinbox/expense/ExpenseDeleted.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@

import static io.myfinbox.shared.Guards.notNull;

/**
* Represents a domain event for the deletion of an expense.
*
* <p>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.</p>
*/
@Builder
public record ExpenseDeleted(UUID expenseId,
UUID accountId,
Expand All @@ -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.");
Expand Down
16 changes: 16 additions & 0 deletions server/src/main/java/io/myfinbox/expense/ExpenseUpdated.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@

import static io.myfinbox.shared.Guards.notNull;

/**
* Represents a domain event for the update of an expense.
*
* <p>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.</p>
*/
@Builder
public record ExpenseUpdated(UUID expenseId,
UUID accountId,
Expand All @@ -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.");
Expand Down
19 changes: 18 additions & 1 deletion server/src/main/java/io/myfinbox/income/IncomeCreated.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@

import static io.myfinbox.shared.Guards.notNull;

/**
* Represents a domain event for the creation of income.
*
* <p>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.</p>
*/
@Builder
public record IncomeCreated(UUID incomeId,
UUID accountId,
Expand All @@ -18,12 +24,23 @@ 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.");
notNull(amount, "amount cannot be null.");
notNull(incomeDate, "incomeDate cannot be null.");
notNull(paymentType, "paymentType cannot be null.");
}
}
}
16 changes: 16 additions & 0 deletions server/src/main/java/io/myfinbox/income/IncomeDeleted.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@

import static io.myfinbox.shared.Guards.notNull;

/**
* Represents a domain event for the deletion of income.
*
* <p>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.</p>
*/
@Builder
public record IncomeDeleted(UUID incomeId,
UUID accountId,
Expand All @@ -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.");
Expand Down
16 changes: 16 additions & 0 deletions server/src/main/java/io/myfinbox/income/IncomeUpdated.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@

import static io.myfinbox.shared.Guards.notNull;

/**
* Represents a domain event for the update of income.
*
* <p>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.</p>
*/
@Builder
public record IncomeUpdated(UUID incomeId,
UUID accountId,
Expand All @@ -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.");
Expand Down

0 comments on commit 46a7358

Please sign in to comment.