Jakarta money is a helpful library for a better developer experience when combining Money-API with Jakarta and MicroProfile API.

Related tags

JSON jakarta-money
Overview

jakarta-money

Jakarta money is a helpful library for a better developer experience when combining Money-API with Jakarta and MicroProfile API.

The dependency:

<dependency>
   <groupId>org.javamoneygroupId>
   <artifactId>jakartaartifactId>
   <version>0.0.1-SNAPSHOTversion>
dependency>

The API brings some libraries that is split by specification:

  • Bean Validator
  • JAXRS
  • CDI
  • JPA
  • JSF

Bean Validator

JSR 380 is a specification of the Java API for bean validation, part of Jakarta EE and JavaSE. It ensures that the properties of a bean meet specific criteria, using annotations such as @NotNull, @Min, and @Max.

To make an integration with Java-money Jakarta-money has four annotations:

CurrencyAccepted: Informs the currencies that are allowed on validation. It works with MonetaryAmount and CurrencyUnit.

@CurrencyAccepted(currencies = "BRL")
private MonetaryAmount money;
@CurrencyAccepted(currencies = "BRL")
private CurrencyUnit currencyUnit;

CurrencyRejected: Informs the currencies that are rejected on validation. It works with MonetaryAmount and CurrencyUnit.

@CurrencyRejected(currencies = "BRL")
private MonetaryAmount money;
@CurrencyRejected(currencies = "BRL")
private CurrencyUnit currencyUnit;

MonetaryMax: Informs the maximum value of a MonetaryAmount.

@MonetaryMax("10.12")
private MonetaryAmount money;

MonetaryMin: Informs the minimum value of a MonetaryAmount.

@MonetaryMin("10.12")
private MonetaryAmount money;

JAXRS

If you want JAX-RS to automatically convert parameters such as query params, path params, or others, you need to create a ParamConverter.

It has support to:

  • CurrencyUnit
  • MonetaryAmount
@Path("monetary")
@ApplicationScoped
public class MoneyResource {

    @GET
    public String findByCurrency(@QueryParam("currency") CurrencyUnit currency) {
        return "hello, " + currency;
    }
}

JPA

Jakarta Persistence defines a standard for managing persistence and object/relational mapping in Java(R) environments.

It has support to both: MoneyAmount and CurrencyUnit.

@Column
@Convert(converter = CurrencyConverter.class)
private CurrencyUnit currency;

@Column
@Convert(converter = MoneyConverter.class)
private MonetaryAmount money;

CDI

Currency Annotation

The Currency annotation allows to inject a currency unit based in the Currency code.

@Inject
@Currency("USD")
private CurrencyUnit currency;

MonetaryProducer

The MonetaryProducer annotations allows to inject the MonetaryAmountProducer

@Inject
@MonetaryProducer
private MonetaryAmountProducer producer;

@Inject
@Currency("EUR")
private CurrencyUnit currency;

//
MonetaryAmount amount = producer.create(currency, 10);
You might also like...

A universal types-preserving Java serialization library that can convert arbitrary Java Objects into JSON and back

A universal types-preserving Java serialization library that can convert arbitrary Java Objects into JSON and back, with a transparent support of any kind of self-references and with a full Java 9 compatibility.

Dec 30, 2021

Java with functions is a small java tools and utils library.

Java with functions is a small java tools and utils library.

Oct 14, 2022

dOOv (Domain Object Oriented Validation) a fluent API for type-safe bean validation and mapping

dOOv (Domain Object Oriented Validation) dOOv is a fluent API for typesafe domain model validation and mapping. It uses annotations, code generation a

Nov 20, 2022

High performance JVM JSON library

High performance JVM JSON library

DSL-JSON library Fastest JVM (Java/Android/Scala/Kotlin) JSON library with advanced compile-time databinding support. Compatible with DSL Platform. Ja

Jan 2, 2023

JSON to JSON transformation library written in Java.

Jolt JSON to JSON transformation library written in Java where the "specification" for the transform is itself a JSON document. Useful For Transformin

Dec 30, 2022

Sawmill is a JSON transformation Java library

Sawmill is a JSON transformation Java library

Update: June 25, 2020 The 2.0 release of Sawmill introduces a breaking change to the GeoIpProcessor to comply with the updated license of the MaxMind

Jan 1, 2023

MapNeat is a JVM library written in Kotlin that provides an easy to use DSL (Domain Specific Language) for transforming JSON to JSON, XML to JSON, POJO to JSON in a declarative way.

MapNeat is a JVM library written in Kotlin that provides an easy to use DSL (Domain Specific Language) for transforming JSON to JSON, XML to JSON, POJ

Sep 17, 2022

Genson a fast & modular Java Json library

Genson Genson is a complete json - java conversion library, providing full databinding, streaming and much more. Gensons main strengths? Easy to use

Jan 3, 2023

Open NFCSense Library

Open NFCSense Library

OpenNFCSense API Open-source API of NFCSense for the Processing programming environment (http://processing.org/). Please refer to the following workfl

Jul 25, 2022
Comments
Owner
Money and Currency API | JavaMoney
Money and Currency API | JavaMoney Project
Money and Currency API | JavaMoney
Aplicación para convertir números entre base con y sin decimales para la certificación de Kotlin Developer de JetBrains Academy.

Kotlin Number Base Converter Aplicación para convertir números entre distintas bases con y sin decimales para la certificación de Kotlin Developer de

José Luis González Sánchez 1 Jan 13, 2022
A Java annotation processor used for automatically generating better builder codes.

BetterBuilder BetterBuilder is a Java annotation processor used for automatically generating better builder codes(builder design pattern), which can m

LEO D PEN 9 Apr 6, 2021
Lean JSON Library for Java, with a compact, elegant API.

mJson is an extremely lightweight Java JSON library with a very concise API. The source code is a single Java file. The license is Apache 2.0. Because

Borislav Iordanov 77 Dec 25, 2022
Elide is a Java library that lets you stand up a GraphQL/JSON-API web service with minimal effort.

Elide Opinionated APIs for web & mobile applications. Read this in other languages: 中文. Table of Contents Background Documentation Install Usage Secur

Yahoo 921 Jan 3, 2023
Android processing and secured library for managing SharedPreferences as key-value elements efficiently and structurally.

Memo Android processing and secured library for managing SharedPreferences as key-value elements efficiently and structurally. 1. Depend on our librar

ZeoFlow 18 Jun 30, 2022
A JSON Transmission Protocol and an ORM Library for automatically providing APIs and Docs.

?? 零代码、热更新、全自动 ORM 库,后端接口和文档零代码,前端(客户端) 定制返回 JSON 的数据和结构。 ?? A JSON Transmission Protocol and an ORM Library for automatically providing APIs and Docs.

Tencent 14.4k Dec 31, 2022
A Java serialization/deserialization library to convert Java Objects into JSON and back

Gson Gson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON string to a

Google 21.7k Jan 8, 2023
Screaming fast JSON parsing and serialization library for Android.

#LoganSquare The fastest JSON parsing and serializing library available for Android. Based on Jackson's streaming API, LoganSquare is able to consiste

BlueLine Labs 3.2k Dec 18, 2022
A modern JSON library for Kotlin and Java.

Moshi Moshi is a modern JSON library for Android and Java. It makes it easy to parse JSON into Java objects: String json = ...; Moshi moshi = new Mos

Square 8.7k Dec 31, 2022
A modern and lightweight library for working with email addresses in Java

JMail A modern, fast, zero-dependency library for working with email addresses and performing email address validation in Java. Built for Java 8 and u

Rohan Nagar 67 Dec 22, 2022