Reassigning components Via an explicit canonical/compact constructor we can reassign components. For instance, when we create a MelonRecord we provide its type (for instance, Cantaloupe) and its weight in grams
Category: Getting a list from a stream
Adding more artifacts in a record – Record and record patternAdding more artifacts in a record – Record and record pattern
85. Adding more artifacts in a record So far, we know how to add in a Java record an explicit canonical/compact constructor. What else we can add? Well, for example,
Understanding records serialization 2 – Record and record patternUnderstanding records serialization 2 – Record and record pattern
Serializing/deserialzing gacContainer (typical Java class) The gacContainer object is an instance of MelonContainer which is a plain Java class. MelonContainer gacContainer = new MelonContainer( LocalDate.now().plusDays(15), “ML9000SQA0”, new Melon(“Gac”, 5000)); After
Introducing record pattern for instanceof – Record and record patternIntroducing record pattern for instanceof – Record and record pattern
92. Introducing record pattern for instanceof In order to introduce record patterns we need a record, so here is one: public record Doctor(String name, String specialty) implements Staff {} This
Introducing record pattern for switch – Record and record patternIntroducing record pattern for switch – Record and record pattern
93. Introducing record pattern for switch You already know that type patterns can be used for instanceof and switch expressions. This statement is true for record patterns as well. For
Tackling guarded record patterns – Record and record patternTackling guarded record patterns – Record and record pattern
94. Tackling guarded record patterns Exactly as in the case of type patterns, we can add guarding conditions based on the binding variables. For instance, the following code uses guarding
Simplifying expressions via record patterns – Record and record patternSimplifying expressions via record patterns – Record and record pattern
97. Simplifying expressions via record patterns Java records can help us a lot to simplify snippets of code meant to handle/evaluate different expressions (mathematical, statistical, string-based, Abstract Syntax Tree (AST),
Tackling records in Spring Boot – Record and record patternTackling records in Spring Boot – Record and record pattern
98. Tackling records in Spring Boot Java records fit perfectly in Spring Boot applications. Let’s have several scenarios where Java records can help us to increase readability and expressiveness by
Tackling records in JPA – Record and record patternTackling records in JPA – Record and record pattern
99. Tackling records in JPA If you are a fan of JPA (I cannot see why, but who am I to judge) then you’ll be more than happy to find
Tackling records in jOOQ – Record and record patternTackling records in jOOQ – Record and record pattern
100. Tackling records in jOOQ The more you learn JPA more you’ll love jOOQ. Why? Because jOOQ represents the best way to write SQL in Java. Flexibility, versatility, dialect agnostic,