Tag: Stream API

Divide A List To Sub-Lists Via Collectors

Consider a List of Color objects with attributes of index, name and group. This object is defined as, Group is simply an Enum of, My list of colors are the following, Now, I want to divide these colors into their own sub-lists of color grouping based on the value of the object’s Group attribute. Traditionally,…

continue reading
No Comments

Rewriting Nested Ifs With Java 8 Stream

Say I have these numbers in an array, for example: I want to do something with that set of numbers, such as taking out null values, and extracting only the odd ones. Too take it further, maybe I want an even number or two mixed in the processed list as well. So I have this…

continue reading
No Comments

Removing Null Values In A List Using Java 8 Stream

The other day, I was working on a huge JSON object that had a number of collections in it. The entire object had to be saved into a relational database, which means I was mapping out the raw JSON data to its logical representation as database tables. Though the object wasn’t that complicated, it did…

continue reading
No Comments