jeudi 22 juin 2017

How to adapt to changes in API

I have a large project that depends on certain library. One of this library classes exposed the following methods:

public void until(final Predicate<T> isTrue)
public <V> V until(Function<? super T, V> isTrue) {

where Predicate and Function are:

com.google.common.base.Predicate<T>
com.google.common.base.Function<? super T, V>

In the last version of that library the above has been changed and was refactored by deprecating(removing) the public void until(final Predicate<T> isTrue) method and amending the second method as follows:

public <V> V until(Function<? super T, V> isTrue)

where Function is now java.util.function.Function<? super T, V>.

As far as I understand the above changes has been done to fully support Java 8 features and specifically lambda expressions.

Now to my question. While I can transform all calls to until that used the deprecated version of this method to the new structure but I am afraid there are too many places where this method is called. Is there a way I can keep using the old (deprecated) method by maybe re-declaring it elsewhere myself or any something of a kind? Any alternative ways to solve this problem are happily accepted.

Aucun commentaire:

Enregistrer un commentaire