JSR-354 (javax.money) naming-compatible façade for Bankster.
This namespace is intentionally Clojure-only: it does not implement
javax.money.* interfaces. Instead, it provides functions whose names (and arities,
after translating receiver->first-arg) mirror the JSR-354 API so that people
familiar with JSR-354 can quickly orient themselves in the Bankster world.
Naming:
Currency resolution policy defaults to Bankster's registry semantics (weight-based canonical selection).
JSR-354 (javax.money) naming-compatible façade for Bankster. This namespace is intentionally **Clojure-only**: it does not implement `javax.money.*` interfaces. Instead, it provides functions whose names (and arities, after translating receiver->first-arg) mirror the JSR-354 API so that people familiar with JSR-354 can quickly orient themselves in the Bankster world. Naming: - kebab-case vars are the canonical ones, - camelCase vars are provided as simple aliases. Currency resolution policy defaults to Bankster's registry semantics (weight-based canonical selection).
(abs a)JSR-354-ish: MonetaryAmount.abs().
JSR-354-ish: `MonetaryAmount.abs()`.
(add a b)JSR-354-ish: MonetaryAmount.add(MonetaryAmount).
JSR-354-ish: `MonetaryAmount.add(MonetaryAmount)`.
Standard MonetaryContext attribute key for amount type.
Standard MonetaryContext attribute key for amount type.
Standard MonetaryContext attribute key for fixed-scale flag.
Standard MonetaryContext attribute key for fixed-scale flag.
Standard MonetaryContext attribute key for max scale.
Standard MonetaryContext attribute key for max scale.
Standard MonetaryContext attribute key for number type.
Standard MonetaryContext attribute key for number type.
Standard MonetaryContext attribute key for precision.
Standard MonetaryContext attribute key for precision.
(compare-to a b)JSR-354-ish: MonetaryAmount.compareTo(MonetaryAmount).
JSR-354-ish: `MonetaryAmount.compareTo(MonetaryAmount)`.
(context)(context opts)Builds a MonetaryContext.
Options (all optional):
:amount-type -> Class (default: io.randomseed.bankster.Money):number-type -> Class (default: java.math.BigDecimal):precision -> integer/long or nil:max-scale -> integer/long or nil:fixed-scale? -> boolean or nil:attrs -> map (keys normalized to strings; see attr-* vars)Bankster runtime extras (stored under :bankster in the resulting record):
:registry -> io.randomseed.bankster.Registry (or nil):rounding-mode -> rounding spec accepted by scale/post-parse-rounding:rescale-each? -> boolean:currency-resolution -> keyword (default: :weight)The builder also standardizes a small set of string keys in attrs:
attr-amount-type, attr-number-type, and (when present) attr-precision,
attr-max-scale, attr-fixed-scale.
Builds a `MonetaryContext`. Options (all optional): - `:amount-type` -> Class (default: `io.randomseed.bankster.Money`) - `:number-type` -> Class (default: `java.math.BigDecimal`) - `:precision` -> integer/long or nil - `:max-scale` -> integer/long or nil - `:fixed-scale?` -> boolean or nil - `:attrs` -> map (keys normalized to strings; see `attr-*` vars) Bankster runtime extras (stored under `:bankster` in the resulting record): - `:registry` -> `io.randomseed.bankster.Registry` (or nil) - `:rounding-mode` -> rounding spec accepted by `scale/post-parse-rounding` - `:rescale-each?` -> boolean - `:currency-resolution` -> keyword (default: `:weight`) The builder also standardizes a small set of string keys in `attrs`: `attr-amount-type`, `attr-number-type`, and (when present) `attr-precision`, `attr-max-scale`, `attr-fixed-scale`.
JSR-354-ish: MonetaryAmountFactory-like constructor.
Delegates to io.randomseed.bankster.money/value (Accountable).
JSR-354-ish: MonetaryAmountFactory-like constructor. Delegates to `io.randomseed.bankster.money/value` (Accountable).
(divide a divisor)(divide a divisor rounding-mode)JSR-354-ish: MonetaryAmount.divide(Number) and MonetaryAmount.divide(Number, RoundingMode).
JSR-354-ish: `MonetaryAmount.divide(Number)` and `MonetaryAmount.divide(Number, RoundingMode)`.
(get-currencies)JSR-354-ish: Monetary.getCurrencies().
Returns a set of currencies known to the default registry.
JSR-354-ish: `Monetary.getCurrencies()`. Returns a set of currencies known to the default registry.
(get-currency currency-or-money)JSR-354-ish: Monetary.getCurrency(String) and MonetaryAmount.getCurrency().
Returns a Bankster Currency resolved in the default registry (weight-based).
JSR-354-ish: `Monetary.getCurrency(String)` and `MonetaryAmount.getCurrency()`. Returns a Bankster `Currency` resolved in the default registry (weight-based).
(get-currency-code currency-or-money)JSR-354-ish: CurrencyUnit.getCurrencyCode().
JSR-354-ish: `CurrencyUnit.getCurrencyCode()`.
(get-default-fraction-digits currency-or-money)JSR-354-ish: CurrencyUnit.getDefaultFractionDigits().
Returns Bankster's currency scale (decimal places) or -1 for auto-scaled.
JSR-354-ish: `CurrencyUnit.getDefaultFractionDigits()`. Returns Bankster's currency scale (decimal places) or `-1` for auto-scaled.
(get-default-rounding)JSR-354-ish: Monetary.getDefaultRounding().
Returns a MonetaryOperator-like function (Money -> Money) that rescales a money
amount to its currency's nominal scale.
Uses io.randomseed.bankster.scale/*rounding-mode* when bound, otherwise defaults
to io.randomseed.bankster.scale/ROUND_HALF_EVEN.
JSR-354-ish: `Monetary.getDefaultRounding()`. Returns a MonetaryOperator-like function `(Money -> Money)` that rescales a money amount to its currency's nominal scale. Uses `io.randomseed.bankster.scale/*rounding-mode*` when bound, otherwise defaults to `io.randomseed.bankster.scale/ROUND_HALF_EVEN`.
(get-number money)JSR-354-ish: MonetaryAmount.getNumber().
Returns the money amount as java.math.BigDecimal.
JSR-354-ish: `MonetaryAmount.getNumber()`. Returns the money amount as `java.math.BigDecimal`.
(get-number-stripped money)JSR-354-ish: MonetaryAmount.getNumberStripped().
Returns the money amount with trailing zeros stripped.
JSR-354-ish: `MonetaryAmount.getNumberStripped()`. Returns the money amount with trailing zeros stripped.
(get-numeric-code currency-or-money)JSR-354-ish: CurrencyUnit.getNumericCode().
Returns Bankster's numeric-id (ISO 4217) or -1 when missing.
JSR-354-ish: `CurrencyUnit.getNumericCode()`. Returns Bankster's numeric-id (ISO 4217) or `-1` when missing.
(is-equal-to a b)JSR-354-ish: MonetaryAmount.isEqualTo(MonetaryAmount).
Scale-insensitive comparison of amounts (currency must match).
JSR-354-ish: `MonetaryAmount.isEqualTo(MonetaryAmount)`. Scale-insensitive comparison of amounts (currency must match).
(is-greater-than a b)JSR-354-ish: MonetaryAmount.isGreaterThan(MonetaryAmount).
JSR-354-ish: `MonetaryAmount.isGreaterThan(MonetaryAmount)`.
(is-greater-than-or-equal-to a b)JSR-354-ish: MonetaryAmount.isGreaterThanOrEqualTo(MonetaryAmount).
JSR-354-ish: `MonetaryAmount.isGreaterThanOrEqualTo(MonetaryAmount)`.
(is-less-than a b)JSR-354-ish: MonetaryAmount.isLessThan(MonetaryAmount).
JSR-354-ish: `MonetaryAmount.isLessThan(MonetaryAmount)`.
(is-less-than-or-equal-to a b)JSR-354-ish: MonetaryAmount.isLessThanOrEqualTo(MonetaryAmount).
JSR-354-ish: `MonetaryAmount.isLessThanOrEqualTo(MonetaryAmount)`.
(is-negative a)JSR-354-ish: MonetaryAmount.isNegative().
JSR-354-ish: `MonetaryAmount.isNegative()`.
(is-negative-or-zero a)JSR-354-ish: MonetaryAmount.isNegativeOrZero().
JSR-354-ish: `MonetaryAmount.isNegativeOrZero()`.
(is-positive a)JSR-354-ish: MonetaryAmount.isPositive().
JSR-354-ish: `MonetaryAmount.isPositive()`.
(is-positive-or-zero a)JSR-354-ish: MonetaryAmount.isPositiveOrZero().
JSR-354-ish: `MonetaryAmount.isPositiveOrZero()`.
(is-zero a)JSR-354-ish: MonetaryAmount.isZero().
JSR-354-ish: `MonetaryAmount.isZero()`.
(multiply a multiplicand)JSR-354-ish: MonetaryAmount.multiply(Number).
JSR-354-ish: `MonetaryAmount.multiply(Number)`.
(negate a)JSR-354-ish: MonetaryAmount.negate().
JSR-354-ish: `MonetaryAmount.negate()`.
(plus a)JSR-354-ish: MonetaryAmount.plus().
JSR-354-ish: `MonetaryAmount.plus()`.
(query amount monetary-query)JSR-354-ish: MonetaryAmount.query(MonetaryQuery).
In Clojure, a MonetaryQuery is just a function (Money -> any).
JSR-354-ish: `MonetaryAmount.query(MonetaryQuery)`. In Clojure, a MonetaryQuery is just a function `(Money -> any)`.
(remainder a divisor)(remainder a divisor rounding-mode)JSR-354-ish: MonetaryAmount.remainder(Number) and MonetaryAmount.remainder(Number, RoundingMode).
JSR-354-ish: `MonetaryAmount.remainder(Number)` and `MonetaryAmount.remainder(Number, RoundingMode)`.
(signum a)JSR-354-ish: MonetaryAmount.signum().
JSR-354-ish: `MonetaryAmount.signum()`.
(strip-trailing-zeros a)JSR-354-ish: MonetaryAmount.stripTrailingZeros().
JSR-354-ish: `MonetaryAmount.stripTrailingZeros()`.
(subtract a b)JSR-354-ish: MonetaryAmount.subtract(MonetaryAmount).
JSR-354-ish: `MonetaryAmount.subtract(MonetaryAmount)`.
(with amount operator)JSR-354-ish: MonetaryAmount.with(MonetaryOperator).
In Clojure, a MonetaryOperator is just a function (Money -> Money).
JSR-354-ish: `MonetaryAmount.with(MonetaryOperator)`. In Clojure, a MonetaryOperator is just a function `(Money -> Money)`.
(with-context ctx & body)Applies a JSR-354-style context in a lexical scope.
In this Clojure-only compat layer, we interpret the context as inputs to dynamic Bankster runtime settings (registry and scaling/rounding), not as mutable state.
Uses (:bankster ctx) as an optional map of settings.
Supported keys:
:registry -> io.randomseed.bankster.Registry (binds registry/*default*):rounding-mode -> java.math.RoundingMode or a value accepted by
io.randomseed.bankster.scale/post-parse-rounding
(binds scale/*rounding-mode*):rescale-each? -> boolean (binds scale/*each*)Unspecified keys do not override current bindings. Keys may be present with nil
values to explicitly clear a binding (e.g. set rounding-mode to nil).
Applies a JSR-354-style context in a lexical scope.
In this Clojure-only compat layer, we interpret the context as *inputs to dynamic
Bankster runtime settings* (registry and scaling/rounding), not as mutable state.
Uses `(:bankster ctx)` as an optional map of settings.
Supported keys:
- `:registry` -> `io.randomseed.bankster.Registry` (binds `registry/*default*`)
- `:rounding-mode` -> `java.math.RoundingMode` or a value accepted by
`io.randomseed.bankster.scale/post-parse-rounding`
(binds `scale/*rounding-mode*`)
- `:rescale-each?` -> boolean (binds `scale/*each*`)
Unspecified keys do not override current bindings. Keys may be present with `nil`
values to explicitly clear a binding (e.g. set rounding-mode to nil).(withContext ctx & body)Alias for with-context.
Alias for `with-context`.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |