Create the new package org.apache.commons.function to parallel the JRE's

java.util.function to provide home for our "failable" version of the
JRE's functional interfaces.
This commit is contained in:
Gary Gregory 2020-06-17 15:58:26 -04:00
parent 9214c65371
commit 8b54728564
34 changed files with 3053 additions and 1505 deletions

View File

@ -25,44 +25,21 @@
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.BiPredicate;
import java.util.function.BooleanSupplier;
import java.util.function.Consumer;
import java.util.function.DoubleBinaryOperator;
import java.util.function.DoubleConsumer;
import java.util.function.DoubleFunction;
import java.util.function.DoublePredicate;
import java.util.function.DoubleSupplier;
import java.util.function.DoubleToIntFunction;
import java.util.function.DoubleToLongFunction;
import java.util.function.Function;
import java.util.function.IntBinaryOperator;
import java.util.function.IntConsumer;
import java.util.function.IntFunction;
import java.util.function.IntPredicate;
import java.util.function.IntSupplier;
import java.util.function.IntToDoubleFunction;
import java.util.function.IntToLongFunction;
import java.util.function.LongBinaryOperator;
import java.util.function.LongConsumer;
import java.util.function.LongFunction;
import java.util.function.LongPredicate;
import java.util.function.LongSupplier;
import java.util.function.LongToDoubleFunction;
import java.util.function.LongToIntFunction;
import java.util.function.ObjDoubleConsumer;
import java.util.function.ObjIntConsumer;
import java.util.function.ObjLongConsumer;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.function.ToDoubleBiFunction;
import java.util.function.ToDoubleFunction;
import java.util.function.ToIntBiFunction;
import java.util.function.ToIntFunction;
import java.util.function.ToLongBiFunction;
import java.util.function.ToLongFunction;
import java.util.stream.Stream;
import org.apache.commons.lang3.Streams.FailableStream;
import org.apache.commons.lang3.function.FailableBooleanSupplier;
import org.apache.commons.lang3.function.FailableDoubleBinaryOperator;
import org.apache.commons.lang3.function.FailableDoubleConsumer;
import org.apache.commons.lang3.function.FailableDoubleSupplier;
import org.apache.commons.lang3.function.FailableIntConsumer;
import org.apache.commons.lang3.function.FailableIntSupplier;
import org.apache.commons.lang3.function.FailableLongConsumer;
import org.apache.commons.lang3.function.FailableLongSupplier;
/**
* This class provides utility functions, and classes for working with the {@code java.util.function} package, or more
@ -101,6 +78,8 @@ public class Functions {
/**
* A functional interface like {@link BiConsumer} that declares a {@code Throwable}.
*
* <p>TODO for 4.0: Move to org.apache.commons.lang3.function.</p>
*
* @param <O1> Consumed type 1.
* @param <O2> Consumed type 2.
@ -122,6 +101,8 @@ public interface FailableBiConsumer<O1, O2, T extends Throwable> {
/**
* A functional interface like {@link BiFunction} that declares a {@code Throwable}.
*
* <p>TODO for 4.0: Move to org.apache.commons.lang3.function.</p>
*
* @param <O1> Input type 1.
* @param <O2> Input type 2.
* @param <R> Return type.
@ -144,6 +125,8 @@ public interface FailableBiFunction<O1, O2, R, T extends Throwable> {
/**
* A functional interface like {@link BiPredicate} that declares a {@code Throwable}.
*
* <p>TODO for 4.0: Move to org.apache.commons.lang3.function.</p>
*
* @param <O1> Predicate type 1.
* @param <O2> Predicate type 2.
* @param <T> Thrown exception.
@ -162,27 +145,11 @@ public interface FailableBiPredicate<O1, O2, T extends Throwable> {
boolean test(O1 object1, O2 object2) throws T;
}
/**
* A functional interface like {@link BooleanSupplier} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableBooleanSupplier<T extends Throwable> {
/**
* Supplies a boolean.
*
* @return a result
* @throws T if the supplier fails
*/
boolean getAsBoolean() throws T;
}
/**
* A functional interface like {@link java.util.concurrent.Callable} that declares a {@code Throwable}.
*
* <p>TODO for 4.0: Move to org.apache.commons.lang3.function.</p>
*
* @param <R> Return type.
* @param <T> Thrown exception.
*/
@ -201,6 +168,8 @@ public interface FailableCallable<R, T extends Throwable> {
/**
* A functional interface like {@link Consumer} that declares a {@code Throwable}.
*
* <p>TODO for 4.0: Move to org.apache.commons.lang3.function.</p>
*
* @param <O> Consumed type 1.
* @param <T> Thrown exception.
*/
@ -216,141 +185,11 @@ public interface FailableConsumer<O, T extends Throwable> {
void accept(O object) throws T;
}
/**
* A functional interface like {@link DoubleBinaryOperator} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableDoubleBinaryOperator<T extends Throwable> {
/**
* Applies this operator to the given operands.
*
* @param left the first operand
* @param right the second operand
* @return the operator result
* @throws T if the operation fails
*/
double applyAsDouble(double left, double right) throws T;
}
/**
* A functional interface like {@link DoubleConsumer} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableDoubleConsumer<T extends Throwable> {
/**
* Accepts the consumer.
*
* @param value the parameter for the consumable to accept
* @throws T Thrown when the consumer fails.
*/
void accept(double value) throws T;
}
/**
* A functional interface like {@link DoubleFunction} that declares a {@code Throwable}.
*
* @param <R> Return type.
* @param <T> Thrown exception.
*/
@FunctionalInterface
public interface FailableDoubleFunction<R, T extends Throwable> {
/**
* Applies this function.
*
* @param input the input for the function
* @return the result of the function
* @throws T Thrown when the function fails.
*/
R apply(double input) throws T;
}
/**
* A functional interface like {@link DoublePredicate} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableDoublePredicate<T extends Throwable> {
/**
* Tests the predicate.
*
* @param value the parameter for the predicate to accept.
* @return {@code true} if the input argument matches the predicate, {@code false} otherwise.
* @throws T Thrown when the consumer fails.
*/
boolean test(double value) throws T;
}
/**
* A functional interface like {@link DoubleSupplier} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableDoubleSupplier<T extends Throwable> {
/**
* Supplies a double.
*
* @return a result
* @throws T if the supplier fails
*/
double getAsDouble() throws T;
}
/**
* A functional interface like {@link DoubleToIntFunction} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableDoubleToIntFunction<T extends Throwable> {
/**
* Applies this function to the given argument.
*
* @param value the function argument
* @return the function result
* @throws T Thrown when the function fails.
*/
int applyAsInt(double value) throws T;
}
/**
* A functional interface like {@link DoubleToLongFunction} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableDoubleToLongFunction<T extends Throwable> {
/**
* Applies this function to the given argument.
*
* @param value the function argument
* @return the function result
* @throws T if the operation fails
*/
int applyAsLong(double value) throws T;
}
/**
* A functional interface like {@link Function} that declares a {@code Throwable}.
*
* <p>TODO for 4.0: Move to org.apache.commons.lang3.function.</p>
*
* @param <I> Input type 1.
* @param <R> Return type.
* @param <T> Thrown exception.
@ -368,333 +207,11 @@ public interface FailableFunction<I, R, T extends Throwable> {
R apply(I input) throws T;
}
/**
* A functional interface like {@link IntBinaryOperator} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableIntBinaryOperator<T extends Throwable> {
/**
* Applies this operator to the given operands.
*
* @param left the first operand
* @param right the second operand
* @return the operator result
* @throws T if the operation fails
*/
int applyAsInt(int left, int right) throws T;
}
/**
* A functional interface like {@link IntConsumer} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableIntConsumer<T extends Throwable> {
/**
* Accepts the consumer.
*
* @param value the parameter for the consumable to accept
* @throws T Thrown when the consumer fails.
*/
void accept(int value) throws T;
}
/**
* A functional interface like {@link IntFunction} that declares a {@code Throwable}.
*
* @param <R> Return type.
* @param <T> Thrown exception.
*/
@FunctionalInterface
public interface FailableIntFunction<R, T extends Throwable> {
/**
* Applies this function.
*
* @param input the input for the function
* @return the result of the function
* @throws T Thrown when the function fails.
*/
R apply(int input) throws T;
}
/**
* A functional interface like {@link IntPredicate} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableIntPredicate<T extends Throwable> {
/**
* Tests the predicate.
*
* @param value the parameter for the predicate to accept.
* @return {@code true} if the input argument matches the predicate, {@code false} otherwise.
* @throws T Thrown when the consumer fails.
*/
boolean test(int value) throws T;
}
/**
* A functional interface like {@link IntSupplier} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableIntSupplier<T extends Throwable> {
/**
* Supplies an int.
*
* @return a result
* @throws T if the supplier fails
*/
int getAsInt() throws T;
}
/**
* A functional interface like {@link IntToDoubleFunction} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableIntToDoubleFunction<T extends Throwable> {
/**
* Applies this function to the given argument.
*
* @param value the function argument
* @return the function result
* @throws T Thrown when the function fails.
*/
double applyAsDouble(int value) throws T;
}
/**
* A functional interface like {@link IntToLongFunction} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableIntToLongFunction<T extends Throwable> {
/**
* Applies this function to the given argument.
*
* @param value the function argument
* @return the function result
* @throws T Thrown when the function fails.
*/
long applyAsLong(int value) throws T;
}
/**
* A functional interface like {@link LongBinaryOperator} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableLongBinaryOperator<T extends Throwable> {
/**
* Applies this operator to the given operands.
*
* @param left the first operand
* @param right the second operand
* @return the operator result
* @throws T if the operation fails
*/
long applyAsLong(long left, long right) throws T;
}
/**
* A functional interface like {@link LongConsumer} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableLongConsumer<T extends Throwable> {
/**
* Accepts the consumer.
*
* @param object the parameter for the consumable to accept
* @throws T Thrown when the consumer fails.
*/
void accept(long object) throws T;
}
/**
* A functional interface like {@link LongFunction} that declares a {@code Throwable}.
*
* @param <R> Return type.
* @param <T> Thrown exception.
*/
@FunctionalInterface
public interface FailableLongFunction<R, T extends Throwable> {
/**
* Applies this function.
*
* @param input the input for the function
* @return the result of the function
* @throws T Thrown when the function fails.
*/
R apply(long input) throws T;
}
/**
* A functional interface like {@link LongPredicate} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableLongPredicate<T extends Throwable> {
/**
* Tests the predicate.
*
* @param value the parameter for the predicate to accept.
* @return {@code true} if the input argument matches the predicate, {@code false} otherwise.
* @throws T Thrown when the consumer fails.
*/
boolean test(long value) throws T;
}
/**
* A functional interface like {@link LongSupplier} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableLongSupplier<T extends Throwable> {
/**
* Supplies a long.
*
* @return a result
* @throws T if the supplier fails
*/
long getAsLong() throws T;
}
/**
* A functional interface like {@link LongToDoubleFunction} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableLongToDoubleFunction<T extends Throwable> {
/**
* Applies this function to the given argument.
*
* @param value the function argument
* @return the function result
* @throws T Thrown when the function fails.
*/
double applyAsDouble(long value) throws T;
}
/**
* A functional interface like {@link LongToIntFunction} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableLongToIntFunction<T extends Throwable> {
/**
* Applies this function to the given argument.
*
* @param value the function argument
* @return the function result
* @throws T Thrown when the function fails.
*/
int applyAsInt(long value) throws T;
}
/**
* A functional interface like {@link ObjDoubleConsumer} that declares a {@code Throwable}.
*
* @param <O> the type of the object argument to the operation.
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableObjDoubleConsumer<O, T extends Throwable> {
/**
* Accepts the consumer.
*
* @param object the object parameter for the consumable to accept.
* @param value the double parameter for the consumable to accept.
* @throws T Thrown when the consumer fails.
*/
void accept(O object, double value) throws T;
}
/**
* A functional interface like {@link ObjIntConsumer} that declares a {@code Throwable}.
*
* @param <O> the type of the object argument to the operation.
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableObjIntConsumer<O, T extends Throwable> {
/**
* Accepts the consumer.
*
* @param object the object parameter for the consumable to accept.
* @param value the int parameter for the consumable to accept.
* @throws T Thrown when the consumer fails.
*/
void accept(O object, int value) throws T;
}
/**
* A functional interface like {@link ObjLongConsumer} that declares a {@code Throwable}.
*
* @param <O> the type of the object argument to the operation.
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableObjLongConsumer<O, T extends Throwable> {
/**
* Accepts the consumer.
*
* @param object the object parameter for the consumable to accept.
* @param value the long parameter for the consumable to accept.
* @throws T Thrown when the consumer fails.
*/
void accept(O object, long value) throws T;
}
/**
* A functional interface like {@link Predicate} that declares a {@code Throwable}.
*
* <p>TODO for 4.0: Move to org.apache.commons.lang3.function.</p>
*
* @param <I> Predicate type 1.
* @param <T> Thrown exception.
*/
@ -714,6 +231,8 @@ public interface FailablePredicate<I, T extends Throwable> {
/**
* A functional interface like {@link Runnable} that declares a {@code Throwable}.
*
* <p>TODO for 4.0: Move to org.apache.commons.lang3.function.</p>
*
* @param <T> Thrown exception.
*/
@FunctionalInterface
@ -730,6 +249,8 @@ public interface FailableRunnable<T extends Throwable> {
/**
* A functional interface like {@link Supplier} that declares a {@code Throwable}.
*
* <p>TODO for 4.0: Move to org.apache.commons.lang3.function.</p>
*
* @param <R> Return type.
* @param <T> Thrown exception.
*/
@ -745,132 +266,6 @@ public interface FailableSupplier<R, T extends Throwable> {
R get() throws T;
}
/**
* A functional interface like {@link ToDoubleBiFunction} that declares a {@code Throwable}.
*
* @param <O1> the type of the first argument to the function
* @param <O2> the type of the second argument to the function
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableToDoubleBiFunction<O1, O2, T extends Throwable> {
/**
* Applies this function to the given arguments.
*
* @param t the first function argument
* @param u the second function argument
* @return the function result
* @throws T Thrown when the function fails.
*/
double applyAsDouble(O1 t, O2 u) throws T;
}
/**
* A functional interface like {@link ToDoubleFunction} that declares a {@code Throwable}.
*
* @param <I> the type of the first argument to the function
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableToDoubleFunction<I, T extends Throwable> {
/**
* Applies this function to the given arguments.
*
* @param t the first function argument
* @return the function result
* @throws T Thrown when the function fails.
*/
double applyAsDouble(I t) throws T;
}
/**
* A functional interface like {@link ToIntBiFunction} that declares a {@code Throwable}.
*
* @param <O1> the type of the first argument to the function
* @param <O2> the type of the second argument to the function
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableToIntBiFunction<O1, O2, T extends Throwable> {
/**
* Applies this function to the given arguments.
*
* @param t the first function argument
* @param u the second function argument
* @return the function result
* @throws T Thrown when the function fails.
*/
int applyAsInt(O1 t, O2 u) throws T;
}
/**
* A functional interface like {@link ToIntFunction} that declares a {@code Throwable}.
*
* @param <I> the type of the first argument to the function
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableToIntFunction<I, T extends Throwable> {
/**
* Applies this function to the given arguments.
*
* @param t the first function argument
* @return the function result
* @throws T Thrown when the function fails.
*/
int applyAsInt(I t) throws T;
}
/**
* A functional interface like {@link ToLongBiFunction} that declares a {@code Throwable}.
*
* @param <O1> the type of the first argument to the function
* @param <O2> the type of the second argument to the function
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableToLongBiFunction<O1, O2, T extends Throwable> {
/**
* Applies this function to the given arguments.
*
* @param t the first function argument
* @param u the second function argument
* @return the function result
* @throws T Thrown when the function fails.
*/
long applyAsLong(O1 t, O2 u) throws T;
}
/**
* A functional interface like {@link ToLongFunction} that declares a {@code Throwable}.
*
* @param <I> the type of the first argument to the function
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableToLongFunction<I, T extends Throwable> {
/**
* Applies this function to the given arguments.
*
* @param t the first function argument
* @return the function result
* @throws T Thrown when the function fails.
*/
long applyAsLong(I t) throws T;
}
/**
* Consumes a consumer and rethrows any exception as a {@link RuntimeException}.
*

View File

@ -0,0 +1,38 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.function;
import java.util.function.BooleanSupplier;
/**
* A functional interface like {@link BooleanSupplier} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableBooleanSupplier<T extends Throwable> {
/**
* Supplies a boolean.
*
* @return a result
* @throws T if the supplier fails
*/
boolean getAsBoolean() throws T;
}

View File

@ -0,0 +1,40 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.function;
import java.util.function.DoubleBinaryOperator;
/**
* A functional interface like {@link DoubleBinaryOperator} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableDoubleBinaryOperator<T extends Throwable> {
/**
* Applies this operator to the given operands.
*
* @param left the first operand
* @param right the second operand
* @return the operator result
* @throws T if the operation fails
*/
double applyAsDouble(double left, double right) throws T;
}

View File

@ -0,0 +1,38 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.function;
import java.util.function.DoubleConsumer;
/**
* A functional interface like {@link DoubleConsumer} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableDoubleConsumer<T extends Throwable> {
/**
* Accepts the consumer.
*
* @param value the parameter for the consumable to accept
* @throws T Thrown when the consumer fails.
*/
void accept(double value) throws T;
}

View File

@ -0,0 +1,40 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.function;
import java.util.function.DoubleFunction;
/**
* A functional interface like {@link DoubleFunction} that declares a {@code Throwable}.
*
* @param <R> Return type.
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableDoubleFunction<R, T extends Throwable> {
/**
* Applies this function.
*
* @param input the input for the function
* @return the result of the function
* @throws T Thrown when the function fails.
*/
R apply(double input) throws T;
}

View File

@ -0,0 +1,39 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.function;
import java.util.function.DoublePredicate;
/**
* A functional interface like {@link DoublePredicate} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableDoublePredicate<T extends Throwable> {
/**
* Tests the predicate.
*
* @param value the parameter for the predicate to accept.
* @return {@code true} if the input argument matches the predicate, {@code false} otherwise.
* @throws T Thrown when the consumer fails.
*/
boolean test(double value) throws T;
}

