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 an @link IntUnaryOperator that receives an int as a bound parameter, and returns a random int
@return int operation
public static IntUnaryOperator boundedRandomIntSupplier
throw new ExerciseNotCompletedException;
Returns @link IntUnaryOperator that calculates an integer square
@return square operation
public static IntUnaryOperator intSquareOperation
throw new ExerciseNotCompletedException;
Returns a @link LongBinaryOperator sum operation.
@return binary sum operation
public static LongBinaryOperator longSumOperation
throw new ExerciseNotCompletedException;
Returns a @link ToIntFunction that converts string to integer.
@return string to int converter
public static ToIntFunction stringToIntConverter
throw new ExerciseNotCompletedException;
Receives int parameter n and returns a @link Supplier that supplies @link IntUnaryOperator
that is a function fx n x
@param n a multiplier
@return a function supplier
public static Supplier nMultiplyFunctionSupplierint n
throw new ExerciseNotCompletedException;
Returns a @link UnaryOperator that accepts str to str function and returns the same function composed with trim
@return function that composes functions with trim function
public static UnaryOperator composeWithTrimFunction
throw new ExerciseNotCompletedException;
Returns a @link BiFunction that has two parameters. First is @link IntUnaryOperator which is some integer function.
Second is @link IntPredicate which is some integer condition. And the third is @link IntUnaryOperator which is
a new composed function that uses provided predicate second parameter of binary function to verify its input
parameter. If predicate returns @code true it applies a provided integer function
first parameter of binary function and returns a result value, otherwise it returns an element itself.
@return a binary function that receiver predicate and function and compose them to create a new function
public static BiFunction functionToConditionalFunction
throw new ExerciseNotCompletedException;
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