Consider a class, say
Class Abc {
private String extraInfo;
pubilc Abc(String extraInfo) {
this.extraInfo = extraInfo;
}
// Assume Input1, Input2 extend the same class 'Input`
public Input2 method1 (Input1 input) {
// performs some action based on the input.
}
public Input1 method2 (Input2 input) {
}
}
What I'm trying to do is write a common method that takes in refrence to these methods as bifuction and want to identify whether the function reference is of method1 or method2.
eg.
void testSuccess (Bifunction<Abc, I, O> func) {
val obj = new Abc("text");
func.apply(obj, decideInput(func));
}
I'm trying to write decideInput which takes in the method ref and returns Input1 type object if the ref is for method1 and Input2 if ref is for method2.
Also would it be a problem writing decideInput if Input1, Input2 do not extend the same class
Input.
I know that the func is a lambda and that it could cause identifying the actual reference.
method1 and method2 both are of type Function. Not sure why you are trying to use BiFunction
BiFunction would be used for a method that takes in two arguments.