Skip to content

Commit e3423c2

Browse files
chore: forgot to run spotlessApply, fixed formatting
1 parent 5c07b2d commit e3423c2

File tree

10 files changed

+174
-171
lines changed

10 files changed

+174
-171
lines changed

lesson_17/bank/bank_app/src/main/java/com/codedifferently/lesson17/bank/BankAtm.java

Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
package com.codedifferently.lesson17.bank;
22

3+
import com.codedifferently.lesson17.bank.exceptions.AccountNotFoundException;
34
import java.util.HashMap;
45
import java.util.Map;
56
import java.util.Set;
67
import java.util.UUID;
78

8-
import com.codedifferently.lesson17.bank.exceptions.AccountNotFoundException;
9-
10-
/**
9+
/**
1110
* Represents a bank ATM system that manages customer accounts and transactions.
12-
*
13-
* <p>This ATM supports various types of checking accounts including standard
14-
* {@link CheckingAccount} and specialized {@link BusinessCheckingAccount} instances.
15-
* The system uses polymorphism to treat all account types uniformly, enabling
16-
* seamless operations regardless of the specific account implementation.
17-
*
11+
*
12+
* <p>This ATM supports various types of checking accounts including standard {@link
13+
* CheckingAccount} and specialized {@link BusinessCheckingAccount} instances. The system uses
14+
* polymorphism to treat all account types uniformly, enabling seamless operations regardless of the
15+
* specific account implementation.
16+
*
1817
* <p>Supported operations include:
18+
*
1919
* <ul>
20-
* <li>Adding accounts to the system</li>
21-
* <li>Finding accounts by customer ID</li>
22-
* <li>Depositing funds (cash or check) with multi-currency support</li>
23-
* <li>Withdrawing funds</li>
20+
* <li>Adding accounts to the system
21+
* <li>Finding accounts by customer ID
22+
* <li>Depositing funds (cash or check) with multi-currency support
23+
* <li>Withdrawing funds
2424
* </ul>
25-
*
26-
* <p>The ATM supports deposits in multiple currencies including USD, EUR, GBP, JPY,
27-
* CAD, AUD, CHF, and CNY. All currency conversions are handled automatically using
28-
* the integrated {@link CurrencyConverter}, with all account balances maintained in USD.
29-
*
30-
* <p>The ATM maintains internal mappings of customers and accounts for efficient
31-
* lookup operations and enforces business rules such as account existence validation.
32-
*
25+
*
26+
* <p>The ATM supports deposits in multiple currencies including USD, EUR, GBP, JPY, CAD, AUD, CHF,
27+
* and CNY. All currency conversions are handled automatically using the integrated {@link
28+
* CurrencyConverter}, with all account balances maintained in USD.
29+
*
30+
* <p>The ATM maintains internal mappings of customers and accounts for efficient lookup operations
31+
* and enforces business rules such as account existence validation.
32+
*
3333
* @see CheckingAccount
3434
* @see BusinessCheckingAccount
3535
* @see Customer
@@ -43,30 +43,29 @@ public class BankAtm {
4343
private final Map<UUID, Customer> customerById = new HashMap<>();
4444
private final Map<String, CheckingAccount> accountByNumber = new HashMap<>();
4545
private final CurrencyConverter currencyConverter;
46-
46+
4747
/**
4848
* Creates a new BankAtm with default currency conversion support.
49-
*
50-
* <p>Initializes the ATM system with an empty set of accounts and customers,
51-
* and sets up currency conversion capabilities for multi-currency deposits.
49+
*
50+
* <p>Initializes the ATM system with an empty set of accounts and customers, and sets up currency
51+
* conversion capabilities for multi-currency deposits.
5252
*/
5353
public BankAtm() {
5454
this.currencyConverter = new CurrencyConverter();
5555
}
5656

5757
/**
5858
* Adds a checking account to the ATM system.
59-
*
60-
* <p>This method accepts any type of checking account, including standard
61-
* {@link CheckingAccount} and {@link BusinessCheckingAccount} instances.
62-
* The account and all its owners are registered in the system for lookup operations.
63-
*
64-
* <p>After adding an account, customers can perform transactions using the
65-
* account number, and the account can be found using any owner's customer ID.
59+
*
60+
* <p>This method accepts any type of checking account, including standard {@link CheckingAccount}
61+
* and {@link BusinessCheckingAccount} instances. The account and all its owners are registered in
62+
* the system for lookup operations.
63+
*
64+
* <p>After adding an account, customers can perform transactions using the account number, and
65+
* the account can be found using any owner's customer ID.
6666
*
6767
* @param account The checking account to add (including business accounts)
6868
* @throws NullPointerException if the account is null
69-
*
7069
* @see BusinessCheckingAccount
7170
* @see #findAccountsByCustomerId(UUID)
7271
*/
@@ -94,14 +93,14 @@ public Set<CheckingAccount> findAccountsByCustomerId(UUID customerId) {
9493

9594
/**
9695
* Deposits funds into an account with automatic currency conversion to USD.
97-
*
98-
* <p>This method accepts deposits in various currencies and automatically
99-
* converts the amount to USD using current exchange rates before depositing
100-
* into the account. All account balances are maintained in USD.
101-
*
102-
* <p>Supported currencies include USD, EUR, GBP, JPY, CAD, AUD, CHF, and CNY.
103-
* Exchange rates are managed by the internal {@link CurrencyConverter}.
104-
* For USD deposits, the amount is deposited directly without conversion overhead.
96+
*
97+
* <p>This method accepts deposits in various currencies and automatically converts the amount to
98+
* USD using current exchange rates before depositing into the account. All account balances are
99+
* maintained in USD.
100+
*
101+
* <p>Supported currencies include USD, EUR, GBP, JPY, CAD, AUD, CHF, and CNY. Exchange rates are
102+
* managed by the internal {@link CurrencyConverter}. For USD deposits, the amount is deposited
103+
* directly without conversion overhead.
105104
*
106105
* @param accountNumber The account number to deposit funds into
107106
* @param amount The amount to deposit in the specified currency
@@ -110,7 +109,6 @@ public Set<CheckingAccount> findAccountsByCustomerId(UUID customerId) {
110109
* @throws IllegalArgumentException if the amount is negative
111110
* @throws IllegalArgumentException if the currency is null
112111
* @throws UnsupportedOperationException if the currency is not supported
113-
*
114112
* @see Currency
115113
* @see CurrencyConverter
116114
*/

lesson_17/bank/bank_app/src/main/java/com/codedifferently/lesson17/bank/BusinessCheckingAccount.java

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
import java.util.Set;
44

5-
/**
5+
/**
66
* Represents a business checking account that extends the standard checking account functionality.
7-
*
7+
*
88
* <p>A business checking account enforces that at least one owner must be a business customer
9-
* ({@link BusinessCustomer}). This validation occurs during account creation and will throw
10-
* an {@link IllegalArgumentException} if no business owners are present.
11-
*
12-
* <p>All standard checking account operations are inherited from {@link CheckingAccount},
13-
* including deposits, withdrawals, balance inquiries, and account closure functionality.
14-
*
15-
* <p>Business accounts can be seamlessly integrated with the {@link BankAtm} system
16-
* through polymorphism, requiring no changes to existing ATM operations.
17-
*
9+
* ({@link BusinessCustomer}). This validation occurs during account creation and will throw an
10+
* {@link IllegalArgumentException} if no business owners are present.
11+
*
12+
* <p>All standard checking account operations are inherited from {@link CheckingAccount}, including
13+
* deposits, withdrawals, balance inquiries, and account closure functionality.
14+
*
15+
* <p>Business accounts can be seamlessly integrated with the {@link BankAtm} system through
16+
* polymorphism, requiring no changes to existing ATM operations.
17+
*
1818
* @see CheckingAccount
1919
* @see BusinessCustomer
2020
* @see BankAtm
@@ -24,11 +24,11 @@ public class BusinessCheckingAccount extends CheckingAccount {
2424

2525
/**
2626
* Creates a new business checking account with validation for business ownership.
27-
*
28-
* <p>This constructor validates that at least one owner in the provided set is a
29-
* {@link BusinessCustomer}. If no business customers are found among the owners,
30-
* an {@link IllegalArgumentException} is thrown.
31-
*
27+
*
28+
* <p>This constructor validates that at least one owner in the provided set is a {@link
29+
* BusinessCustomer}. If no business customers are found among the owners, an {@link
30+
* IllegalArgumentException} is thrown.
31+
*
3232
* <p>The account inherits all functionality from {@link CheckingAccount} including
3333
* deposit/withdrawal operations, balance management, and account closure capabilities.
3434
*
@@ -38,28 +38,28 @@ public class BusinessCheckingAccount extends CheckingAccount {
3838
* @throws IllegalArgumentException if the owners set is empty or contains no business customers
3939
* @throws IllegalArgumentException if the account number is null or empty
4040
* @throws IllegalArgumentException if the initial balance is negative
41-
*
4241
* @see BusinessCustomer
4342
* @see CheckingAccount#CheckingAccount(String, Set, double)
4443
*/
45-
public BusinessCheckingAccount(String accountNumber, Set<Customer> owners, double initialBalance) {
44+
public BusinessCheckingAccount(
45+
String accountNumber, Set<Customer> owners, double initialBalance) {
4646
super(accountNumber, owners, initialBalance);
47-
47+
4848
// Validate that at least one owner is a business customer
49-
boolean hasBusinessOwner = owners.stream()
50-
.anyMatch(owner -> owner instanceof BusinessCustomer);
51-
49+
boolean hasBusinessOwner = owners.stream().anyMatch(owner -> owner instanceof BusinessCustomer);
50+
5251
if (!hasBusinessOwner) {
53-
throw new IllegalArgumentException("Business checking account requires at least one business owner");
52+
throw new IllegalArgumentException(
53+
"Business checking account requires at least one business owner");
5454
}
5555
}
5656

5757
/**
5858
* Returns a string representation of this business checking account.
59-
*
60-
* <p>The string includes the account number, current balance, and active status,
61-
* formatted specifically for business accounts to distinguish them from regular
62-
* checking accounts in logging and debugging scenarios.
59+
*
60+
* <p>The string includes the account number, current balance, and active status, formatted
61+
* specifically for business accounts to distinguish them from regular checking accounts in
62+
* logging and debugging scenarios.
6363
*
6464
* @return A formatted string containing account details
6565
*/
@@ -75,4 +75,4 @@ public String toString() {
7575
+ !isClosed()
7676
+ '}';
7777
}
78-
}
78+
}