View File

@ -0,0 +1,38 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.function;
import java.util.function.DoubleSupplier;
/**
* A functional interface like {@link DoubleSupplier} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableDoubleSupplier<T extends Throwable> {
/**
* Supplies a double.
*
* @return a result
* @throws T if the supplier fails
*/
double getAsDouble() throws T;
}

View File

@ -0,0 +1,39 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.function;
import java.util.function.DoubleToIntFunction;
/**
* A functional interface like {@link DoubleToIntFunction} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableDoubleToIntFunction<T extends Throwable> {
/**
* Applies this function to the given argument.
*
* @param value the function argument
* @return the function result
* @throws T Thrown when the function fails.
*/
int applyAsInt(double value) throws T;
}

View File

@ -0,0 +1,39 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.function;
import java.util.function.DoubleToLongFunction;
/**
* A functional interface like {@link DoubleToLongFunction} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableDoubleToLongFunction<T extends Throwable> {
/**
* Applies this function to the given argument.
*
* @param value the function argument
* @return the function result
* @throws T if the operation fails
*/
int applyAsLong(double value) throws T;
}

View File

@ -0,0 +1,40 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.function;
import java.util.function.IntBinaryOperator;
/**
* A functional interface like {@link IntBinaryOperator} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableIntBinaryOperator<T extends Throwable> {
/**
* Applies this operator to the given operands.
*
* @param left the first operand
* @param right the second operand
* @return the operator result
* @throws T if the operation fails
*/
int applyAsInt(int left, int right) throws T;
}

View File

@ -0,0 +1,38 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.function;
import java.util.function.IntConsumer;
/**
* A functional interface like {@link IntConsumer} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableIntConsumer<T extends Throwable> {
/**
* Accepts the consumer.
*
* @param value the parameter for the consumable to accept
* @throws T Thrown when the consumer fails.
*/
void accept(int value) throws T;
}

View File

@ -0,0 +1,40 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.function;
import java.util.function.IntFunction;
/**
* A functional interface like {@link IntFunction} that declares a {@code Throwable}.
*
* @param <R> Return type.
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableIntFunction<R, T extends Throwable> {
/**
* Applies this function.
*
* @param input the input for the function
* @return the result of the function
* @throws T Thrown when the function fails.
*/
R apply(int input) throws T;
}

View File

@ -0,0 +1,39 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.function;
import java.util.function.IntPredicate;
/**
* A functional interface like {@link IntPredicate} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableIntPredicate<T extends Throwable> {
/**
* Tests the predicate.
*
* @param value the parameter for the predicate to accept.
* @return {@code true} if the input argument matches the predicate, {@code false} otherwise.
* @throws T Thrown when the consumer fails.
*/
boolean test(int value) throws T;
}

View File

@ -0,0 +1,38 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.function;
import java.util.function.IntSupplier;
/**
* A functional interface like {@link IntSupplier} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableIntSupplier<T extends Throwable> {
/**
* Supplies an int.
*
* @return a result
* @throws T if the supplier fails
*/
int getAsInt() throws T;
}

View File

@ -0,0 +1,39 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.function;
import java.util.function.IntToDoubleFunction;
/**
* A functional interface like {@link IntToDoubleFunction} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableIntToDoubleFunction<T extends Throwable> {
/**
* Applies this function to the given argument.
*
* @param value the function argument
* @return the function result
* @throws T Thrown when the function fails.
*/
double applyAsDouble(int value) throws T;
}

View File

@ -0,0 +1,39 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.function;
import java.util.function.IntToLongFunction;
/**
* A functional interface like {@link IntToLongFunction} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableIntToLongFunction<T extends Throwable> {
/**
* Applies this function to the given argument.
*
* @param value the function argument
* @return the function result
* @throws T Thrown when the function fails.
*/
long applyAsLong(int value) throws T;
}

View File

@ -0,0 +1,40 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.function;
import java.util.function.LongBinaryOperator;
/**
* A functional interface like {@link LongBinaryOperator} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableLongBinaryOperator<T extends Throwable> {
/**
* Applies this operator to the given operands.
*
* @param left the first operand
* @param right the second operand
* @return the operator result
* @throws T if the operation fails
*/
long applyAsLong(long left, long right) throws T;
}

View File

@ -0,0 +1,38 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.function;
import java.util.function.LongConsumer;
/**
* A functional interface like {@link LongConsumer} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableLongConsumer<T extends Throwable> {
/**
* Accepts the consumer.
*
* @param object the parameter for the consumable to accept
* @throws T Thrown when the consumer fails.
*/
void accept(long object) throws T;
}

View File

@ -0,0 +1,40 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.function;
import java.util.function.LongFunction;
/**
* A functional interface like {@link LongFunction} that declares a {@code Throwable}.
*
* @param <R> Return type.
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableLongFunction<R, T extends Throwable> {
/**
* Applies this function.
*
* @param input the input for the function
* @return the result of the function
* @throws T Thrown when the function fails.
*/
R apply(long input) throws T;
}

