You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2020/06/24 17:00:29 UTC

[commons-lang] branch master updated: Use the same generic parameter names as the JRE.

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git


The following commit(s) were added to refs/heads/master by this push:
     new 4cf5048  Use the same generic parameter names as the JRE.
4cf5048 is described below

commit 4cf50486a3b50d632686039a1701e3584fe19377
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jun 24 13:00:21 2020 -0400

    Use the same generic parameter names as the JRE.
---
 .../apache/commons/lang3/function/Failable.java    | 150 ++++++++++-----------
 1 file changed, 75 insertions(+), 75 deletions(-)

diff --git a/src/main/java/org/apache/commons/lang3/function/Failable.java b/src/main/java/org/apache/commons/lang3/function/Failable.java
index d33e9ee..7ff69bd 100644
--- a/src/main/java/org/apache/commons/lang3/function/Failable.java
+++ b/src/main/java/org/apache/commons/lang3/function/Failable.java
@@ -76,12 +76,12 @@ public class Failable {
      * @param consumer the consumer to consume
      * @param object1 the first object to consume by {@code consumer}
      * @param object2 the second object to consume by {@code consumer}
-     * @param <O1> the type of the first argument the consumer accepts
-     * @param <O2> the type of the second argument the consumer accepts
-     * @param <T> the type of checked exception the consumer may throw
+     * @param <T> the type of the first argument the consumer accepts
+     * @param <U> the type of the second argument the consumer accepts
+     * @param <E> the type of checked exception the consumer may throw
      */
-    public static <O1, O2, T extends Throwable> void accept(final FailableBiConsumer<O1, O2, T> consumer,
-        final O1 object1, final O2 object2) {
+    public static <T, U, E extends Throwable> void accept(final FailableBiConsumer<T, U, E> consumer,
+        final T object1, final U object2) {
         run(() -> consumer.accept(object1, object2));
     }
 
@@ -90,10 +90,10 @@ public class Failable {
      *
      * @param consumer the consumer to consume
      * @param object the object to consume by {@code consumer}
-     * @param <O> the type the consumer accepts
-     * @param <T> the type of checked exception the consumer may throw
+     * @param <T> the type the consumer accepts
+     * @param <E> the type of checked exception the consumer may throw
      */
-    public static <O, T extends Throwable> void accept(final FailableConsumer<O, T> consumer, final O object) {
+    public static <T, E extends Throwable> void accept(final FailableConsumer<T, E> consumer, final T object) {
         run(() -> consumer.accept(object));
     }
 
@@ -102,9 +102,9 @@ public class Failable {
      *
      * @param consumer the consumer to consume
      * @param value the value to consume by {@code consumer}
-     * @param <T> the type of checked exception the consumer may throw
+     * @param <E> the type of checked exception the consumer may throw
      */
-    public static <T extends Throwable> void accept(final FailableDoubleConsumer<T> consumer, final double value) {
+    public static <E extends Throwable> void accept(final FailableDoubleConsumer<E> consumer, final double value) {
         run(() -> consumer.accept(value));
     }
 
@@ -113,9 +113,9 @@ public class Failable {
      *
      * @param consumer the consumer to consume
      * @param value the value to consume by {@code consumer}
-     * @param <T> the type of checked exception the consumer may throw
+     * @param <E> the type of checked exception the consumer may throw
      */
-    public static <T extends Throwable> void accept(final FailableIntConsumer<T> consumer, final int value) {
+    public static <E extends Throwable> void accept(final FailableIntConsumer<E> consumer, final int value) {
         run(() -> consumer.accept(value));
     }
 
@@ -124,9 +124,9 @@ public class Failable {
      *
      * @param consumer the consumer to consume
      * @param value the value to consume by {@code consumer}
-     * @param <T> the type of checked exception the consumer may throw
+     * @param <E> the type of checked exception the consumer may throw
      */
-    public static <T extends Throwable> void accept(final FailableLongConsumer<T> consumer, final long value) {
+    public static <E extends Throwable> void accept(final FailableLongConsumer<E> consumer, final long value) {
         run(() -> consumer.accept(value));
     }
 
@@ -136,14 +136,14 @@ public class Failable {
      * @param function the function to apply
      * @param input1 the first input to apply {@code function} on
      * @param input2 the second input to apply {@code function} on
-     * @param <O1> the type of the first argument the function accepts
-     * @param <O2> the type of the second argument the function accepts
-     * @param <O> the return type of the function
-     * @param <T> the type of checked exception the function may throw
+     * @param <T> the type of the first argument the function accepts
+     * @param <U> the type of the second argument the function accepts
+     * @param <R> the return type of the function
+     * @param <E> the type of checked exception the function may throw
      * @return the value returned from the function
      */
-    public static <O1, O2, O, T extends Throwable> O apply(final FailableBiFunction<O1, O2, O, T> function,
-        final O1 input1, final O2 input2) {
+    public static <T, U, R, E extends Throwable> R apply(final FailableBiFunction<T, U, R, E> function,
+        final T input1, final U input2) {
         return get(() -> function.apply(input1, input2));
     }
 
@@ -152,12 +152,12 @@ public class Failable {
      *
      * @param function the function to apply
      * @param input the input to apply {@code function} on
-     * @param <I> the type of the argument the function accepts
-     * @param <O> the return type of the function
-     * @param <T> the type of checked exception the function may throw
+     * @param <T> the type of the argument the function accepts
+     * @param <R> the return type of the function
+     * @param <E> the type of checked exception the function may throw
      * @return the value returned from the function
      */
-    public static <I, O, T extends Throwable> O apply(final FailableFunction<I, O, T> function, final I input) {
+    public static <T, R, E extends Throwable> R apply(final FailableFunction<T, R, E> function, final T input) {
         return get(() -> function.apply(input));
     }
 
@@ -167,10 +167,10 @@ public class Failable {
      * @param function the function to apply
      * @param left the first input to apply {@code function} on
      * @param right the second input to apply {@code function} on
-     * @param <T> the type of checked exception the function may throw
+     * @param <E> the type of checked exception the function may throw
      * @return the value returned from the function
      */
-    public static <T extends Throwable> double applyAsDouble(final FailableDoubleBinaryOperator<T> function,
+    public static <E extends Throwable> double applyAsDouble(final FailableDoubleBinaryOperator<E> function,
         final double left, final double right) {
         return getAsDouble(() -> function.applyAsDouble(left, right));
     }
@@ -178,82 +178,82 @@ public class Failable {
     /**
      * Converts the given {@link FailableBiConsumer} into a standard {@link BiConsumer}.
      *
-     * @param <O1> the type of the first argument of the consumers
-     * @param <O2> the type of the second argument of the consumers
+     * @param <T> the type of the first argument of the consumers
+     * @param <U> the type of the second argument of the consumers
      * @param consumer a failable {@code BiConsumer}
      * @return a standard {@code BiConsumer}
      */
-    public static <O1, O2> BiConsumer<O1, O2> asBiConsumer(final FailableBiConsumer<O1, O2, ?> consumer) {
+    public static <T, U> BiConsumer<T, U> asBiConsumer(final FailableBiConsumer<T, U, ?> consumer) {
         return (input1, input2) -> accept(consumer, input1, input2);
     }
 
     /**
      * Converts the given {@link FailableBiFunction} into a standard {@link BiFunction}.
      *
-     * @param <O1> the type of the first argument of the input of the functions
-     * @param <O2> the type of the second argument of the input of the functions
-     * @param <O> the type of the output of the functions
+     * @param <T> the type of the first argument of the input of the functions
+     * @param <U> the type of the second argument of the input of the functions
+     * @param <R> the type of the output of the functions
      * @param function a {@code FailableBiFunction}
      * @return a standard {@code BiFunction}
      */
-    public static <O1, O2, O> BiFunction<O1, O2, O> asBiFunction(final FailableBiFunction<O1, O2, O, ?> function) {
+    public static <T, U, R> BiFunction<T, U, R> asBiFunction(final FailableBiFunction<T, U, R, ?> function) {
         return (input1, input2) -> apply(function, input1, input2);
     }
 
     /**
      * Converts the given {@link FailableBiPredicate} into a standard {@link BiPredicate}.
      *
-     * @param <O1> the type of the first argument used by the predicates
-     * @param <O2> the type of the second argument used by the predicates
+     * @param <T> the type of the first argument used by the predicates
+     * @param <U> the type of the second argument used by the predicates
      * @param predicate a {@code FailableBiPredicate}
      * @return a standard {@code BiPredicate}
      */
-    public static <O1, O2> BiPredicate<O1, O2> asBiPredicate(final FailableBiPredicate<O1, O2, ?> predicate) {
+    public static <T, U> BiPredicate<T, U> asBiPredicate(final FailableBiPredicate<T, U, ?> predicate) {
         return (input1, input2) -> test(predicate, input1, input2);
     }
 
     /**
      * Converts the given {@link FailableCallable} into a standard {@link Callable}.
      *
-     * @param <O> the type used by the callables
+     * @param <V> the type used by the callables
      * @param callable a {@code FailableCallable}
      * @return a standard {@code Callable}
      */
-    public static <O> Callable<O> asCallable(final FailableCallable<O, ?> callable) {
+    public static <V> Callable<V> asCallable(final FailableCallable<V, ?> callable) {
         return () -> call(callable);
     }
 
     /**
      * Converts the given {@link FailableConsumer} into a standard {@link Consumer}.
      *
-     * @param <I> the type used by the consumers
+     * @param <T> the type used by the consumers
      * @param consumer a {@code FailableConsumer}
      * @return a standard {@code Consumer}
      */
-    public static <I> Consumer<I> asConsumer(final FailableConsumer<I, ?> consumer) {
+    public static <T> Consumer<T> asConsumer(final FailableConsumer<T, ?> consumer) {
         return input -> accept(consumer, input);
     }
 
     /**
      * Converts the given {@link FailableFunction} into a standard {@link Function}.
      *
-     * @param <I> the type of the input of the functions
-     * @param <O> the type of the output of the functions
+     * @param <T> the type of the input of the functions
+     * @param <R> the type of the output of the functions
      * @param function a {code FailableFunction}
      * @return a standard {@code Function}
      */
-    public static <I, O> Function<I, O> asFunction(final FailableFunction<I, O, ?> function) {
+    public static <T, R> Function<T, R> asFunction(final FailableFunction<T, R, ?> function) {
         return input -> apply(function, input);
     }
 
     /**
      * Converts the given {@link FailablePredicate} into a standard {@link Predicate}.
      *
-     * @param <I> the type used by the predicates
+     * @param <T> the type used by the predicates
      * @param predicate a {@code FailablePredicate}
      * @return a standard {@code Predicate}
      */
-    public static <I> Predicate<I> asPredicate(final FailablePredicate<I, ?> predicate) {
+    public static <T> Predicate<T> asPredicate(final FailablePredicate<T, ?> predicate) {
         return input -> test(predicate, input);
     }
 
@@ -270,11 +270,11 @@ public class Failable {
     /**
      * Converts the given {@link FailableSupplier} into a standard {@link Supplier}.
      *
-     * @param <O> the type supplied by the suppliers
+     * @param <T> the type supplied by the suppliers
      * @param supplier a {@code FailableSupplier}
      * @return a standard {@code Supplier}
      */
-    public static <O> Supplier<O> asSupplier(final FailableSupplier<O, ?> supplier) {
+    public static <T> Supplier<T> asSupplier(final FailableSupplier<T, ?> supplier) {
         return () -> get(supplier);
     }
 
@@ -282,11 +282,11 @@ public class Failable {
      * Calls a callable and rethrows any exception as a {@link RuntimeException}.
      *
      * @param callable the callable to call
-     * @param <O> the return type of the callable
-     * @param <T> the type of checked exception the callable may throw
+     * @param <V> the return type of the callable
+     * @param <E> the type of checked exception the callable may throw
      * @return the value returned from the callable
      */
-    public static <O, T extends Throwable> O call(final FailableCallable<O, T> callable) {
+    public static <V, E extends Throwable> V call(final FailableCallable<V, E> callable) {
         return get(callable::call);
     }
 
@@ -294,11 +294,11 @@ public class Failable {
      * Invokes a supplier, and returns the result.
      *
      * @param supplier The supplier to invoke.
-     * @param <O> The suppliers output type.
-     * @param <T> The type of checked exception, which the supplier can throw.
+     * @param <T> The suppliers output type.
+     * @param <E> The type of checked exception, which the supplier can throw.
      * @return The object, which has been created by the supplier
      */
-    public static <O, T extends Throwable> O get(final FailableSupplier<O, T> supplier) {
+    public static <T, E extends Throwable> T get(final FailableSupplier<T, E> supplier) {
         try {
             return supplier.get();
         } catch (final Throwable t) {
@@ -310,10 +310,10 @@ public class Failable {
      * Invokes a boolean supplier, and returns the result.
      *
      * @param supplier The boolean supplier to invoke.
-     * @param <T> The type of checked exception, which the supplier can throw.
+     * @param <E> The type of checked exception, which the supplier can throw.
      * @return The boolean, which has been created by the supplier
      */
-    public static <T extends Throwable> boolean getAsBoolean(final FailableBooleanSupplier<T> supplier) {
+    public static <E extends Throwable> boolean getAsBoolean(final FailableBooleanSupplier<E> supplier) {
         try {
             return supplier.getAsBoolean();
         } catch (final Throwable t) {
@@ -325,10 +325,10 @@ public class Failable {
      * Invokes a double supplier, and returns the result.
      *
      * @param supplier The double supplier to invoke.
-     * @param <T> The type of checked exception, which the supplier can throw.
+     * @param <E> The type of checked exception, which the supplier can throw.
      * @return The boolean, which has been created by the supplier
      */
-    public static <T extends Throwable> double getAsDouble(final FailableDoubleSupplier<T> supplier) {
+    public static <E extends Throwable> double getAsDouble(final FailableDoubleSupplier<E> supplier) {
         try {
             return supplier.getAsDouble();
         } catch (final Throwable t) {
@@ -340,10 +340,10 @@ public class Failable {
      * Invokes an int supplier, and returns the result.
      *
      * @param supplier The int supplier to invoke.
-     * @param <T> The type of checked exception, which the supplier can throw.
+     * @param <E> The type of checked exception, which the supplier can throw.
      * @return The boolean, which has been created by the supplier
      */
-    public static <T extends Throwable> int getAsInt(final FailableIntSupplier<T> supplier) {
+    public static <E extends Throwable> int getAsInt(final FailableIntSupplier<E> supplier) {
         try {
             return supplier.getAsInt();
         } catch (final Throwable t) {
@@ -355,10 +355,10 @@ public class Failable {
      * Invokes a long supplier, and returns the result.
      *
      * @param supplier The long supplier to invoke.
-     * @param <T> The type of checked exception, which the supplier can throw.
+     * @param <E> The type of checked exception, which the supplier can throw.
      * @return The boolean, which has been created by the supplier
      */
-    public static <T extends Throwable> long getAsLong(final FailableLongSupplier<T> supplier) {
+    public static <E extends Throwable> long getAsLong(final FailableLongSupplier<E> supplier) {
         try {
             return supplier.getAsLong();
         } catch (final Throwable t) {
@@ -410,9 +410,9 @@ public class Failable {
      * Runs a runnable and rethrows any exception as a {@link RuntimeException}.
      *
      * @param runnable The runnable to run
-     * @param <T> the type of checked exception the runnable may throw
+     * @param <E> the type of checked exception the runnable may throw
      */
-    public static <T extends Throwable> void run(final FailableRunnable<T> runnable) {
+    public static <E extends Throwable> void run(final FailableRunnable<E> runnable) {
         try {
             runnable.run();
         } catch (final Throwable t) {
@@ -429,10 +429,10 @@ public class Failable {
      * </pre>
      *
      * @param collection The collection, which is being converted into a {@link FailableStream}.
-     * @param <O> The collections element type. (In turn, the result streams element type.)
+     * @param <E> The collections element type. (In turn, the result streams element type.)
      * @return The created {@link FailableStream}.
      */
-    public static <O> FailableStream<O> stream(final Collection<O> collection) {
+    public static <E> FailableStream<E> stream(final Collection<E> collection) {
         return new FailableStream<>(collection.stream());
     }
 
@@ -443,10 +443,10 @@ public class Failable {
      * {@link Function}, {@link Consumer}, etc.
      *
      * @param stream The stream, which is being converted into a {@link FailableStream}.
-     * @param <O> The streams element type.
+     * @param <T> The streams element type.
      * @return The created {@link FailableStream}.
      */
-    public static <O> FailableStream<O> stream(final Stream<O> stream) {
+    public static <T> FailableStream<T> stream(final Stream<T> stream) {
         return new FailableStream<>(stream);
     }
 
@@ -456,13 +456,13 @@ public class Failable {
      * @param predicate the predicate to test
      * @param object1 the first input to test by {@code predicate}
      * @param object2 the second input to test by {@code predicate}
-     * @param <O1> the type of the first argument the predicate tests
-     * @param <O2> the type of the second argument the predicate tests
-     * @param <T> the type of checked exception the predicate may throw
+     * @param <T> the type of the first argument the predicate tests
+     * @param <U> the type of the second argument the predicate tests
+     * @param <E> the type of checked exception the predicate may throw
      * @return the boolean value returned by the predicate
      */
-    public static <O1, O2, T extends Throwable> boolean test(final FailableBiPredicate<O1, O2, T> predicate,
-        final O1 object1, final O2 object2) {
+    public static <T, U, E extends Throwable> boolean test(final FailableBiPredicate<T, U, E> predicate,
+        final T object1, final U object2) {
         return getAsBoolean(() -> predicate.test(object1, object2));
     }
 
@@ -471,11 +471,11 @@ public class Failable {
      *
      * @param predicate the predicate to test
      * @param object the input to test by {@code predicate}
-     * @param <O> the type of argument the predicate tests
-     * @param <T> the type of checked exception the predicate may throw
+     * @param <T> the type of argument the predicate tests
+     * @param <E> the type of checked exception the predicate may throw
      * @return the boolean value returned by the predicate
      */
-    public static <O, T extends Throwable> boolean test(final FailablePredicate<O, T> predicate, final O object) {
+    public static <T, E extends Throwable> boolean test(final FailablePredicate<T, E> predicate, final T object) {
         return getAsBoolean(() -> predicate.test(object));
     }