Skip to content

Commit 62b3c4d

Browse files
committed
Remove redundant documentation from transaction APIs
- Stripped excessive comments and inline documentation across interfaces in `transaction`, `account`, and `currency` APIs. - Simplified code readability by retaining only essential comments for public functions and properties. - Updated related classes to adopt a cleaner, more concise interface structure.
1 parent 7f535e6 commit 62b3c4d

File tree

10 files changed

+5
-315
lines changed

10 files changed

+5
-315
lines changed

surf-transaction-api/src/main/kotlin/dev/slne/surf/transaction/api/account/Account.kt

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,42 +10,15 @@ import java.util.*
1010
@OptIn(InternalTransactionApi::class)
1111
interface Account : Transactional, AccountMemberOperations {
1212

13-
/**
14-
* Unique identifier for the account.
15-
*/
1613
val accountId: UUID
17-
18-
/**
19-
* The name of the account.
20-
*/
2114
val name: String
22-
23-
/**
24-
* The owner of the account.
25-
*/
2615
val ownerUuid: UUID
27-
28-
/**
29-
* Indicates whether this account is the default account for the owner.
30-
*/
3116
val defaultAccount: Boolean
3217

33-
/**
34-
* Converts the account information into a [Component] for display purposes.
35-
*
36-
* @return A [Component] representing the account information, suitable for use in user interfaces.
37-
*/
3818
suspend fun asComponent(): Component
3919

4020
companion object {
41-
/**
42-
* Minimum length for account names.
43-
*/
4421
const val MIN_NAME_LENGTH = 3
45-
46-
/**
47-
* Maximum length for account names.
48-
*/
4922
const val MAX_NAME_LENGTH = 32
5023

5124
suspend fun byId(accountId: UUID): Account? =

surf-transaction-api/src/main/kotlin/dev/slne/surf/transaction/api/account/AccountAccess.kt

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,43 +9,10 @@ import java.util.*
99
interface AccountAccess {
1010

1111
val userUuid: UUID
12-
13-
/**
14-
* Retrieves the default account for this player.
15-
*
16-
* @return the default [Account] associated with this player
17-
*/
1812
suspend fun getDefaultAccount(): Account
19-
20-
/**
21-
* Retrieves all accounts associated with this player.
22-
*
23-
* @return a set of [Account]s owned by this player
24-
*/
2513
suspend fun getAllAccounts(): Set<Account>
26-
27-
/**
28-
* Creates a new account for this player with the specified [name].
29-
*
30-
* @param name the name of the new account; must be non-empty
31-
* @return the newly created [Account]
32-
*/
3314
suspend fun createAccount(name: String): AccountCreationResult
34-
35-
/**
36-
* Retrieves the account with the specified [accountName] for this player.
37-
*
38-
* @param accountName the name of the account to retrieve; must be non-empty
39-
* @return the [Account] matching [accountName], or `null` if not found
40-
*/
4115
suspend fun getAccountByName(accountName: String): Account?
42-
43-
/**
44-
* Deletes the specified [account] from this player's accounts.
45-
*
46-
* @param account the account to delete; must be non-null
47-
* @return an [dev.slne.surf.transaction.api.account.result.AccountDeleteResult] indicating success or failure
48-
*/
4916
suspend fun deleteAccount(account: Account): AccountDeleteResult
5017

5118
}

surf-transaction-api/src/main/kotlin/dev/slne/surf/transaction/api/account/AccountService.kt

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,8 @@ import java.util.*
77

88
@InternalTransactionApi
99
interface AccountService {
10-
/**
11-
* Retrieves an account by its unique identifier.
12-
*
13-
* @param accountId The unique identifier of the account to retrieve.
14-
* @return The account associated with the given identifier, or null if no such account exists.
15-
*/
1610
suspend fun getAccountByAccountId(accountId: UUID): Account?
17-
1811
suspend fun getAccountByName(accountName: String): Account?
19-
20-
/**
21-
* Creates a new account for a specified player.
22-
*
23-
* @param owner The player who will own the new account.
24-
* @param name The name of the new account.
25-
* @return A result indicating the success or failure of the account creation.
26-
*/
2712
suspend fun createAccount(ownerUuid: UUID, name: String): AccountCreationResult
2813

2914
companion object {
Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,20 @@
11
package dev.slne.surf.transaction.api.account.member
22

33
import dev.slne.surf.transaction.api.account.member.results.AccountMemberResult
4-
import it.unimi.dsi.fastutil.objects.ObjectSet
54
import java.util.*
65

76
interface AccountMemberOperations {
8-
/**
9-
* A set of members associated with the account.
10-
*/
117
val members: Set<UUID>
128

13-
/**
14-
* Adds a new member to the account.
15-
*
16-
* @param executor The [OfflineCloudPlayer] executing the addition.
17-
* @param target The [OfflineCloudPlayer] to be added as a member.
18-
*/
199
suspend fun addMember(
2010
executor: UUID,
2111
target: UUID
2212
): AccountMemberResult
2313

24-
/**
25-
* Removes a member from the account.
26-
*
27-
* @param executor The [OfflineCloudPlayer] executing the removal.
28-
* @param target The [OfflineCloudPlayer] to be removed from the members.
29-
*/
3014
suspend fun removeMember(
3115
executor: UUID,
3216
target: UUID
3317
): AccountMemberResult
3418

35-
/**
36-
* Checks if a player is a member of the account.
37-
*
38-
* @param player The [OfflineCloudPlayer] to check for membership.
39-
* @return `true` if the player is a member, `false` otherwise.
40-
*/
4119
fun isMember(player: UUID): Boolean
4220
}
Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,36 @@
11
package dev.slne.surf.transaction.api.currency
22

33
import dev.slne.surf.surfapi.core.api.messages.Colors
4-
import dev.slne.surf.transaction.api.currency.Currency.Companion.byName
54
import dev.slne.surf.transaction.api.util.InternalTransactionApi
65
import net.kyori.adventure.text.Component
76
import net.kyori.adventure.text.ComponentLike
87
import net.kyori.adventure.text.format.TextColor
98
import java.math.BigDecimal
109

11-
/**
12-
* Describes a monetary unit that can be used in the transaction system.
13-
*
14-
* A **currency** is identified by its unique [name] and may provide rich‐text
15-
* variants for UI presentation via [displayName] and [symbolDisplay].
16-
* Implementations must be immutable and thread-safe.
17-
*
18-
* ### Serialization
19-
* This interface is annotated with `@Serializable(with = CurrencySerializer::class)`
20-
* to enable polymorphic (de)serialization of concrete currency implementations.
21-
*/
2210
@OptIn(InternalTransactionApi::class)
2311
interface Currency : ComponentLike {
24-
25-
/** Unique identifier (≤ [ CURRENCY_NAME_MAX_LENGTH ] characters), e.g. `"castcoin"`. */
2612
val name: String
27-
28-
/** Rich-text display name, e.g. `<red>CastCoin</red>`. */
2913
val displayName: Component
30-
31-
/** `true` if this is the platform-wide default currency. */
3214
val defaultCurrency: Boolean
33-
34-
/** Plain text symbol, e.g. `"$"`. */
3515
val symbol: String
36-
37-
/** Rich-text variant of [symbol], e.g. `<red>$</red>`. */
3816
val symbolDisplay: Component
39-
40-
/** Decimal precision and formatting rules for this currency. */
4117
val scale: CurrencyScale
42-
43-
/** Minimum amount that must be present after validation unless bypassed. */
4418
val minimumAmount: BigDecimal
4519

46-
/**
47-
* Converts [amount] into a formatted, colorized [Component].
48-
*
49-
* @param amount value to format
50-
* @param color text color for the numeric part; defaults to [Colors.VARIABLE_VALUE]
51-
* @return formatted text like `"§7$§c1.50"`
52-
*/
5320
fun format(amount: BigDecimal, color: TextColor = Colors.VARIABLE_VALUE): Component
5421

55-
/**
56-
* Convenience overload delegating to the `BigDecimal` version.
57-
*
58-
* @param amount value to format (will be converted with `toBigDecimal()`)
59-
* @param color text color for the numeric part; defaults to [Colors.VARIABLE_VALUE]
60-
* @return formatted text component
61-
*/
6222
fun format(amount: Double, color: TextColor = Colors.VARIABLE_VALUE) =
6323
format(amount.toBigDecimal(), color)
6424

65-
/**
66-
* Returns the display name of this currency as a [Component].
67-
* This is primarily used for UI purposes, such as displaying the currency
68-
* name in menus or transaction summaries.
69-
*
70-
* @return the display name of this currency as a [Component]
71-
*/
7225
override fun asComponent(): Component = displayName
7326

7427
companion object {
75-
/** Maximum allowed length for [name]. */
7628
const val CURRENCY_NAME_MAX_LENGTH = 16
77-
78-
/** Maximum allowed length for [symbol] and its display variant. */
7929
const val CURRENCY_SYMBOL_MAX_LENGTH = 16
8030

81-
/** Returns the platform-wide default currency. */
8231
fun default(): Currency = CurrencyService.instance.defaultCurrency
83-
84-
85-
/**
86-
* Retrieves the complete set of available currencies.
87-
*
88-
* This method provides access to all the currencies managed by the
89-
* underlying `CurrencyService` instance. The returned set includes
90-
* every defined currency that can be used in transactions or
91-
* other currency-related operations.
92-
*
93-
* @return a set of all available currencies
94-
*/
9532
fun all(): Set<Currency> = CurrencyService.instance.currencies
96-
97-
/** Retrieves a currency by its [name] or `null` if none matches. */
9833
fun byName(name: String): Currency? = CurrencyService.instance.getCurrencyByName(name)
99-
100-
/** Alias for [byName]. */
10134
operator fun get(name: String): Currency? = byName(name)
10235
}
10336
}

surf-transaction-api/src/main/kotlin/dev/slne/surf/transaction/api/currency/CurrencyScale.kt

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,50 +5,21 @@ import java.math.RoundingMode
55
import java.text.NumberFormat
66
import java.util.*
77

8-
/**
9-
* Supported decimal precisions for monetary values.
10-
*
11-
* Each entry provides a custom implementation of [format] that clamps a
12-
* [BigDecimal] to the appropriate scale. Helper overloads are supplied for
13-
* `Double` conversion and locale-aware string formatting via [NumberFormat].
14-
*/
158
enum class CurrencyScale {
16-
17-
/**
18-
* No fractional digits (`scale = 0`).
19-
*/
209
INTEGER {
2110
override fun format(amount: BigDecimal): BigDecimal {
2211
return amount.setScale(0, RoundingMode.HALF_UP)
2312
}
2413
},
2514

26-
/**
27-
* Exactly two fractional digits (`scale = 2`).
28-
*/
2915
DECIMAL_2 {
3016
override fun format(amount: BigDecimal): BigDecimal {
3117
return amount.setScale(2, RoundingMode.HALF_UP)
3218
}
3319
};
3420

35-
/**
36-
* Returns [amount] rounded to this scale.
37-
*
38-
* @param amount value to adjust
39-
* @return a new [BigDecimal] with the correct scale
40-
*/
4121
abstract fun format(amount: BigDecimal): BigDecimal
4222

43-
/**
44-
* Returns a locale-aware string representation of [amount] after applying
45-
* this scale’s rounding rules.
46-
*
47-
* @param amount value to convert and scale
48-
* @param locale formatting locale; defaults to the JVM’s current
49-
* [`FORMAT`](https://docs.oracle.com/javase/8/docs/api/java/util/Locale.Category.html#FORMAT) locale
50-
* @return human-readable number, e.g. `"1,234.00"`
51-
*/
5223
fun formatString(
5324
amount: BigDecimal,
5425
locale: Locale = Locale.getDefault(Locale.Category.FORMAT)

surf-transaction-api/src/main/kotlin/dev/slne/surf/transaction/api/transaction/Transaction.kt

Lines changed: 4 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -8,77 +8,19 @@ import org.jetbrains.annotations.Unmodifiable
88
import java.math.BigDecimal
99
import java.util.*
1010

11-
/**
12-
* Immutable description of a single monetary operation.
13-
*
14-
* A transaction moves an [amount] of a specified [currency] from an optional [senderAccount]
15-
* to an optional [receiverAccount]. When either participant is `null`, the transfer is treated
16-
* as a **system transaction**—originating from or destined to the platform itself
17-
* rather than an [Account].
18-
*
19-
* All properties are read-only; implementations are expected to be thread-safe.
20-
*/
2111
@OptIn(InternalTransactionApi::class)
2212
interface Transaction {
2313

24-
/** Globally unique identifier of this transaction instance. */
2514
val identifier: UUID
26-
27-
/**
28-
* The [OfflineCloudPlayer] who initiated this transaction.
29-
*/
3015
val initiator: UUID?
31-
32-
/**
33-
* The uuid of the [Account] initiating the transfer, or `null` for system credits.
34-
*
35-
* When `null`, the funds originate from the platform (e.g. daily rewards).
36-
*/
3716
val senderAccountId: UUID?
38-
39-
/**
40-
* The uuid of the [Account] receiving the funds, or `null` for system debits.
41-
*
42-
* When `null`, the funds are removed from circulation by the platform
43-
* (e.g., taxes, sinks).
44-
*/
4517
val receiverAccountId: UUID?
4618

47-
/**
48-
* Asynchronously retrieves the [Account] initiating the transfer, or `null` for system credits.
49-
*
50-
* When `null`, the funds originate from the platform (e.g. daily rewards).
51-
*/
52-
suspend fun senderAccount(): Account?
53-
54-
/**
55-
* Asynchronously retrieves the [Account] receiving the funds, or `null` for system debits.
56-
*
57-
* When `null`, the funds are removed from circulation by the platform
58-
* (e.g., taxes, sinks).
59-
*/
60-
suspend fun receiverAccount(): Account?
61-
62-
/**
63-
* Currency in which the [amount] is denominated.
64-
* */
6519
val currency: Currency
66-
67-
/**
68-
* Absolute value transferred, expressed with high-precision decimal arithmetic.
69-
*/
7020
val amount: BigDecimal
71-
72-
/**
73-
* Arbitrary, immutable set of metadata entries associated with this transaction.
74-
*/
75-
val data: @Unmodifiable Set<TransactionData>
76-
77-
/**
78-
* `true` if minimum-balance validation should be bypassed for this transaction.
79-
*
80-
* Typically used for administrative or system-level operations.
81-
*/
8221
val ignoreMinimumAmount: Boolean
22+
val data: @Unmodifiable Set<TransactionData>
8323

84-
}
24+
suspend fun receiverAccount(): Account?
25+
suspend fun senderAccount(): Account?
26+
}

0 commit comments

Comments
 (0)