From 6d720cbf99021b71ae9d2918168561db2223b030 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Wed, 29 Jun 2016 00:17:11 +0200 Subject: add checkNotNull to Lombok for future usage in super constructor call --- src/core/lombok/Lombok.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/core/lombok') diff --git a/src/core/lombok/Lombok.java b/src/core/lombok/Lombok.java index 07fd083d..164c47a8 100644 --- a/src/core/lombok/Lombok.java +++ b/src/core/lombok/Lombok.java @@ -71,4 +71,16 @@ public class Lombok { public static T preventNullAnalysis(T value) { return value; } + + /** + * Ensures that the {@code value} is not {@code null}. + * @param value the value to test for null + * @param message the message of the {@link NullPointerException} + * @return the value if it is not null + * @throws NullPointerException with the {@code message} if the value is null + */ + public static T checkNotNull(T value, String message) { + if (value == null) throw new NullPointerException(message); + return value; + } } -- cgit