Skip to content

Commit 0c94a62

Browse files
committed
Implemented createCurrency in CurrencyHolder
Replaced `UnsupportedOperationException` with a fully implemented method. Leveraged builder details for initializing currency attributes such as names, fractional digits, and symbols. Simplified creation logic and enhanced API usability.
1 parent ffd4fe6 commit 0c94a62

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main/java/net/thenextlvl/service/api/economy/currency/CurrencyHolder.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,12 @@ default Currency createCurrency(String name, Consumer<Currency.Builder> builder)
7474
* @throws IllegalArgumentException if a currency with the same name already exists
7575
*/
7676
default Currency createCurrency(Currency.Builder builder) {
77-
throw new UnsupportedOperationException("Not implemented yet");
77+
return createCurrency(builder.name(), delegate -> {
78+
builder.displayNamesPlural().forEach(delegate::displayNamePlural);
79+
builder.displayNamesSingular().forEach(delegate::displayNameSingular);
80+
builder.fractionalDigits().ifPresent(delegate::fractionalDigits);
81+
builder.symbol().ifPresent(delegate::symbol);
82+
});
7883
}
7984

8085
/**
@@ -112,7 +117,6 @@ default boolean deleteCurrency(String name) {
112117
*
113118
* @return {@code true} if multi-currency is supported, otherwise {@code false}
114119
* @implSpec If multiple currencies are supported, all respective methods have to be implemented.
115-
* @see #createCurrency(Currency.Builder)
116120
* @see #createCurrency(String, Consumer)
117121
* @see #deleteCurrency(String)
118122
* @see #getCurrencies()

0 commit comments

Comments
 (0)