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 2023/07/10 11:56:24 UTC
[commons-lang] branch master updated (4e2782dde -> 120d3489a)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
from 4e2782dde Bump github/codeql-action from 2.20.1 to 2.20.3 (#1080)
new accde3be2 Javdoc
new 120d3489a Add IntToIntFunction
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
src/changes/changes.xml | 1 +
.../commons/lang3/function/IntToCharFunction.java | 7 +++----
...ntToCharFunction.java => IntToIntFunction.java} | 24 ++++++++++++++--------
...FunctionTest.java => IntToIntFunctionTest.java} | 15 +++++++++-----
4 files changed, 30 insertions(+), 17 deletions(-)
copy src/main/java/org/apache/commons/lang3/function/{IntToCharFunction.java => IntToIntFunction.java} (68%)
copy src/test/java/org/apache/commons/lang3/function/{IntToCharFunctionTest.java => IntToIntFunctionTest.java} (74%)
Re: [commons-lang] 02/02: Add IntToIntFunction
Posted by Gary Gregory <ga...@gmail.com>.
You're right! Thank you. I'll clean it up.
Gary
On Mon, Jul 10, 2023, 09:18 Alex Herbert <al...@gmail.com> wrote:
> Is this not the same as:
>
> java.util.function.IntUnaryOperator
>
> On Mon, 10 Jul 2023 at 12:56, <gg...@apache.org> wrote:
> >
> > 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 120d3489aad924e310a8071a66139947ace7a685
> > Author: Gary Gregory <ga...@gmail.com>
> > AuthorDate: Mon Jul 10 07:56:18 2023 -0400
> >
> > Add IntToIntFunction
> > ---
> > src/changes/changes.xml | 1 +
> > .../commons/lang3/function/IntToIntFunction.java | 52
> ++++++++++++++++++++++
> > .../lang3/function/IntToIntFunctionTest.java | 40
> +++++++++++++++++
> > 3 files changed, 93 insertions(+)
> >
> > diff --git a/src/changes/changes.xml b/src/changes/changes.xml
> > index b9930b0d2..a9d493949 100644
> > --- a/src/changes/changes.xml
> > +++ b/src/changes/changes.xml
> > @@ -216,6 +216,7 @@ The <action> type attribute can be
> add,update,fix,remove.
> > <action issue="LANG-1647" type="add" dev="ggregory" due-to="Arturo
> Bernal, Dimitrios Efthymiou, Gary Gregory">Add and
> ExceptionUtils.isChecked() and isUnchecked() #1069</action>
> > <action type="add" dev="ggregory" due-to="Gary
> Gregory">Add and use ExceptionUtils.throwUnchecked(throwable).</action>
> > <action type="add" dev="ggregory" due-to="Gary
> Gregory">Add LockingVisitors.create(O, ReadWriteLock).</action>
> > + <action type="add" dev="ggregory" due-to="Gary
> Gregory">Add IntToIntFunction.</action>
> > <!-- UPDATE -->
> > <action type="update" dev="ggregory"
> due-to="Dependabot, XenoAmess, Gary Gregory">Bump actions/cache from 2.1.4
> to 3.0.10 #742, #752, #764, #833, #867, #959, #964.</action>
> > <action type="update" dev="ggregory"
> due-to="Dependabot, Gary Gregory">Bump actions/checkout from 2 to 3.1.0
> #819, #825, #859, #963.</action>
> > diff --git
> a/src/main/java/org/apache/commons/lang3/function/IntToIntFunction.java
> b/src/main/java/org/apache/commons/lang3/function/IntToIntFunction.java
> > new file mode 100644
> > index 000000000..45f309743
> > --- /dev/null
> > +++
> b/src/main/java/org/apache/commons/lang3/function/IntToIntFunction.java
> > @@ -0,0 +1,52 @@
> > +/*
> > + * 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.lang3.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 3.13.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);
> > +}
> > diff --git
> a/src/test/java/org/apache/commons/lang3/function/IntToIntFunctionTest.java
> b/src/test/java/org/apache/commons/lang3/function/IntToIntFunctionTest.java
> > new file mode 100644
> > index 000000000..d8d11ae07
> > --- /dev/null
> > +++
> b/src/test/java/org/apache/commons/lang3/function/IntToIntFunctionTest.java
> > @@ -0,0 +1,40 @@
> > +/*
> > + * 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.lang3.function;
> > +
> > +import static org.junit.jupiter.api.Assertions.assertEquals;
> > +
> > +import org.apache.commons.lang3.AbstractLangTest;
> > +import org.junit.jupiter.api.Test;
> > +
> > +/**
> > + * Tests {@link IntToIntFunction}.
> > + */
> > +public class IntToIntFunctionTest extends AbstractLangTest {
> > +
> > + @Test
> > + public void testApply() {
> > + final IntToIntFunction func = i -> i + 1;
> > + assertEquals(66, func.applyAsInt(65));
> > + }
> > +
> > + @Test
> > + public void testIdentity() {
> > + assertEquals(65, IntToIntFunction.identity().applyAsInt(65));
> > + }
> > +}
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
Re: [commons-lang] 02/02: Add IntToIntFunction
Posted by Alex Herbert <al...@gmail.com>.
Is this not the same as:
java.util.function.IntUnaryOperator
On Mon, 10 Jul 2023 at 12:56, <gg...@apache.org> wrote:
>
> 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 120d3489aad924e310a8071a66139947ace7a685
> Author: Gary Gregory <ga...@gmail.com>
> AuthorDate: Mon Jul 10 07:56:18 2023 -0400
>
> Add IntToIntFunction
> ---
> src/changes/changes.xml | 1 +
> .../commons/lang3/function/IntToIntFunction.java | 52 ++++++++++++++++++++++
> .../lang3/function/IntToIntFunctionTest.java | 40 +++++++++++++++++
> 3 files changed, 93 insertions(+)
>
> diff --git a/src/changes/changes.xml b/src/changes/changes.xml
> index b9930b0d2..a9d493949 100644
> --- a/src/changes/changes.xml
> +++ b/src/changes/changes.xml
> @@ -216,6 +216,7 @@ The <action> type attribute can be add,update,fix,remove.
> <action issue="LANG-1647" type="add" dev="ggregory" due-to="Arturo Bernal, Dimitrios Efthymiou, Gary Gregory">Add and ExceptionUtils.isChecked() and isUnchecked() #1069</action>
> <action type="add" dev="ggregory" due-to="Gary Gregory">Add and use ExceptionUtils.throwUnchecked(throwable).</action>
> <action type="add" dev="ggregory" due-to="Gary Gregory">Add LockingVisitors.create(O, ReadWriteLock).</action>
> + <action type="add" dev="ggregory" due-to="Gary Gregory">Add IntToIntFunction.</action>
> <!-- UPDATE -->
> <action type="update" dev="ggregory" due-to="Dependabot, XenoAmess, Gary Gregory">Bump actions/cache from 2.1.4 to 3.0.10 #742, #752, #764, #833, #867, #959, #964.</action>
> <action type="update" dev="ggregory" due-to="Dependabot, Gary Gregory">Bump actions/checkout from 2 to 3.1.0 #819, #825, #859, #963.</action>
> diff --git a/src/main/java/org/apache/commons/lang3/function/IntToIntFunction.java b/src/main/java/org/apache/commons/lang3/function/IntToIntFunction.java
> new file mode 100644
> index 000000000..45f309743
> --- /dev/null
> +++ b/src/main/java/org/apache/commons/lang3/function/IntToIntFunction.java
> @@ -0,0 +1,52 @@
> +/*
> + * 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.lang3.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 3.13.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);
> +}
> diff --git a/src/test/java/org/apache/commons/lang3/function/IntToIntFunctionTest.java b/src/test/java/org/apache/commons/lang3/function/IntToIntFunctionTest.java
> new file mode 100644
> index 000000000..d8d11ae07
> --- /dev/null
> +++ b/src/test/java/org/apache/commons/lang3/function/IntToIntFunctionTest.java
> @@ -0,0 +1,40 @@
> +/*
> + * 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.lang3.function;
> +
> +import static org.junit.jupiter.api.Assertions.assertEquals;
> +
> +import org.apache.commons.lang3.AbstractLangTest;
> +import org.junit.jupiter.api.Test;
> +
> +/**
> + * Tests {@link IntToIntFunction}.
> + */
> +public class IntToIntFunctionTest extends AbstractLangTest {
> +
> + @Test
> + public void testApply() {
> + final IntToIntFunction func = i -> i + 1;
> + assertEquals(66, func.applyAsInt(65));
> + }
> +
> + @Test
> + public void testIdentity() {
> + assertEquals(65, IntToIntFunction.identity().applyAsInt(65));
> + }
> +}
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
[commons-lang] 02/02: Add IntToIntFunction
Posted by gg...@apache.org.
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 120d3489aad924e310a8071a66139947ace7a685
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Jul 10 07:56:18 2023 -0400
Add IntToIntFunction
---
src/changes/changes.xml | 1 +
.../commons/lang3/function/IntToIntFunction.java | 52 ++++++++++++++++++++++
.../lang3/function/IntToIntFunctionTest.java | 40 +++++++++++++++++
3 files changed, 93 insertions(+)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index b9930b0d2..a9d493949 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -216,6 +216,7 @@ The <action> type attribute can be add,update,fix,remove.
<action issue="LANG-1647" type="add" dev="ggregory" due-to="Arturo Bernal, Dimitrios Efthymiou, Gary Gregory">Add and ExceptionUtils.isChecked() and isUnchecked() #1069</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">Add and use ExceptionUtils.throwUnchecked(throwable).</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">Add LockingVisitors.create(O, ReadWriteLock).</action>
+ <action type="add" dev="ggregory" due-to="Gary Gregory">Add IntToIntFunction.</action>
<!-- UPDATE -->
<action type="update" dev="ggregory" due-to="Dependabot, XenoAmess, Gary Gregory">Bump actions/cache from 2.1.4 to 3.0.10 #742, #752, #764, #833, #867, #959, #964.</action>
<action type="update" dev="ggregory" due-to="Dependabot, Gary Gregory">Bump actions/checkout from 2 to 3.1.0 #819, #825, #859, #963.</action>
diff --git a/src/main/java/org/apache/commons/lang3/function/IntToIntFunction.java b/src/main/java/org/apache/commons/lang3/function/IntToIntFunction.java
new file mode 100644
index 000000000..45f309743
--- /dev/null
+++ b/src/main/java/org/apache/commons/lang3/function/IntToIntFunction.java
@@ -0,0 +1,52 @@
+/*
+ * 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.lang3.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 3.13.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);
+}
diff --git a/src/test/java/org/apache/commons/lang3/function/IntToIntFunctionTest.java b/src/test/java/org/apache/commons/lang3/function/IntToIntFunctionTest.java
new file mode 100644
index 000000000..d8d11ae07
--- /dev/null
+++ b/src/test/java/org/apache/commons/lang3/function/IntToIntFunctionTest.java
@@ -0,0 +1,40 @@
+/*
+ * 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.lang3.function;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.apache.commons.lang3.AbstractLangTest;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests {@link IntToIntFunction}.
+ */
+public class IntToIntFunctionTest extends AbstractLangTest {
+
+ @Test
+ public void testApply() {
+ final IntToIntFunction func = i -> i + 1;
+ assertEquals(66, func.applyAsInt(65));
+ }
+
+ @Test
+ public void testIdentity() {
+ assertEquals(65, IntToIntFunction.identity().applyAsInt(65));
+ }
+}
[commons-lang] 01/02: Javdoc
Posted by gg...@apache.org.
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 accde3be2368c64c2d3cb3c22e78a2b81c6423c9
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Jul 10 07:14:20 2023 -0400
Javdoc
---
.../java/org/apache/commons/lang3/function/IntToCharFunction.java | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/main/java/org/apache/commons/lang3/function/IntToCharFunction.java b/src/main/java/org/apache/commons/lang3/function/IntToCharFunction.java
index f3da38451..a90797d20 100644
--- a/src/main/java/org/apache/commons/lang3/function/IntToCharFunction.java
+++ b/src/main/java/org/apache/commons/lang3/function/IntToCharFunction.java
@@ -20,12 +20,11 @@ package org.apache.commons.lang3.function;
import java.util.function.Function;
/**
- * Represents a function that accepts an int-valued argument and produces a long-valued result. This is the
- * {@code int}-to-{@code long} primitive specialization for {@link Function}.
+ * Represents a function that accepts an int-valued argument and produces a char-valued result. This is the {@code int}-to-{@code char} primitive specialization
+ * for {@link Function}.
*
* <p>
- * This is a <a href="package-summary.html">functional interface</a> whose functional method is
- * {@link #applyAsChar(int)}.
+ * This is a <a href="package-summary.html">functional interface</a> whose functional method is {@link #applyAsChar(int)}.
* </p>
*
* @see Function