docs: update function composition pattern

This commit is contained in:
Ilkka Seppälä
2025-04-12 16:11:03 +03:00
parent ce2e5f75d8
commit 8ca487e96c
4 changed files with 28 additions and 28 deletions
@@ -25,9 +25,10 @@
package com.iluwatar.function.composition;
import java.util.function.Function;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
/** Main application class to demonstrate the use of function composition. */
@Slf4j
public class App {
/**
@@ -36,7 +37,6 @@ public class App {
* @param args command line arguments (not used)
*/
public static void main(String[] args) {
final var logger = LoggerFactory.getLogger(App.class);
Function<Integer, Integer> timesTwo = x -> x * 2;
Function<Integer, Integer> square = x -> x * x;
@@ -44,6 +44,6 @@ public class App {
FunctionComposer.composeFunctions(timesTwo, square);
int result = composedFunction.apply(3);
logger.info("Result of composing 'timesTwo' and 'square' functions applied to 3 is: " + result);
LOGGER.info("Result of composing 'timesTwo' and 'square' functions applied to 3 is: " + result);
}
}
@@ -32,6 +32,8 @@ import java.util.function.Function;
*/
public class FunctionComposer {
private FunctionComposer() {}
/**
* Composes two functions where the output of the first function becomes the input of the second
* function.
@@ -30,7 +30,7 @@ import java.util.function.Function;
import org.junit.jupiter.api.Test;
/** Test class for FunctionComposer. */
public class FunctionComposerTest {
class FunctionComposerTest {
/** Tests the composition of two functions. */
@Test