Posted at September 23, 2020 / Carlos Chacin
Retrofit is pluggable allowing different serialization formats and their libraries to be used for converting Java types to their HTTP representation and parsing HTTP entities back into Java types.
These are called converters, and Retrofit includes a few first-party modules for popular frameworks
Just for fun, I created a Retrofit2 Converter.Factory
for JakartaEE Json-B.
Read more ...
Posted at April 30, 2020 / Carlos Chacin
After a long day trying to figure out how to reset all my IntelliJ settings, I decided to write this to document the obvious solution that was not that obvious to me.
I was using the π₯ JetBrains Toolbox App π₯ for a while to manage my IntelliJ Idea Ultimate installation along with other tools like Rider, WebStorm, and the Early Access Preview for IntelliJ Community Edition.
After several installations and reinstallations of IDEs and different Java/JDK versions (8, 9, 11, 14), the IDE was not able to import my maven projects. The IntelliJ IDEA was acting as a simple text editor at this time π.
Read more ...
Posted at April 20, 2020 / Carlos Chacin
In the previous article about Java 14 Records, we saw how to start creating Records to avoid writing much boilerplate code that the compiler would generate for us.
Now the next steps are to see how we can serialize records to JSON and deserialize JSON to records to be able to use them as a request/response representation for microservices.
In this case, we would use the JSON-B specification used by JakartaEE and MicroProfile implementations like GlashFish, TomEE, Wildfly, OpenLiberty, and Quarkus.
Read more ...
Posted at April 17, 2020 / Carlos Chacin
Record is a new kind of type declaration in the Java language. Like an enum, a record is a restricted form of class. It declares its representation and commits to an API that matches that representation. Records give up a freedom that classes usually enjoy: the ability to decouple API from representation. In return, records gain a significant degree of concision.
A record has a name and a state description. The state description declares the components of the record. Optionally, a record has a body. For example:
record Point(int x, int y) { }
Read more ...
Posted at April 12, 2020 / Carlos Chacin
In this article, we are going to compare some of the features of the Immutables.org library, Google AutoValue and Project Lombok:
- Generated the
Builder
pattern by default?
- Generated helper methods for, i.e.,
Optional
and List
?
- The number of lines of code to write?
- Required IDEβs plugins?
- Are the objects immutable?
The three libraries are based on an annotation processor to generate/modify code for us:
- Immutable classes
equals
, hashCode
and toString
methods
- other utilities
NOTE: Immutables
and AutoValue
generate new classes with the processor, and Lombok
modifies the bytecode of the original class.
Read more ...