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 6c01d24c Use IntUnaryOperator 6c01d24c is described below commit 6c01d24c99e16c2fa02faeca75dca632c2a1730c Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Mon Jul 10 14:54:28 2023 -0400 Use IntUnaryOperator --- src/changes/changes.xml | 3 -- .../commons/io/build/AbstractStreamBuilder.java | 9 ++-- .../commons/io/function/IntToIntFunction.java | 52 ---------------------- 3 files changed, 5 insertions(+), 59 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 4e713b8a..c38afdbf 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -107,9 +107,6 @@ The <action> type attribute can be add,update,fix,remove. <action dev="ggregory" type="add" due-to="Gary Gregory"> Add DeferredFileOutputStream.Builder.setDirectory(Path). </action> - <action dev="ggregory" type="add" due-to="Gary Gregory"> - Add IntToIntFunction. - </action> <action dev="ggregory" type="add" due-to="Gary Gregory"> Add AbstractStreamBuilder.setBufferSizeChecker(IntToIntFunction). </action> diff --git a/src/main/java/org/apache/commons/io/build/AbstractStreamBuilder.java b/src/main/java/org/apache/commons/io/build/AbstractStreamBuilder.java index d7c2fc3c..67dcec42 100644 --- a/src/main/java/org/apache/commons/io/build/AbstractStreamBuilder.java +++ b/src/main/java/org/apache/commons/io/build/AbstractStreamBuilder.java @@ -24,10 +24,11 @@ import java.io.Writer; import java.nio.charset.Charset; import java.nio.file.OpenOption; import java.nio.file.Path; +import java.util.function.IntUnaryOperator; + import org.apache.commons.io.Charsets; import org.apache.commons.io.IOUtils; import org.apache.commons.io.file.PathUtils; -import org.apache.commons.io.function.IntToIntFunction; /** * Abstracts building a typed instance of {@code T}. @@ -72,12 +73,12 @@ public abstract class AbstractStreamBuilder<T, B extends AbstractStreamBuilder<T /** * The default checking behavior for a buffer size request. Throws a {@link IllegalArgumentException} by default. */ - private final IntToIntFunction defaultSizeChecker = size -> size > bufferSizeMax ? throwIae(size, bufferSizeMax) : size; + private final IntUnaryOperator defaultSizeChecker = size -> size > bufferSizeMax ? throwIae(size, bufferSizeMax) : size; /** * The checking behavior for a buffer size request. */ - private IntToIntFunction bufferSizeChecker = defaultSizeChecker; + private IntUnaryOperator bufferSizeChecker = defaultSizeChecker; /** * Applies the buffer size request. @@ -233,7 +234,7 @@ public abstract class AbstractStreamBuilder<T, B extends AbstractStreamBuilder<T * @return this * @since 2.14.0 */ - public B setBufferSizeChecker(final IntToIntFunction bufferSizeChecker) { + public B setBufferSizeChecker(final IntUnaryOperator bufferSizeChecker) { this.bufferSizeChecker = bufferSizeChecker != null ? bufferSizeChecker : defaultSizeChecker; return asThis(); } diff --git a/src/main/java/org/apache/commons/io/function/IntToIntFunction.java b/src/main/java/org/apache/commons/io/function/IntToIntFunction.java deleted file mode 100644 index 57cea6c0..00000000 --- a/src/main/java/org/apache/commons/io/function/IntToIntFunction.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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; - -import java.util.function.Function; - -/** - * Represents a function that accepts an int-valued argument and produces an int-valued result. This is the {@code int}-to-{@code int} primitive - * specialization for {@link Function}. - * - * <p> - * This is a <a href="package-summary.html">functional interface</a> whose functional method is {@link #applyAsInt(int)}. - * </p> - * - * @see Function - * @since 2.14.0 - */ -@FunctionalInterface -public interface IntToIntFunction { - - /** - * Returns a function that always returns its input argument. - * - * @return a function that always returns its input argument - */ - static IntToIntFunction identity() { - return i -> i; - } - - /** - * Applies this function to the given argument. - * - * @param value the function argument - * @return the function result - */ - int applyAsInt(int value); -} \ No newline at end of file