View File

@ -0,0 +1,39 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.function;
import java.util.function.LongPredicate;
/**
* A functional interface like {@link LongPredicate} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableLongPredicate<T extends Throwable> {
/**
* Tests the predicate.
*
* @param value the parameter for the predicate to accept.
* @return {@code true} if the input argument matches the predicate, {@code false} otherwise.
* @throws T Thrown when the consumer fails.
*/
boolean test(long value) throws T;
}

View File

@ -0,0 +1,38 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.function;
import java.util.function.LongSupplier;
/**
* A functional interface like {@link LongSupplier} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableLongSupplier<T extends Throwable> {
/**
* Supplies a long.
*
* @return a result
* @throws T if the supplier fails
*/
long getAsLong() throws T;
}

View File

@ -0,0 +1,39 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.function;
import java.util.function.LongToDoubleFunction;
/**
* A functional interface like {@link LongToDoubleFunction} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableLongToDoubleFunction<T extends Throwable> {
/**
* Applies this function to the given argument.
*
* @param value the function argument
* @return the function result
* @throws T Thrown when the function fails.
*/
double applyAsDouble(long value) throws T;
}

View File

@ -0,0 +1,39 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.function;
import java.util.function.LongToIntFunction;
/**
* A functional interface like {@link LongToIntFunction} that declares a {@code Throwable}.
*
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableLongToIntFunction<T extends Throwable> {
/**
* Applies this function to the given argument.
*
* @param value the function argument
* @return the function result
* @throws T Thrown when the function fails.
*/
int applyAsInt(long value) throws T;
}

View File

@ -0,0 +1,40 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.function;
import java.util.function.ObjDoubleConsumer;
/**
* A functional interface like {@link ObjDoubleConsumer} that declares a {@code Throwable}.
*
* @param <O> the type of the object argument to the operation.
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableObjDoubleConsumer<O, T extends Throwable> {
/**
* Accepts the consumer.
*
* @param object the object parameter for the consumable to accept.
* @param value the double parameter for the consumable to accept.
* @throws T Thrown when the consumer fails.
*/
void accept(O object, double value) throws T;
}

View File

@ -0,0 +1,40 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.function;
import java.util.function.ObjIntConsumer;
/**
* A functional interface like {@link ObjIntConsumer} that declares a {@code Throwable}.
*
* @param <O> the type of the object argument to the operation.
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableObjIntConsumer<O, T extends Throwable> {
/**
* Accepts the consumer.
*
* @param object the object parameter for the consumable to accept.
* @param value the int parameter for the consumable to accept.
* @throws T Thrown when the consumer fails.
*/
void accept(O object, int value) throws T;
}

View File

@ -0,0 +1,40 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.function;
import java.util.function.ObjLongConsumer;
/**
* A functional interface like {@link ObjLongConsumer} that declares a {@code Throwable}.
*
* @param <O> the type of the object argument to the operation.
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableObjLongConsumer<O, T extends Throwable> {
/**
* Accepts the consumer.
*
* @param object the object parameter for the consumable to accept.
* @param value the long parameter for the consumable to accept.
* @throws T Thrown when the consumer fails.
*/
void accept(O object, long value) throws T;
}

View File

@ -0,0 +1,42 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.function;
import java.util.function.ToDoubleBiFunction;
/**
* A functional interface like {@link ToDoubleBiFunction} that declares a {@code Throwable}.
*
* @param <O1> the type of the first argument to the function
* @param <O2> the type of the second argument to the function
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableToDoubleBiFunction<O1, O2, T extends Throwable> {
/**
* Applies this function to the given arguments.
*
* @param t the first function argument
* @param u the second function argument
* @return the function result
* @throws T Thrown when the function fails.
*/
double applyAsDouble(O1 t, O2 u) throws T;
}

View File

@ -0,0 +1,40 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.function;
import java.util.function.ToDoubleFunction;
/**
* A functional interface like {@link ToDoubleFunction} that declares a {@code Throwable}.
*
* @param <I> the type of the first argument to the function
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableToDoubleFunction<I, T extends Throwable> {
/**
* Applies this function to the given arguments.
*
* @param t the first function argument
* @return the function result
* @throws T Thrown when the function fails.
*/
double applyAsDouble(I t) throws T;
}

View File

@ -0,0 +1,42 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.function;
import java.util.function.ToIntBiFunction;
/**
* A functional interface like {@link ToIntBiFunction} that declares a {@code Throwable}.
*
* @param <O1> the type of the first argument to the function
* @param <O2> the type of the second argument to the function
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableToIntBiFunction<O1, O2, T extends Throwable> {
/**
* Applies this function to the given arguments.
*
* @param t the first function argument
* @param u the second function argument
* @return the function result
* @throws T Thrown when the function fails.
*/
int applyAsInt(O1 t, O2 u) throws T;
}

View File

@ -0,0 +1,40 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.function;
import java.util.function.ToIntFunction;
/**
* A functional interface like {@link ToIntFunction} that declares a {@code Throwable}.
*
* @param <I> the type of the first argument to the function
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableToIntFunction<I, T extends Throwable> {
/**
* Applies this function to the given arguments.
*
* @param t the first function argument
* @return the function result
* @throws T Thrown when the function fails.
*/
int applyAsInt(I t) throws T;
}

View File

@ -0,0 +1,42 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.function;
import java.util.function.ToLongBiFunction;
/**
* A functional interface like {@link ToLongBiFunction} that declares a {@code Throwable}.
*
* @param <O1> the type of the first argument to the function
* @param <O2> the type of the second argument to the function
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableToLongBiFunction<O1, O2, T extends Throwable> {
/**
* Applies this function to the given arguments.
*
* @param t the first function argument
* @param u the second function argument
* @return the function result
* @throws T Thrown when the function fails.
*/
long applyAsLong(O1 t, O2 u) throws T;
}

