-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optional<> replaced with NullableValue<>
- Loading branch information
Andrey Komarov (k0m@)
committed
Aug 17, 2021
1 parent
634cebd
commit 10e9c7f
Showing
2 changed files
with
33 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package pw.komarov.utils; | ||
|
||
public class NullableValue<E> { | ||
private static final NullableValue<?> NULLABLE = new NullableValue<>(null); | ||
|
||
private final E value; | ||
|
||
private NullableValue(E value) { | ||
this.value = value; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public static <E> NullableValue<E> of(E value) { | ||
return value == null ? (NullableValue<E>) NULLABLE : new NullableValue<>(value); | ||
} | ||
|
||
public E get() { | ||
return value; | ||
} | ||
} |