From eadcf5ebb0c366c8876a4c96cf1b876949744c7f Mon Sep 17 00:00:00 2001 From: Ivan Gagarkin Date: Thu, 7 Nov 2024 17:54:01 +0100 Subject: [PATCH] dbeaver/pro#3523 Add throwable function interface --- modules/org.jkiss.utils/META-INF/MANIFEST.MF | 3 +- .../utils/function/ThrowableFunction.java | 33 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 modules/org.jkiss.utils/src/org/jkiss/utils/function/ThrowableFunction.java diff --git a/modules/org.jkiss.utils/META-INF/MANIFEST.MF b/modules/org.jkiss.utils/META-INF/MANIFEST.MF index dbec555..6013756 100644 --- a/modules/org.jkiss.utils/META-INF/MANIFEST.MF +++ b/modules/org.jkiss.utils/META-INF/MANIFEST.MF @@ -14,5 +14,6 @@ Export-Package: org.jkiss.api, org.jkiss.utils.io, org.jkiss.utils.rest, org.jkiss.utils.time, - org.jkiss.utils.xml + org.jkiss.utils.xml, + org.jkiss.utils.function Automatic-Module-Name: org.jkiss.utils diff --git a/modules/org.jkiss.utils/src/org/jkiss/utils/function/ThrowableFunction.java b/modules/org.jkiss.utils/src/org/jkiss/utils/function/ThrowableFunction.java new file mode 100644 index 0000000..52273e4 --- /dev/null +++ b/modules/org.jkiss.utils/src/org/jkiss/utils/function/ThrowableFunction.java @@ -0,0 +1,33 @@ +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2024 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.utils.function; + +/** + * Throwable function. + */ +@FunctionalInterface +public interface ThrowableFunction { + + /** + * Applies this function to the given argument. + * + * @param input the function argument. + * @return the function result. + * @throws E if an exception occurs. + */ + O apply(I input) throws E; +}