Skip to content

Instantly share code, notes, and snippets.

@thombergs
Last active September 26, 2019 07:26
Show Gist options
  • Save thombergs/d7c29c4556f6574e98198bbddcb8fbd2 to your computer and use it in GitHub Desktop.
Save thombergs/d7c29c4556f6574e98198bbddcb8fbd2 to your computer and use it in GitHub Desktop.
Account.java
package buckpal.domain;
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class Account {
@Getter private final AccountId id;
@Getter private final ActivityWindow activityWindow;
private final Money baselineBalance;
public static Account withoutId(
Money baselineBalance,
ActivityWindow activityWindow) {
return new Account(null, baselineBalance, activityWindow);
}
public static Account withId(
AccountId accountId,
Money baselineBalance,
ActivityWindow activityWindow) {
return new Account(accountId, baselineBalance, activityWindow);
}
public Money calculateBalance() {
// ...
}
public boolean withdraw(Money money, AccountId targetAccountId) {
// ...
}
public boolean deposit(Money money, AccountId sourceAccountId) {
// ...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment