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: Tackling guarded record patterns
Iterating what we cannot have in a record – Record and record patternIterating what we cannot have in a record – Record and record pattern
86. Iterating what we cannot have in a record There are several artifacts that we cannot have in a Java record. The top 5 list includes:Let’s tackle them one by
Understanding records serialization – Record and record patternUnderstanding records serialization – Record and record pattern
89. Understanding records serialization In order to understand how Java records are serialized/deserialized, let’s have a parallel between a classical code based on plain Java classes and the same code
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
Using generic records in record patterns 2 – Record and record patternUsing generic records in record patterns 2 – Record and record pattern
This time, if we call buyFruit(seed) we get the message, This is a seed of Fairytale from India. The call matches the case SeedRecord(String type, String country) branch. And, if
Using generic records in record patterns – Record and record patternUsing generic records in record patterns – Record and record pattern
95. Using generic records in record patterns Declaring a generic record for mapping fruit data can be done as follows: public record FruitRecord<T>(T t, String country) {} Now, let’s assume
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
Introducing parallel computations with arrays – Arrays, collections and data structuresIntroducing parallel computations with arrays – Arrays, collections and data structures
101. Introducing parallel computations with arrays There was a time when CPUs were capable to perform operations on data only in the traditional mode known as SISD (Single Instruction, Single
Covering Vector API structure and terminology 3 – Arrays, collections and data structuresCovering Vector API structure and terminology 3 – Arrays, collections and data structures
Creating vectors of same primitive value Creating a vector and loading it up with a primitive value can be quickly accomplished via the broadcast() method as follows: [5, 5, 5,
Covering Vector API structure and terminology – Arrays, collections and data structuresCovering Vector API structure and terminology – Arrays, collections and data structures
102. Covering Vector API structure and terminology The Vector API is mapped by the jdk.incubator.vector module (and a package with the same name). A jdk.incubator.vector.Vector starts from a generic abstract