dimanche 10 avril 2016

java get type from object by reflect

can i get the object generics type from object?

it's the class of target:

public static abstract class MySubscriber<T extends Foo> extends rx.Subscriber<T> {

    public abstract void onNext(T t);

}

and i what get the subscriber's generics type at there:

Observable.create(new Observable.OnSubscribe<Foo>() {
        @Override
        public void call(Subscriber<? super Foo> subscriber) {
            String jsonStr = "{a:1, b:2}";

            // how to get the subscriber generics type
            subscriber.onNext(gson.fromJson(echo, ??));
        }
    });





Aucun commentaire:

Enregistrer un commentaire