Reduce new public API footprint
Move new constants to a package private class
ADD
src/main/java/org/apache/commons/io/function/Constants.java
+/*
+ * 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
+ }
+
+}

MODIFY
src/main/java/org/apache/commons/io/function/IOBiConsumer.java
src/main/java/org/apache/commons/io/function/IOBiConsumer.java
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
* @since 2.12.0
*/
static <T, U> IOBiConsumer<T, U> noop() {
- return NOOP;
+ return Constants.IO_BI_CONSUMER;
}
/**
*/
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);

MODIFY
src/main/java/org/apache/commons/io/function/IOBiFunction.java
src/main/java/org/apache/commons/io/function/IOBiFunction.java
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
* @return The NOOP singleton.
*/
static <T, U, R> IOBiFunction<T, U, R> noop() {
- return NOOP;
+ return Constants.IO_BI_FUNCTION;
}
/**

MODIFY
src/main/java/org/apache/commons/io/function/IOFunction.java
src/main/java/org/apache/commons/io/function/IOFunction.java
* @return a function that always returns its input argument
*/
static <T> IOFunction<T, T> identity() {
- return t -> t;
+ return Constants.IO_FUNCTION_ID;
}
/**

MODIFY
src/test/java/org/apache/commons/io/function/IOBiConsumerTest.java
src/test/java/org/apache/commons/io/function/IOBiConsumerTest.java
@@ -49,7 +49,6 @@ public void testAndThen() throws IOException {
@Test
public void testNoopIOConsumer() throws IOException {
IOBiConsumer.noop().accept(null, null);
- IOBiConsumer.NOOP.accept(null, null);
}
}

MODIFY
src/test/java/org/apache/commons/io/function/IOBiFunctionTest.java
src/test/java/org/apache/commons/io/function/IOBiFunctionTest.java
@@ -93,7 +93,6 @@ public void testApplyThrowsException() {
@Test
public void testNoopIOConsumer() throws IOException {
assertNull(IOBiFunction.noop().apply(null, null));
- assertNull(IOBiFunction.NOOP.apply(null, null));
}
}

Reduce new public API footprint

Move new constants to a package private class