Refactored models, preparing for immutable model records.
This commit is contained in:
parent
63bb7cb097
commit
be8e5dd3ca
|
@ -8,9 +8,9 @@ import java.util.Currency;
|
|||
* credit-card, etc.).
|
||||
*/
|
||||
public class Account {
|
||||
private long id;
|
||||
private LocalDateTime createdAt;
|
||||
private boolean archived;
|
||||
private final long id;
|
||||
private final LocalDateTime createdAt;
|
||||
private final boolean archived;
|
||||
|
||||
private AccountType type;
|
||||
private String accountNumber;
|
||||
|
@ -27,14 +27,6 @@ public class Account {
|
|||
this.currency = currency;
|
||||
}
|
||||
|
||||
public Account(AccountType type, String accountNumber, String name, Currency currency) {
|
||||
this.archived = false;
|
||||
this.type = type;
|
||||
this.accountNumber = accountNumber;
|
||||
this.name = name;
|
||||
this.currency = currency;
|
||||
}
|
||||
|
||||
public AccountType getType() {
|
||||
return type;
|
||||
}
|
||||
|
|
|
@ -36,13 +36,13 @@ public class AccountEntry {
|
|||
DEBIT
|
||||
}
|
||||
|
||||
private long id;
|
||||
private LocalDateTime timestamp;
|
||||
private long accountId;
|
||||
private long transactionId;
|
||||
private BigDecimal amount;
|
||||
private Type type;
|
||||
private Currency currency;
|
||||
private final long id;
|
||||
private final LocalDateTime timestamp;
|
||||
private final long accountId;
|
||||
private final long transactionId;
|
||||
private final BigDecimal amount;
|
||||
private final Type type;
|
||||
private final Currency currency;
|
||||
|
||||
public AccountEntry(long id, LocalDateTime timestamp, long accountId, long transactionId, BigDecimal amount, Type type, Currency currency) {
|
||||
this.id = id;
|
||||
|
@ -54,14 +54,6 @@ public class AccountEntry {
|
|||
this.currency = currency;
|
||||
}
|
||||
|
||||
public AccountEntry(long accountId, long transactionId, BigDecimal amount, Type type, Currency currency) {
|
||||
this.accountId = accountId;
|
||||
this.transactionId = transactionId;
|
||||
this.amount = amount;
|
||||
this.type = type;
|
||||
this.currency = currency;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package com.andrewlalis.perfin.model;
|
||||
|
||||
/**
|
||||
* Represents the different possible account types in Perfin.
|
||||
*/
|
||||
public enum AccountType {
|
||||
CHECKING("Checking"),
|
||||
SAVINGS("Savings"),
|
||||
|
|
|
@ -12,11 +12,11 @@ import java.time.format.DateTimeFormatter;
|
|||
* account balance record.
|
||||
*/
|
||||
public class Attachment {
|
||||
private long id;
|
||||
private LocalDateTime timestamp;
|
||||
private String identifier;
|
||||
private String filename;
|
||||
private String contentType;
|
||||
private final long id;
|
||||
private final LocalDateTime timestamp;
|
||||
private final String identifier;
|
||||
private final String filename;
|
||||
private final String contentType;
|
||||
|
||||
public Attachment(long id, LocalDateTime timestamp, String identifier, String filename, String contentType) {
|
||||
this.id = id;
|
||||
|
@ -26,13 +26,6 @@ public class Attachment {
|
|||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
public Attachment(LocalDateTime timestamp, String identifier, String filename, String contentType) {
|
||||
this.timestamp = timestamp;
|
||||
this.identifier = identifier;
|
||||
this.filename = filename;
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
|
|
@ -10,12 +10,12 @@ import java.util.Currency;
|
|||
* correct balance.
|
||||
*/
|
||||
public class BalanceRecord {
|
||||
private long id;
|
||||
private LocalDateTime timestamp;
|
||||
private final long id;
|
||||
private final LocalDateTime timestamp;
|
||||
|
||||
private long accountId;
|
||||
private BigDecimal balance;
|
||||
private Currency currency;
|
||||
private final long accountId;
|
||||
private final BigDecimal balance;
|
||||
private final Currency currency;
|
||||
|
||||
public BalanceRecord(long id, LocalDateTime timestamp, long accountId, BigDecimal balance, Currency currency) {
|
||||
this.id = id;
|
||||
|
@ -25,12 +25,6 @@ public class BalanceRecord {
|
|||
this.currency = currency;
|
||||
}
|
||||
|
||||
public BalanceRecord(long accountId, BigDecimal balance, Currency currency) {
|
||||
this.accountId = accountId;
|
||||
this.balance = balance;
|
||||
this.currency = currency;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ public class Transaction {
|
|||
|
||||
private final BigDecimal amount;
|
||||
private final Currency currency;
|
||||
private String description;
|
||||
private final String description;
|
||||
|
||||
public Transaction(long id, LocalDateTime timestamp, BigDecimal amount, Currency currency, String description) {
|
||||
this.id = id;
|
||||
|
|
|
@ -9,10 +9,10 @@ import java.time.LocalDateTime;
|
|||
* record, or modifications to the account's properties.
|
||||
*/
|
||||
public class AccountHistoryItem {
|
||||
private long id;
|
||||
private LocalDateTime timestamp;
|
||||
private long accountId;
|
||||
private AccountHistoryItemType type;
|
||||
private final long id;
|
||||
private final LocalDateTime timestamp;
|
||||
private final long accountId;
|
||||
private final AccountHistoryItemType type;
|
||||
|
||||
public AccountHistoryItem(long id, LocalDateTime timestamp, long accountId, AccountHistoryItemType type) {
|
||||
this.id = id;
|
||||
|
@ -21,12 +21,6 @@ public class AccountHistoryItem {
|
|||
this.type = type;
|
||||
}
|
||||
|
||||
public AccountHistoryItem(LocalDateTime timestamp, long accountId, AccountHistoryItemType type) {
|
||||
this.timestamp = timestamp;
|
||||
this.accountId = accountId;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue