Skip to content

Commit d752fd3

Browse files
committed
Improved Javadoc and parameter handling in banking APIs
Enhanced descriptions for method parameters, added `@apiNote` annotations for clarity, and standardized return value formatting with `{@code}`. Updated references to `uuid` instead of `UUID`. Improved consistency in `Account` API behavior with `BigDecimal.ZERO` returns for unsupported operations.
1 parent 9816748 commit d752fd3

File tree

2 files changed

+36
-25
lines changed

2 files changed

+36
-25
lines changed

src/main/java/net/thenextlvl/service/api/economy/Account.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
public interface Account {
1818
/**
1919
* Deposits the specified amount of the given currency into the account balance.
20+
* <p>
21+
* Returns {@link BigDecimal#ZERO} if {@link #canHold(Currency)} returns {@code false}
2022
*
2123
* @param amount the amount to be deposited
2224
* @param currency the currency that is being deposited
@@ -38,6 +40,8 @@ default BigDecimal deposit(Number amount, Currency currency) {
3840

3941
/**
4042
* Withdraws the specified amount of the given currency from the account balance.
43+
* <p>
44+
* Returns {@link BigDecimal#ZERO} if {@link #canHold(Currency)} returns {@code false}
4145
*
4246
* @param amount the amount to be withdrawn
4347
* @param currency the currency in which the withdrawal is to be made
@@ -49,16 +53,16 @@ default BigDecimal withdraw(Number amount, Currency currency) {
4953
}
5054

5155
/**
52-
* Returns an optional containing the world associated with this account.
56+
* Returns the world associated with this account.
5357
*
54-
* @return an {@code Optional<World>} containing the world associated with this account, or empty
58+
* @return an optional containing the world associated with this account, or empty
5559
*/
5660
Optional<World> getWorld();
5761

5862
/**
59-
* Returns the UUID of the owner of this account.
63+
* Returns the account owner's uuid.
6064
*
61-
* @return the UUID of the owner
65+
* @return the account owner's uuid
6266
*/
6367
UUID getOwner();
6468

@@ -77,10 +81,13 @@ default int compareTo(Account account, Currency currency) {
7781

7882
/**
7983
* Sets the balance of the account to the specified value in the given currency.
84+
* <p>
85+
* Returns {@link BigDecimal#ZERO} if {@link #canHold(Currency)} returns {@code false}
8086
*
8187
* @param balance the new balance to be set
8288
* @param currency the currency of the balance
8389
* @return the new balance after the operation
90+
* @see #canHold(Currency)
8491
* @since 3.0.0
8592
*/
8693
BigDecimal setBalance(Number balance, Currency currency);
Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package net.thenextlvl.service.api.economy.bank;
22

33
import net.thenextlvl.service.api.economy.Account;
4+
import net.thenextlvl.service.api.economy.currency.Currency;
45
import org.bukkit.OfflinePlayer;
56
import org.jetbrains.annotations.Contract;
67
import org.jetbrains.annotations.Unmodifiable;
@@ -13,7 +14,7 @@
1314
* The Bank interface represents a financial entity that can be owned and hold members.
1415
* It extends the Account interface, providing additional functionality specific
1516
* to banking, such as depositing or withdrawing money.
16-
*
17+
*
1718
* @since 1.0.0
1819
*/
1920
@NullMarked
@@ -22,6 +23,7 @@ public interface Bank extends Account {
2223
* Retrieves a set of UUIDs representing the members of the bank.
2324
*
2425
* @return an unmodifiable set containing the UUIDs of the members.
26+
* @apiNote does not contain the uuid of the owner
2527
*/
2628
@Unmodifiable
2729
Set<UUID> getMembers();
@@ -37,8 +39,8 @@ public interface Bank extends Account {
3739
/**
3840
* Adds a member to the bank.
3941
*
40-
* @param player the OfflinePlayer object representing the player to be added as a member
41-
* @return true if the player was successfully added as a member, false otherwise
42+
* @param player the player to be added as a member
43+
* @return {@code true} if the player was successfully added as a member, otherwise {@code false}
4244
*/
4345
default boolean addMember(OfflinePlayer player) {
4446
return addMember(player.getUniqueId());
@@ -47,62 +49,64 @@ default boolean addMember(OfflinePlayer player) {
4749
/**
4850
* Adds a member to the bank.
4951
*
50-
* @param uuid the UUID of the member to be added
51-
* @return true if the member was successfully added, false otherwise
52+
* @param uuid the uuid of the member to be added
53+
* @return {@code true} if the member was successfully added, otherwise {@code false}
5254
*/
5355
boolean addMember(UUID uuid);
5456

5557
/**
5658
* Checks if the specified player is a member of the bank.
5759
*
58-
* @param player the OfflinePlayer object representing the player to check for membership
59-
* @return true if the player is a member of the bank, false otherwise
60+
* @param player the player to check for membership
61+
* @return {@code true} if the player is a member of the bank, otherwise {@code false}
62+
* @apiNote returns {@code false} on the owner
6063
*/
6164
default boolean isMember(OfflinePlayer player) {
6265
return isMember(player.getUniqueId());
6366
}
6467

6568
/**
66-
* Checks if the specified UUID is associated with a member of the bank.
69+
* Checks if the specified uuid is associated with a member of the bank.
6770
*
68-
* @param uuid the UUID of the member to check for membership
69-
* @return true if the UUID corresponds to a member of the bank, false otherwise
71+
* @param uuid the uuid of the member to check for membership
72+
* @return {@code true} if the uuid corresponds to a member of the bank, otherwise {@code false}
73+
* @apiNote returns {@code false} on the owner
7074
*/
7175
boolean isMember(UUID uuid);
7276

7377
/**
7478
* Removes a member from the bank.
7579
*
76-
* @param player the OfflinePlayer object representing the player to be removed as a member
77-
* @return true if the member was successfully removed, false otherwise
80+
* @param player the player to be removed as a member
81+
* @return {@code true} if the member was successfully removed, otherwise {@code false}
7882
*/
7983
default boolean removeMember(OfflinePlayer player) {
8084
return removeMember(player.getUniqueId());
8185
}
8286

8387
/**
84-
* Removes a member from the bank using the specified UUID.
88+
* Removes a member from the bank using the specified uuid.
8589
*
86-
* @param uuid the UUID of the member to be removed
87-
* @return true if the member was successfully removed, false otherwise
90+
* @param uuid the uuid of the member to be removed
91+
* @return {@code true} if the member was successfully removed, otherwise {@code false}
8892
*/
8993
boolean removeMember(UUID uuid);
9094

9195
/**
92-
* Sets the specified OfflinePlayer as the owner of the bank.
96+
* Sets the specified player as the owner of the bank.
9397
*
94-
* @param player the OfflinePlayer object representing the player to be set as the owner
95-
* @return true if the player was successfully set as the owner, false otherwise
98+
* @param player the player to be set as the owner
99+
* @return {@code true} if the player was successfully set as the owner, otherwise {@code false}
96100
*/
97101
default boolean setOwner(OfflinePlayer player) {
98102
return setOwner(player.getUniqueId());
99103
}
100104

101105
/**
102-
* Sets the owner of the bank to the specified UUID.
106+
* Sets the owner of the bank to the specified uuid.
103107
*
104-
* @param uuid the UUID of the new owner
105-
* @return true if the owner was successfully set, false otherwise
108+
* @param uuid the uuid of the new owner
109+
* @return {@code true} if the owner was successfully set, otherwise {@code false}
106110
*/
107111
boolean setOwner(UUID uuid);
108112
}

0 commit comments

Comments
 (0)