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 2022/07/23 17:07:22 UTC
[commons-io] branch master updated: Reduce new public API footprint
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-io.git
The following commit(s) were added to refs/heads/master by this push:
new 3dfbff61 Reduce new public API footprint
3dfbff61 is described below
commit 3dfbff6100776d2ae352b6eb08160f557203f725
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Jul 23 13:07:16 2022 -0400
Reduce new public API footprint
Move new constants to a package private class
---
.../org/apache/commons/io/function/Constants.java | 47 ++++++++++++++++++++++
.../apache/commons/io/function/IOBiConsumer.java | 12 +-----
.../apache/commons/io/function/IOBiFunction.java | 10 +----
.../org/apache/commons/io/function/IOFunction.java | 2 +-
.../commons/io/function/IOBiConsumerTest.java | 1 -
.../commons/io/function/IOBiFunctionTest.java | 1 -
6 files changed, 52 insertions(+), 21 deletions(-)
diff --git a/src/main/java/org/apache/commons/io/function/Constants.java b/src/main/java/org/apache/commons/io/function/Constants.java
new file mode 100644
index 00000000..7d9ab52b
--- /dev/null
+++ b/src/main/java/org/apache/commons/io/function/Constants.java
@@ -0,0 +1,47 @@
+/*
+ * 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.io.function;
+
+/**
+ * Defines package-private constants.
+ */
+class Constants {
+
+ /**
+ * No-op singleton.
+ */
+ @SuppressWarnings("rawtypes")
+ static final IOBiConsumer IO_BI_CONSUMER = (t, u) -> {/* NOOP */};
+
+ /**
+ * No-op singleton.
+ */
+ @SuppressWarnings("rawtypes")
+ static final IOBiFunction IO_BI_FUNCTION = (t, u) -> null;
+
+ /**
+ * No-op singleton.
+ */
+ @SuppressWarnings("rawtypes")
+ static final IOFunction IO_FUNCTION_ID = t -> t;
+
+ private Constants() {
+ // We don't want instances
+ }
+
+}
diff --git a/src/main/java/org/apache/commons/io/function/IOBiConsumer.java b/src/main/java/org/apache/commons/io/function/IOBiConsumer.java
index a87f6624..86cefc24 100644
--- a/src/main/java/org/apache/commons/io/function/IOBiConsumer.java
+++ b/src/main/java/org/apache/commons/io/function/IOBiConsumer.java
@@ -34,14 +34,7 @@ import java.util.function.BiConsumer;
public interface IOBiConsumer<T, U> {
/**
- * NOOP singleton.
- * @since 2.12.0
- */
- @SuppressWarnings("rawtypes")
- IOBiConsumer NOOP = (t, u) -> {/* NOOP */};
-
- /**
- * Returns The NOOP singleton.
+ * Returns The no-op singleton.
*
* @param <T> the type of the first argument to the operation
* @param <U> the type of the second argument to the operation
@@ -49,7 +42,7 @@ public interface IOBiConsumer<T, U> {
* @since 2.12.0
*/
static <T, U> IOBiConsumer<T, U> noop() {
- return NOOP;
+ return Constants.IO_BI_CONSUMER;
}
/**
@@ -73,7 +66,6 @@ public interface IOBiConsumer<T, U> {
*/
default IOBiConsumer<T, U> andThen(final IOBiConsumer<? super T, ? super U> after) {
Objects.requireNonNull(after);
-
return (l, r) -> {
accept(l, r);
after.accept(l, r);
diff --git a/src/main/java/org/apache/commons/io/function/IOBiFunction.java b/src/main/java/org/apache/commons/io/function/IOBiFunction.java
index 85126c49..ed6427da 100644
--- a/src/main/java/org/apache/commons/io/function/IOBiFunction.java
+++ b/src/main/java/org/apache/commons/io/function/IOBiFunction.java
@@ -40,13 +40,7 @@ import java.util.function.Function;
public interface IOBiFunction<T, U, R> {
/**
- * NOOP singleton.
- */
- @SuppressWarnings("rawtypes")
- IOBiFunction NOOP = (t, u) -> null;
-
- /**
- * Returns The NOOP singleton.
+ * Returns The p singleton.
*
* @param <T> the type of the first argument to the function
* @param <U> the type of the second argument to the function
@@ -54,7 +48,7 @@ public interface IOBiFunction<T, U, R> {
* @return The NOOP singleton.
*/
static <T, U, R> IOBiFunction<T, U, R> noop() {
- return NOOP;
+ return Constants.IO_BI_FUNCTION;
}
/**
diff --git a/src/main/java/org/apache/commons/io/function/IOFunction.java b/src/main/java/org/apache/commons/io/function/IOFunction.java
index f5c3406c..3a277ebf 100644
--- a/src/main/java/org/apache/commons/io/function/IOFunction.java
+++ b/src/main/java/org/apache/commons/io/function/IOFunction.java
@@ -40,7 +40,7 @@ public interface IOFunction<T, R> {
* @return a function that always returns its input argument
*/
static <T> IOFunction<T, T> identity() {
- return t -> t;
+ return Constants.IO_FUNCTION_ID;
}
/**
diff --git a/src/test/java/org/apache/commons/io/function/IOBiConsumerTest.java b/src/test/java/org/apache/commons/io/function/IOBiConsumerTest.java
index 9c730cda..2d7d9700 100644
--- a/src/test/java/org/apache/commons/io/function/IOBiConsumerTest.java
+++ b/src/test/java/org/apache/commons/io/function/IOBiConsumerTest.java
@@ -49,7 +49,6 @@ public class IOBiConsumerTest {
@Test
public void testNoopIOConsumer() throws IOException {
IOBiConsumer.noop().accept(null, null);
- IOBiConsumer.NOOP.accept(null, null);
}
}
diff --git a/src/test/java/org/apache/commons/io/function/IOBiFunctionTest.java b/src/test/java/org/apache/commons/io/function/IOBiFunctionTest.java
index 7315e799..69f3628e 100644
--- a/src/test/java/org/apache/commons/io/function/IOBiFunctionTest.java
+++ b/src/test/java/org/apache/commons/io/function/IOBiFunctionTest.java
@@ -93,7 +93,6 @@ public class IOBiFunctionTest {
@Test
public void testNoopIOConsumer() throws IOException {
assertNull(IOBiFunction.noop().apply(null, null));
- assertNull(IOBiFunction.NOOP.apply(null, null));
}
}