mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-12 08:14:13 +00:00
deps: Refactor dependencies (#3224)
* remove spring dep move junit, logging, mockito under dep mgmt * upgrade anti-corruption-layer deps * async method invocation * balking, bloc * bridge to bytecode * caching * callback - cqrs * component - health check * hexagonal - metadata mapping * rest of the patterns * remove checkstyle, take spotless into use
This commit is contained in:
1 parent
371439aeaa
commit
0ca162a55c
1863 files changed
+14403
-17632
No files matched your search
@@ -27,9 +27,7 @@ package com.iluwatar.function.composition;
|
||||
import java.util.function.Function;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Main application class to demonstrate the use of function composition.
|
||||
*/
|
||||
/** Main application class to demonstrate the use of function composition. */
|
||||
public class App {
|
||||
|
||||
/**
|
||||
@@ -42,7 +40,8 @@ public class App {
|
||||
Function<Integer, Integer> timesTwo = x -> x * 2;
|
||||
Function<Integer, Integer> square = x -> x * x;
|
||||
|
||||
Function<Integer, Integer> composedFunction = FunctionComposer.composeFunctions(timesTwo, square);
|
||||
Function<Integer, Integer> composedFunction =
|
||||
FunctionComposer.composeFunctions(timesTwo, square);
|
||||
|
||||
int result = composedFunction.apply(3);
|
||||
logger.info("Result of composing 'timesTwo' and 'square' functions applied to 3 is: " + result);
|
||||
|
||||
+6
-5
@@ -27,20 +27,21 @@ package com.iluwatar.function.composition;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Class for composing functions using the Function Composition pattern.
|
||||
* Provides a static method to compose two functions using the 'andThen' method.
|
||||
* Class for composing functions using the Function Composition pattern. Provides a static method to
|
||||
* compose two functions using the 'andThen' method.
|
||||
*/
|
||||
public class FunctionComposer {
|
||||
|
||||
/**
|
||||
* Composes two functions where the output of the first function becomes
|
||||
* the input of the second function.
|
||||
* Composes two functions where the output of the first function becomes the input of the second
|
||||
* function.
|
||||
*
|
||||
* @param f1 the first function to apply
|
||||
* @param f2 the second function to apply after the first
|
||||
* @return a composed function that applies f1 and then f2
|
||||
*/
|
||||
public static Function<Integer, Integer> composeFunctions(Function<Integer, Integer> f1, Function<Integer, Integer> f2) {
|
||||
public static Function<Integer, Integer> composeFunctions(
|
||||
Function<Integer, Integer> f1, Function<Integer, Integer> f2) {
|
||||
return f1.andThen(f2);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user