lesson_17/bank/bank_app/src/main/java/com/codedifferently/lesson17/bank/BusinessCustomer.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,14 @@ public boolean isBusiness() {
5151
@Override
5252
public String toString() {
5353
return "BusinessCustomer{"
54-
+ "id=" + getId()
55-
+ ", businessName='" + businessName + '\''
56-
+ ", taxId='" + taxId + '\''
54+
+ "id="
55+
+ getId()
56+
+ ", businessName='"
57+
+ businessName
58+
+ '\''
59+
+ ", taxId='"
60+
+ taxId
61+
+ '\''
5762
+ '}';
5863
}
5964
}

lesson_17/bank/bank_app/src/main/java/com/codedifferently/lesson17/bank/Currency.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,35 @@
22

33
/**
44
* Enumeration of supported currencies for banking transactions.
5-
*
6-
* <p>This enum defines the various currencies that can be used for deposits
7-
* and other banking operations. All currency amounts are converted to USD
8-
* for internal account balance management.
9-
*
5+
*
6+
* <p>This enum defines the various currencies that can be used for deposits and other banking
7+
* operations. All currency amounts are converted to USD for internal account balance management.
8+
*
109
* @see CurrencyConverter
1110
* @since 1.0
1211
*/
1312
public enum Currency {
1413
/** United States Dollar (base currency) */
1514
USD,
16-
15+
1716
/** Euro */
1817
EUR,
19-
18+
2019
/** British Pound Sterling */
2120
GBP,
22-
21+
2322
/** Japanese Yen */
2423
JPY,
25-
24+
2625
/** Canadian Dollar */
2726
CAD,
28-
27+
2928
/** Australian Dollar */
3029
AUD,
31-
30+
3231
/** Swiss Franc */
3332
CHF,
34-
33+
3534
/** Chinese Yuan */
3635
CNY
3736
}

0 commit comments

Comments
 (0)