Add IntToCharFunction.

This commit is contained in:
Gary Gregory 2021-08-27 11:16:49 -04:00
parent e93e4f2e87
commit 3f9422aec4
3 changed files with 79 additions and 0 deletions

View File

@ -71,6 +71,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="add" dev="ggregory" due-to="Gary Gregory">Add and use ArrayUtils.setAll(T[], IntFunction).</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">Add and use ArrayUtils.setAll(T[], Supplier).</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">Add BooleanConsumer.</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">Add IntToCharFunction.</action>
<!-- UPDATE -->
<action type="update" dev="ggregory" due-to="Dependabot, Gary Gregory">Bump spotbugs-maven-plugin from 4.2.0 to 4.2.3 #735.</action>
<action type="update" dev="ggregory" due-to="Dependabot, XenoAmess">Bump Bump actions/cache from v2.1.4 to v2.1.6 #742, #752, #764.</action>

View File

@ -0,0 +1,44 @@
/*
* 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 a long-valued result. This is the
* {@code int}-to-{@code long} primitive specialization for {@link Function}.
*
* <p>
* This is a <a href="package-summary.html">functional interface</a> whose functional method is
* {@link #applyAsChar(int)}.
* </p>
*
* @see Function
* @since 3.13.0
*/
@FunctionalInterface
public interface IntToCharFunction {
/**
* Applies this function to the given argument.
*
* @param value the function argument.
* @return the function result.
*/
char applyAsChar(int value);
}

View File

@ -0,0 +1,34 @@
/*
* 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.junit.jupiter.api.Test;
/**
* Tests {@link IntToCharFunction}.
*/
public class IntToCharFunctionTest {
@Test
public void test() {
final IntToCharFunction func = i -> (char) i;
assertEquals('A', func.applyAsChar(65));
}
}