Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please take a look at the todo part and help with the following code! Thank you so much! package fp; import java.math.BigDecimal; import java.util.ArrayList; import
Please take a look at the todo part and help with the following code! Thank you so much!
package fp;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Map;
import java.util.function.
;
import java.util.stream.Collectors;
import java.util.List;
class ExerciseNotCompletedException extends RuntimeException
public ExerciseNotCompletedException
super
Exercise is not completed yet"
;
@link HW
is an exercise class. Each method returns a functional interface and it should be implemented
using either lambda or a method reference. Every method that is not implemented yet throws
@link ExerciseNotCompletedException
TODO: remove exception and implement each method of this class using lambda or method reference
Returns a @link BiFunction which first parameter is a @link Map where key is a function name, and value is some
@link IntUnaryOperator and second parameter is a @link String which is a function name. If the map contains a
function by a given name then it is returned by high order function otherwise an identity is returned.
@return a highorder function that fetches a function from a function map by a given name or returns identity
public static BiFunction, String, IntUnaryOperator functionLoader
throw new ExerciseNotCompletedException;
Returns a comparator of type T that is comparing values extracted using the provided mapper function.
Eg imagine you need to compare accounts by their balance values.
PLEASE NOTE, that @@link Comparator is a functional interface, and you should manually write a lambda expression
to implement it
@param mapper a mapper function that allows to map an object to a comparable value
@return a comparator instance
public static Comparator comparingFunction mapper
throw new ExerciseNotCompletedException;
Returns a comparator of type T that uses a provided comparator to compare objects, and only if they are equal
it's comparing values extracted using the provided mapper function.
Eg suppose you want to compare accounts by balance, but in case two people have the same balance you want to
compare their first names:
@param comparator an initial comparator
@param mapper a mapper function that is used to extract values when initial comparator returns zero
@return a comparator instance
public static Comparator thenComparing
Comparator comparator, Function mapper
throw new ExerciseNotCompletedException;
Returns @link Supplier of @link Supplier of @link Supplier of @link String "WELL DONE!".
@return a supplier instance
public static Supplier trickyWellDoneSupplier
throw new ExerciseNotCompletedException;
public static void mainString args
ArrayList l new ArrayList;
ladda;
laddbc;
ladddcf;
System.out.printlnmaplString x return xlength;;
U String, V Integer
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started