View File

@ -0,0 +1,40 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.commons.lang3.function;
import java.util.function.ToLongFunction;
/**
* A functional interface like {@link ToLongFunction} that declares a {@code Throwable}.
*
* @param <I> the type of the first argument to the function
* @param <T> Thrown exception.
* @since 3.11
*/
@FunctionalInterface
public interface FailableToLongFunction<I, T extends Throwable> {
/**
* Applies this function to the given arguments.
*
* @param t the first function argument
* @return the function result
* @throws T Thrown when the function fails.
*/
long applyAsLong(I t) throws T;
}

View File

@ -709,15 +709,6 @@ public void testConstructor() {
new Functions();
}
@Test
public void testDoublePredicate() throws Throwable {
FailureOnOddInvocations.invocations = 0;
final Functions.FailableDoublePredicate<Throwable> failablePredicate = t1 -> FailureOnOddInvocations
.testDouble(t1);
assertThrows(SomeException.class, () -> failablePredicate.test(1d));
failablePredicate.test(1d);
}
@Test
public void testFunction() {
final IllegalStateException ise = new IllegalStateException();
@ -880,24 +871,6 @@ public void testGetSupplier() {
assertEquals(0, i.intValue());
}
@Test
public void testIntPredicate() throws Throwable {
FailureOnOddInvocations.invocations = 0;
final Functions.FailableIntPredicate<Throwable> failablePredicate = t1 -> FailureOnOddInvocations
.testInt(t1);
assertThrows(SomeException.class, () -> failablePredicate.test(1));
failablePredicate.test(1);
}
@Test
public void testLongPredicate() throws Throwable {
FailureOnOddInvocations.invocations = 0;
final Functions.FailableLongPredicate<Throwable> failablePredicate = t1 -> FailureOnOddInvocations
.testLong(t1);
assertThrows(SomeException.class, () -> failablePredicate.test(1l));
failablePredicate.test(1l);
}
@Test
@DisplayName("Test that asPredicate(FailablePredicate) is converted to -> Predicate ")
public void testPredicate() {
@ -1020,36 +993,6 @@ public boolean test(String object1, String object2) throws IOException {
};
}
/**
* Tests that our failable interface is properly defined to throw any exception. using the top level generic types
* Object and Throwable.
*/
@Test
void testThrows_FailableBooleanSupplier_Object_Throwable() {
new Functions.FailableBooleanSupplier<Throwable>() {
@Override
public boolean getAsBoolean() throws Throwable {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception using String and IOExceptions as
* generic test types.
*/
@Test
void testThrows_FailableBooleanSupplier_String_IOException() {
new Functions.FailableBooleanSupplier<IOException>() {
@Override
public boolean getAsBoolean() throws IOException {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception. using the top level generic types
* Object and Throwable.
@ -1112,187 +1055,6 @@ public void accept(String object) throws IOException {
};
}
/**
* Tests that our failable interface is properly defined to throw any exception. using the top level generic types
* Object and Throwable.
*/
@Test
void testThrows_FailableDoubleBinaryOperator_Object_Throwable() {
new Functions.FailableDoubleBinaryOperator<Throwable>() {
@Override
public double applyAsDouble(double left, double right) throws Throwable {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception using String and IOExceptions as
* generic test types.
*/
@Test
void testThrows_FailableDoubleBinaryOperator_String_IOException() {
new Functions.FailableDoubleBinaryOperator<IOException>() {
@Override
public double applyAsDouble(double left, double right) throws IOException {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception. using the top level generic types
* Object and Throwable.
*/
@Test
void testThrows_FailableDoubleConsumer_Object_Throwable() {
new Functions.FailableDoubleConsumer<Throwable>() {
@Override
public void accept(double value) throws Throwable {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception using String and IOExceptions as
* generic test types.
*/
@Test
void testThrows_FailableDoubleConsumer_String_IOException() {
new Functions.FailableDoubleConsumer<IOException>() {
@Override
public void accept(double value) throws IOException {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception. using the top level generic types
* Object and Throwable.
*/
@Test
void testThrows_FailableDoubleFunction_Object_Throwable() {
new Functions.FailableDoubleFunction<Object, Throwable>() {
@Override
public Object apply(double input) throws Throwable {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception using String and IOExceptions as
* generic test types.
*/
@Test
void testThrows_FailableDoubleFunction_String_IOException() {
new Functions.FailableDoubleFunction<String, IOException>() {
@Override
public String apply(double input) throws IOException {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception. using the top level generic types
* Object and Throwable.
*/
@Test
void testThrows_FailableDoubleSupplier_Object_Throwable() {
new Functions.FailableDoubleSupplier<Throwable>() {
@Override
public double getAsDouble() throws Throwable {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception using String and IOExceptions as
* generic test types.
*/
@Test
void testThrows_FailableDoubleSupplier_String_IOException() {
new Functions.FailableDoubleSupplier<IOException>() {
@Override
public double getAsDouble() throws IOException {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception. using the top level generic types
* Object and Throwable.
*/
@Test
void testThrows_FailableDoubleToIntFunction_Object_Throwable() {
new Functions.FailableDoubleToIntFunction<Throwable>() {
@Override
public int applyAsInt(double value) throws Throwable {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception using String and IOExceptions as
* generic test types.
*/
@Test
void testThrows_FailableDoubleToIntFunction_String_IOException() {
new Functions.FailableDoubleToIntFunction<IOException>() {
@Override
public int applyAsInt(double value) throws IOException {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception. using the top level generic types
* Object and Throwable.
*/
@Test
void testThrows_FailableDoubleToLongFunction_Object_Throwable() {
new Functions.FailableDoubleToLongFunction<Throwable>() {
@Override
public int applyAsLong(double value) throws Throwable {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception using String and IOExceptions as
* generic test types.
*/
@Test
void testThrows_FailableDoubleToLongFunction_String_IOException() {
new Functions.FailableDoubleToLongFunction<IOException>() {
@Override
public int applyAsLong(double value) throws IOException {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception. using the top level generic types
* Object and Throwable.
@ -1323,462 +1085,6 @@ public String apply(String input) throws IOException {
};
}
/**
* Tests that our failable interface is properly defined to throw any exception. using the top level generic types
* Object and Throwable.
*/
@Test
void testThrows_FailableIntBinaryOperator_Object_Throwable() {
new Functions.FailableIntBinaryOperator<Throwable>() {
@Override
public int applyAsInt(int left, int right) throws Throwable {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception using String and IOExceptions as
* generic test types.
*/
@Test
void testThrows_FailableIntBinaryOperator_String_IOException() {
new Functions.FailableIntBinaryOperator<IOException>() {
@Override
public int applyAsInt(int left, int right) throws IOException {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception. using the top level generic types
* Object and Throwable.
*/
@Test
void testThrows_FailableIntConsumer_Object_Throwable() {
new Functions.FailableIntConsumer<Throwable>() {
@Override
public void accept(int value) throws Throwable {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception using String and IOExceptions as
* generic test types.
*/
@Test
void testThrows_FailableIntConsumer_String_IOException() {
new Functions.FailableIntConsumer<IOException>() {
@Override
public void accept(int value) throws IOException {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception. using the top level generic types
* Object and Throwable.
*/
@Test
void testThrows_FailableIntFunction_Object_Throwable() {
new Functions.FailableIntFunction<Object, Throwable>() {
@Override
public Object apply(int input) throws Throwable {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception using String and IOExceptions as
* generic test types.
*/
@Test
void testThrows_FailableIntFunction_String_IOException() {
new Functions.FailableIntFunction<String, IOException>() {
@Override
public String apply(int input) throws IOException {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception. using the top level generic types
* Object and Throwable.
*/
@Test
void testThrows_FailableIntSupplier_Object_Throwable() {
new Functions.FailableIntSupplier<Throwable>() {
@Override
public int getAsInt() throws Throwable {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception using String and IOExceptions as
* generic test types.
*/
@Test
void testThrows_FailableIntSupplier_String_IOException() {
new Functions.FailableIntSupplier<IOException>() {
@Override
public int getAsInt() throws IOException {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception. using the top level generic types
* Object and Throwable.
*/
@Test
void testThrows_FailableIntToDoubleFunction_Object_Throwable() {
new Functions.FailableIntToDoubleFunction<Throwable>() {
@Override
public double applyAsDouble(int value) throws Throwable {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception using String and IOExceptions as
* generic test types.
*/
@Test
void testThrows_FailableIntToDoubleFunction_String_IOException() {
new Functions.FailableIntToDoubleFunction<IOException>() {
@Override
public double applyAsDouble(int value) throws IOException {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception. using the top level generic types
* Object and Throwable.
*/
@Test
void testThrows_FailableIntToLongFunction_Object_Throwable() {
new Functions.FailableIntToLongFunction<Throwable>() {
@Override
public long applyAsLong(int value) throws Throwable {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception using String and IOExceptions as
* generic test types.
*/
@Test
void testThrows_FailableIntToLongFunction_String_IOException() {
new Functions.FailableIntToLongFunction<IOException>() {
@Override
public long applyAsLong(int value) throws IOException {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception. using the top level generic types
* Object and Throwable.
*/
@Test
void testThrows_FailableLongBinaryOperator_Object_Throwable() {
new Functions.FailableLongBinaryOperator<Throwable>() {
@Override
public long applyAsLong(long left, long right) throws Throwable {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception using String and IOExceptions as
* generic test types.
*/
@Test
void testThrows_FailableLongBinaryOperator_String_IOException() {
new Functions.FailableLongBinaryOperator<IOException>() {
@Override
public long applyAsLong(long left, long right) throws IOException {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception. using the top level generic types
* Object and Throwable.
*/
@Test
void testThrows_FailableLongConsumer_Object_Throwable() {
new Functions.FailableLongConsumer<Throwable>() {
@Override
public void accept(long object) throws Throwable {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception using String and IOExceptions as
* generic test types.
*/
@Test
void testThrows_FailableLongConsumer_String_IOException() {
new Functions.FailableLongConsumer<IOException>() {
@Override
public void accept(long object) throws IOException {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception. using the top level generic types
* Object and Throwable.
*/
@Test
void testThrows_FailableLongFunction_Object_Throwable() {
new Functions.FailableLongFunction<Object, Throwable>() {
@Override
public Object apply(long input) throws Throwable {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception using String and IOExceptions as
* generic test types.
*/
@Test
void testThrows_FailableLongFunction_String_IOException() {
new Functions.FailableLongFunction<String, IOException>() {
@Override
public String apply(long input) throws IOException {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception. using the top level generic types
* Object and Throwable.
*/
@Test
void testThrows_FailableLongSupplier_Object_Throwable() {
new Functions.FailableLongSupplier<Throwable>() {
@Override
public long getAsLong() throws Throwable {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception using String and IOExceptions as
* generic test types.
*/
@Test
void testThrows_FailableLongSupplier_String_IOException() {
new Functions.FailableLongSupplier<IOException>() {
@Override
public long getAsLong() throws IOException {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception. using the top level generic types
* Object and Throwable.
*/
@Test
void testThrows_FailableLongToDoubleFunction_Object_Throwable() {
new Functions.FailableLongToDoubleFunction<Throwable>() {
@Override
public double applyAsDouble(long value) throws Throwable {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception using String and IOExceptions as
* generic test types.
*/
@Test
void testThrows_FailableLongToDoubleFunction_String_IOException() {
new Functions.FailableLongToDoubleFunction<IOException>() {
@Override
public double applyAsDouble(long value) throws IOException {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception. using the top level generic types
* Object and Throwable.
*/
@Test
void testThrows_FailableLongToIntFunction_Object_Throwable() {
new Functions.FailableLongToIntFunction<Throwable>() {
@Override
public int applyAsInt(long value) throws Throwable {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception using String and IOExceptions as
* generic test types.
*/
@Test
void testThrows_FailableLongToIntFunction_String_IOException() {
new Functions.FailableLongToIntFunction<IOException>() {
@Override
public int applyAsInt(long value) throws IOException {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception. using the top level generic types
* Object and Throwable.
*/
@Test
void testThrows_FailableObjDoubleConsumer_Object_Throwable() {
new Functions.FailableObjDoubleConsumer<Object, Throwable>() {
@Override
public void accept(Object object, double value) throws Throwable {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception using String and IOExceptions as
* generic test types.
*/
@Test
void testThrows_FailableObjDoubleConsumer_String_IOException() {
new Functions.FailableObjDoubleConsumer<String, IOException>() {
@Override
public void accept(String object, double value) throws IOException {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception. using the top level generic types
* Object and Throwable.
*/
@Test
void testThrows_FailableObjIntConsumer_Object_Throwable() {
new Functions.FailableObjIntConsumer<Object, Throwable>() {
@Override
public void accept(Object object, int value) throws Throwable {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception using String and IOExceptions as
* generic test types.
*/
@Test
void testThrows_FailableObjIntConsumer_String_IOException() {
new Functions.FailableObjIntConsumer<String, IOException>() {
@Override
public void accept(String object, int value) throws IOException {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception. using the top level generic types
* Object and Throwable.
*/
@Test
void testThrows_FailableObjLongConsumer_Object_Throwable() {
new Functions.FailableObjLongConsumer<Object, Throwable>() {
@Override
public void accept(Object object, long value) throws Throwable {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception using String and IOExceptions as
* generic test types.
*/
@Test
void testThrows_FailableObjLongConsumer_String_IOException() {
new Functions.FailableObjLongConsumer<String, IOException>() {
@Override
public void accept(String object, long value) throws IOException {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception. using the top level generic types
* Object and Throwable.
@ -1870,186 +1176,6 @@ public String get() throws IOException {
};
}
/**
* Tests that our failable interface is properly defined to throw any exception. using the top level generic types
* Object and Throwable.
*/
@Test
void testThrows_FailableToDoubleBiFunction_Object_Throwable() {
new Functions.FailableToDoubleBiFunction<Object, Object, Throwable>() {
@Override
public double applyAsDouble(Object t, Object u) throws Throwable {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception using String and IOExceptions as
* generic test types.
*/
@Test
void testThrows_FailableToDoubleBiFunction_String_IOException() {
new Functions.FailableToDoubleBiFunction<String, String, IOException>() {
@Override
public double applyAsDouble(String t, String u) throws IOException {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception. using the top level generic types
* Object and Throwable.
*/
@Test
void testThrows_FailableToDoubleFunction_Object_Throwable() {
new Functions.FailableToDoubleFunction<Object, Throwable>() {
@Override
public double applyAsDouble(Object t) throws Throwable {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception using String and IOExceptions as
* generic test types.
*/
@Test
void testThrows_FailableToDoubleFunction_String_IOException() {
new Functions.FailableToDoubleFunction<String, IOException>() {
@Override
public double applyAsDouble(String t) throws IOException {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception. using the top level generic types
* Object and Throwable.
*/
@Test
void testThrows_FailableToIntBiFunction_Object_Throwable() {
new Functions.FailableToIntBiFunction<Object, Object, Throwable>() {
@Override
public int applyAsInt(Object t, Object u) throws Throwable {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception using String and IOExceptions as
* generic test types.
*/
@Test
void testThrows_FailableToIntBiFunction_String_IOException() {
new Functions.FailableToIntBiFunction<String, String, IOException>() {
@Override
public int applyAsInt(String t, String u) throws IOException {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception. using the top level generic types
* Object and Throwable.
*/
@Test
void testThrows_FailableToIntFunction_Object_Throwable() {
new Functions.FailableToIntFunction<Object, Throwable>() {
@Override
public int applyAsInt(Object t) throws Throwable {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception using String and IOExceptions as
* generic test types.
*/
@Test
void testThrows_FailableToIntFunction_String_IOException() {
new Functions.FailableToIntFunction<String, IOException>() {
@Override
public int applyAsInt(String t) throws IOException {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception. using the top level generic types
* Object and Throwable.
*/
@Test
void testThrows_FailableToLongBiFunction_Object_Throwable() {
new Functions.FailableToLongBiFunction<Object, Object, Throwable>() {
@Override
public long applyAsLong(Object t, Object u) throws Throwable {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception using String and IOExceptions as
* generic test types.
*/
@Test
void testThrows_FailableToLongBiFunction_String_IOException() {
new Functions.FailableToLongBiFunction<String, String, IOException>() {
@Override
public long applyAsLong(String t, String u) throws IOException {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception. using the top level generic types
* Object and Throwable.
*/
@Test
void testThrows_FailableToLongFunction_Object_Throwable() {
new Functions.FailableToLongFunction<Object, Throwable>() {
@Override
public long applyAsLong(Object t) throws Throwable {
throw new IOException("test");
}
};
}
/**
* Tests that our failable interface is properly defined to throw any exception using String and IOExceptions as
* generic test types.
*/
@Test
void testThrows_FailableToLongFunction_String_IOException() {
new Functions.FailableToLongFunction<String, IOException>() {
@Override
public long applyAsLong(String t) throws IOException {
throw new IOException("test");
}
};
}
@Test
public void testTryWithResources() {
final CloseableObject co = new CloseableObject();

File diff suppressed because it is too large Load Diff