According to The Britannica Dictionary, the term collection designates
a group of interesting or beautiful objects brought together in order to show or study them.
Tips, Expertise, Articles and Advice from the Pro's for Your Website or Blog to Succeed
According to The Britannica Dictionary, the term collection designates
a group of interesting or beautiful objects brought together in order to show or study them.
As mentioned, JPAstreamer allows JPA queries to be expressed as standard Java Streams using short and concise, type-safe declarative constructs. This makes our code shorter, less complex, and easier to read and maintain. Best of all, we can stick to using only Java code without needing to mix it with SQL/JPQL or other language constructs/DSL.
In short, we can query a database like this:
Of course we all love the creamy, functional goodness that oozed from Java 8. And I'm certainly no imperativist, like those in this Java video.
But one thing bothers me.
In Java, we can use a Predicate
to test if something is true
or false
. This is especially useful when we use the filter
method of the Java Stream API.
You may also like: Towards More Functional Java Using Lambdas as Predicates
We can use lambda expressions to define our Predicate
or implement the Predicate
interface. If we want to combine different Predicate
objects, we can use the or
, and
, and negate
methods of the Predicate
interfaces. These are default methods of the interface and will return a new Predicate
.
The class java.util.Optional
is implemented as a single immutable concrete class that internally handles two cases; one with an element and one without. Wouldn't it have been a better choice to let Optional
be an interface and have two different implementations implement that interface instead? After all, that is what we generally are taught to do in an object-oriented language.
In this article, we will learn about some of the potential arguments for the current Optional
implementation. We will also learn why Streams are implemented in a different way, enabling Streams to be obtained from files or even database tables.
Sorting a Stream instance is straightforward and involves just a single API method call — achieving the opposite is not that easy.
In this article, we'll see how to shuffle a Stream in Java both eagerly and lazily using Stream Collectors factories and custom Spliterators.
Recently, while developing examples for the groupingBy() guide, I discovered the handy JDK 10 additions to the Stream API Collectors, allowing collecting Stream pipelines into unmodifiable data structures.
In this super short article, we'll have a closer look at them.