Our library contains two methods: doXForAll
and doXForEach
:
default List<Object> doXForAll(Object input1) {
return Collections.singletonList(doXForEach(input1));
}
default Object doXForEach(Object input1) {
return doX(input1); // Some kind of default behaviour over the input
}
We encourage clients to override these default methods with their own implementations. We need to be cautious not to make any changes that would break existing functionality.
The problem:
We want to add support for an extra parameter Object input2
in both of the above methods. How would you recommend going about this without requiring our clients to update their implementations?
Our current solution:
default List<Object> doXForAll(Object input1, Object input2) {
return doXForAll(input1);
}
The problems with this are:
- We're missing a
doXForEach
method with the additional parameter - We are calling methods we've just deprecated (which feels wrong)