Throw Exception in Optional in Java 8 1. Introduction In this tutorial, we’re going to show how to throw a custom exception when an Optional is empty. If you want to go deeper into Optional, take a look at our full guide, here. 2. Optional.orElseThrow Simply put, if the value is present, then isPresent() would return… Continue Reading java-optional-throw-exception

Jersey Filters and Interceptors 1. Introduction In this article, we’re going to explain how filters and interceptors work in the Jersey framework, as well as the main differences between these. We’ll use Jersey 2 here, and we’ll test our application using a Tomcat 9 server. 2. Application Setup Let’s first… Continue Reading jersey-filters-interceptors

Visibility Modifiers in Kotlin 1. Introduction The Kotlin programming language is built upon the Java Virtual Machine (JVM). As such, it has to follow all of the rules that the JVM imposes – including visibility modifiers. However, there are some subtle nuances in how the language implements these modifiers with… Continue Reading kotlin-visibility-modifiers

Spring Security Authentication Provider 1. Overview This tutorial will show how to set up an Authentication Provider in Spring Security to allow for additional flexibility compared to the standard scenario using a simple UserDetailsService. 2. The Authentication Provider Spring Security provides a variety of options for performing authentication. These follow… Continue Reading spring-security-authentication-provider

Hibernate Inheritance Mapping 1. Overview Relational databases don’t have a straightforward way to map class hierarchies onto database tables. To address this, the JPA specification provides several strategies: MappedSuperclass – the parent classes, can’t be entities Single Table – the entities from different classes with a common ancestor are placed… Continue Reading hibernate-inheritance