Skip to content

danailalexiev/java-sealed-interfaces-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java Typer Error Handling with Sealed Interfaces

Overview

This short demo showcases the use of Java sealed interfaces when implementing Typed Error Handling.

It's considered a bad practice to use checked / unchecked exceptions as ways to control the logical flow of an application. Modern Java language features like sealed interfaces and pattern matching provide a way to handle all expected logical branches of an app in a secure, performant and elegant way.

Exploring the demo

The repo consists of 3 branches:

  • main uses exceptions to drive the application logic
  • feature/refactor-with-sealed-classes shows a version that uses sealed interfaces
  • feature/refactor-with-sealed-classes-and-optional shows a version that uses the now common return type of Optional<T> for the findByEmail repo method.

Additional Links

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages