Skip to content
This repository was archived by the owner on Feb 10, 2021. It is now read-only.

Commit 3d8c9c9

Browse files
committed
Complete new tasks in CrazyLambdas.java
1 parent 9e7c40e commit 3d8c9c9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

crazy-lambdas/src/main/java/com/bobocode/CrazyLambdas.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static Predicate<String> isEmptyPredicate() {
3232
* @return function that repeats Strings
3333
*/
3434
public static BiFunction<String, Integer, String> stringMultiplier() {
35-
throw new UnsupportedOperationException("It's your job to implement this method"); // todo
35+
return String::repeat;
3636
}
3737

3838
/**
@@ -120,7 +120,7 @@ public static Supplier<IntUnaryOperator> nMultiplyFunctionSupplier(int n) {
120120
* @return function that composes functions with trim() function
121121
*/
122122
public static UnaryOperator<Function<String, String>> composeWithTrimFunction() {
123-
throw new UnsupportedOperationException("It's your job to implement this method"); // todo
123+
return stringFunction -> stringFunction.compose(String::trim);
124124
}
125125

126126
/**
@@ -182,7 +182,7 @@ public static BiFunction<IntUnaryOperator, IntPredicate, IntUnaryOperator> funct
182182
* @return a high-order function that fetches a function from a function map by a given name or returns identity()
183183
*/
184184
public static BiFunction<Map<String, IntUnaryOperator>, String, IntUnaryOperator> functionLoader() {
185-
throw new UnsupportedOperationException("It's your job to implement this method"); // todo
185+
return (functionMap, functionName) -> functionMap.getOrDefault(functionName, IntUnaryOperator.identity());
186186
}
187187

188188
/**

0 commit comments

Comments
 (0)