After discussion in the comments:
To fix a compilation error:
Function<Object, Double> f1 = Functions.compose(Functions.forMap(someMap), Functions.toStringFunction());
Your question implies that you want Function<Integer, Double> instead of Function<Object, Double> . Based on the discussion in the comments and trying to think about other scenarios, the only reason you want to is checking. The code in the toStringFunction function is out of your control, so checking in this function is out of the question. As for the validation in the forMap function, this code is also uncontrollable. If you want to protect against an IllegalArgumentException, you will need to perform this check to see if the input you provided is an object or an integer. Thus, the check also goes beyond the scope of forMap, toStringFunction and is, because none of these functions provides such a check, and you must write your own code for this (either catch the exception, or handle it, or check which this way before calling this compiled function).
For a particular compilation, you do not get anything by changing the input parameter Function from Object to Integer, because functions only need methods that are present in Object, so this is a good solution, because it simplifies in this case and makes it more widely used. Suppose you were able to apply the parameter type as Integer, you still did not get absolutely any benefit, whether it was checking for IllegalArgumentException or something else that you are trying to do.
When developing an API, you want it to be used by as many consumers as possible, without having to go out of your way, that is, you must use the highest level class that meets your requirements. Using Object in toStringFunction, the Guava function satisfies this principle. This makes the function more general and more widely used. This is the reason for choosing an object instead of parameterizing this function.
If a function accepts a parameter, it will not do anything differently as it is now, so why use a parameter when it is not needed. This approach greatly simplifies the design, instead of adding something that is not required.
Original answer:
Each class is a child of the object, and the function only calls a toString on the input that is present in the Object class. Therefore, in this case, declaring a function is equivalent to declaring a function. You will not get anything by changing the input parameter of the function from the object to the whole, because functions only need the methods present in the object, so this is a good solution, because in this case it simplifies.
As much as possible, you should use the highest level class that suits your requirements. This makes the function more general and more widely used. This is the reason for choosing an object instead of parameterizing this function.
To fix a compilation error: Function f1 = Functions.compose (Functions.forMap (someMap), Functions.toStringFunction ());