Andrey Arzhannikov Andrey Arzhannikov - 1 year ago 121
Android Question

validateEagerly() method in Retrofit 2.0 (beta 2)

What exactly does

(Retrofit 2.0 beta 2) method do?
Where can I apply this method?

JavaDoc says that
When calling create on the resulting Retrofit instance, eagerly validate the configuration of all methods in the supplied interface.
but this description is not so clear.

Answer Source

validateEagerly() validates the configuration you have provided when building your Retrofit instance. This will inspect your interface annotations for valid Retrofit annotations, inspection of arguments and method arguments, if they are consistent with the annotations set, also this checks for possible incorrect method return types (different than Call<T>).

The inspection is usually called before you build your Retrofit instance.

private Retrofit getRetrofit() {
        OkHttpClient okClient = getOkHttpClient();
        GsonBuilder builder = getGsonBuilder();
        Retrofit.Builder retrofitBuilder = new Retrofit.Builder();

It can throw IllegalArgumentException with different message and cause, if something is not valid.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download