Add null-check to Lazy

This commit is contained in:
Blue (Lukas Rieger) 2021-05-23 16:08:52 +02:00
parent c1f3122c68
commit 4a54cf7b79
No known key found for this signature in database
GPG Key ID: 904C4995F9E1F800
1 changed files with 5 additions and 0 deletions

View File

@ -24,6 +24,7 @@
*/
package de.bluecolored.bluemap.core.util;
import java.util.Objects;
import java.util.function.Supplier;
public class Lazy<T> {
@ -32,11 +33,15 @@ public class Lazy<T> {
private T value;
public Lazy(Supplier<T> loader) {
Objects.requireNonNull(loader);
this.loader = loader;
this.value = null;
}
public Lazy(T value) {
Objects.requireNonNull(value);
this.loader = null;
this.value = value;
}