<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Optional on Devops Monk</title><link>https://blog.devops-monk.com/tags/optional/</link><description>Recent content in Optional on Devops Monk</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Mon, 04 May 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://blog.devops-monk.com/tags/optional/index.xml" rel="self" type="application/rss+xml"/><item><title>Java 8 Best Practices and Patterns for Production Code</title><link>https://blog.devops-monk.com/tutorials/java8/java8-best-practices/</link><pubDate>Mon, 04 May 2026 00:00:00 +0000</pubDate><guid>https://blog.devops-monk.com/tutorials/java8/java8-best-practices/</guid><description>Introduction Java 8 introduced a fundamentally different programming model. The features — lambdas, streams, Optional, CompletableFuture — interact with each other in ways that produce clean, readable code when used correctly and confusing, brittle code when used incorrectly. This article consolidates the most important production-ready guidance from across the series into a single reference, along with the migration checklist for moving a Java 7 codebase to Java 8.
Streams Best Practices Do: Use streams for transformations and aggregations // Good: filter → transform → collect List&amp;lt;String&amp;gt; premiumNames = customers.</description></item><item><title>Optional: Eliminating NullPointerException the Right Way</title><link>https://blog.devops-monk.com/tutorials/java8/optional/</link><pubDate>Mon, 04 May 2026 00:00:00 +0000</pubDate><guid>https://blog.devops-monk.com/tutorials/java8/optional/</guid><description>The Problem Optional Solves NullPointerException is the most common runtime exception in Java, and it is almost always avoidable. Optional&amp;lt;T&amp;gt; is not a magic fix — used incorrectly it becomes a more verbose null check. Used correctly, it encodes the possibility of absence directly in the type system, so callers can never &amp;ldquo;forget&amp;rdquo; to handle the empty case. This article covers both how to use Optional and — critically — how not to.</description></item><item><title>Stream &amp; Optional API Enhancements (Java 9–11)</title><link>https://blog.devops-monk.com/tutorials/java11/stream-optional-enhancements/</link><pubDate>Mon, 04 May 2026 00:00:00 +0000</pubDate><guid>https://blog.devops-monk.com/tutorials/java11/stream-optional-enhancements/</guid><description>Stream API — New Methods (Java 9) Java 9 added four new instance methods to Stream&amp;lt;T&amp;gt;. All are terminal-ish or intermediate operations that make common patterns expressible without workarounds.
takeWhile(Predicate) Returns elements from the beginning of the stream as long as the predicate holds, then stops. The first element that fails the predicate (and all subsequent elements) are discarded.
Stream.of(1, 2, 3, 4, 5, 1, 2) .takeWhile(n -&amp;gt; n &amp;lt; 4) .</description></item></channel></rss>