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

commit 4c1cbdbb8002074959f3291371b34f4b0ce1f359
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Wed May 29 16:18:40 2024 -0400

    Flip args on new API
---
 src/main/java/org/apache/commons/lang3/function/Consumers.java    | 6 +++---
 src/main/java/org/apache/commons/lang3/function/Functions.java    | 6 +++---
 .../java/org/apache/commons/lang3/function/ConsumersTest.java     | 8 ++++----
 .../java/org/apache/commons/lang3/function/FunctionsTest.java     | 8 ++++----
 4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/main/java/org/apache/commons/lang3/function/Consumers.java 
b/src/main/java/org/apache/commons/lang3/function/Consumers.java
index 49b514ec1..0fa880c6b 100644
--- a/src/main/java/org/apache/commons/lang3/function/Consumers.java
+++ b/src/main/java/org/apache/commons/lang3/function/Consumers.java
@@ -34,13 +34,13 @@ public class Consumers {
     /**
      * Applies the given {@link Consumer} action to the object if the consumer 
is not {@code null}. Otherwise, does
      * nothing.
-     *
-     * @param object the object to be consumed.
      * @param consumer the consumer to consume.
+     * @param object the object to be consumed.
+     *
      * @param <T> the type of the argument the consumer accepts.
      * @since 3.15.0
      */
-    public static <T> void accept(final T object, final Consumer<T> consumer) {
+    public static <T> void accept(final Consumer<T> consumer, final T object) {
         if (consumer != null) {
             consumer.accept(object);
         }
diff --git a/src/main/java/org/apache/commons/lang3/function/Functions.java 
b/src/main/java/org/apache/commons/lang3/function/Functions.java
index 8d9313ca5..707fb93bf 100644
--- a/src/main/java/org/apache/commons/lang3/function/Functions.java
+++ b/src/main/java/org/apache/commons/lang3/function/Functions.java
@@ -29,15 +29,15 @@ public final class Functions {
     /**
      * Applies the {@link Function} on the object if the function is not 
{@code null}. Otherwise, does nothing and
      * returns {@code null}.
-     *
-     * @param object the object to apply the function.
      * @param function the function to apply.
+     * @param object the object to apply the function.
+     *
      * @param <T> the type of the argument the function applies.
      * @param <R> the type of the result the function returns.
      * @return the value the function returns if the function is not {@code 
null}; {@code null} otherwise.
      * @since 3.15.0
      */
-    public static <T, R> R apply(final T object, final Function<T, R> 
function) {
+    public static <T, R> R apply(final Function<T, R> function, final T 
object) {
         return function != null ? function.apply(object) : null;
     }
 
diff --git a/src/test/java/org/apache/commons/lang3/function/ConsumersTest.java 
b/src/test/java/org/apache/commons/lang3/function/ConsumersTest.java
index e649c25db..a4a4ab64e 100644
--- a/src/test/java/org/apache/commons/lang3/function/ConsumersTest.java
+++ b/src/test/java/org/apache/commons/lang3/function/ConsumersTest.java
@@ -41,20 +41,20 @@ public class ConsumersTest extends AbstractLangTest {
     }
 
     /**
-     * Tests {@link Consumers#accept(Object, Consumer)}.
+     * Tests {@link Consumers#accept(Consumer, Object)}.
      */
     @Test
     public void testAccept() {
         final StringBuilder builder = new StringBuilder("foo");
-        Consumers.accept(builder, sb -> sb.append("-bar"));
+        Consumers.accept(sb -> sb.append("-bar"), builder);
         assertEquals("foo-bar", builder.toString());
 
         final TestConsumer<String> consumer = new TestConsumer<>();
-        Consumers.accept(null, consumer);
+        Consumers.accept(consumer, null);
         assertTrue(consumer.isCalled);
 
         final StringBuilder builder2 = new StringBuilder("foo");
-        Consumers.accept(builder2, null);
+        Consumers.accept(null, builder2);
         assertEquals("foo", builder2.toString());
     }
 
diff --git a/src/test/java/org/apache/commons/lang3/function/FunctionsTest.java 
b/src/test/java/org/apache/commons/lang3/function/FunctionsTest.java
index 8f5825134..368fd00c7 100644
--- a/src/test/java/org/apache/commons/lang3/function/FunctionsTest.java
+++ b/src/test/java/org/apache/commons/lang3/function/FunctionsTest.java
@@ -30,13 +30,13 @@ import org.junit.jupiter.api.Test;
 public class FunctionsTest {
 
     /**
-     * Tests {@link Functions#apply(Object, Function)}.
+     * Tests {@link Functions#apply(Function, Object)}.
      */
     @Test
     public void testApply() {
-        assertEquals("foo-bar", Functions.apply("foo", string -> 
string.concat("-bar")));
-        assertEquals("foo-bar", Functions.apply(null, object -> "foo-bar"));
-        assertNull(Functions.apply("foo", null));
+        assertEquals("foo-bar", Functions.apply(string -> 
string.concat("-bar"), "foo"));
+        assertEquals("foo-bar", Functions.apply(object -> "foo-bar", null));
+        assertNull(Functions.apply(null, "foo"));
     }
 
     /**

Reply via email to