We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent aba6eb0 commit 9e01a99Copy full SHA for 9e01a99
1 file changed
src/main/java/com/saicone/types/TypeParser.java
@@ -26,7 +26,7 @@
26
* @param <T> the type result of the function.
27
*/
28
@FunctionalInterface
29
-public interface TypeParser<T> {
+public interface TypeParser<T> extends Function<Object, T> {
30
31
/**
32
* Create a type parser with associated type.
@@ -153,6 +153,12 @@ default boolean isInstance(@Nullable Object object) {
153
throw new RuntimeException("The current type parser doesn't support instance check");
154
}
155
156
+ @Override
157
+ @Contract("null -> null")
158
+ default @Nullable T apply(@Nullable Object object) {
159
+ return object == null ? null : parse(object);
160
+ }
161
+
162
163
* Parse the given object into required type.
164
*
0 commit comments