All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.kucoin.sdk.rest.impl.retrofit.PublicRetrofitAPIImpl Maven / Gradle / Ivy

The newest version!
/**
 * Copyright 2019 Mek Global Limited.
 */
package com.kucoin.sdk.rest.impl.retrofit;

import com.kucoin.sdk.factory.RetrofitFactory;

import java.lang.reflect.ParameterizedType;

/**
 * Created by chenshiwei on 2019/1/10.
 */
public class PublicRetrofitAPIImpl extends AbstractRetrofitAPIImpl {

    private volatile boolean inited;
    private T apiImpl;

    @Override
    public T getAPIImpl() {
        if (inited)
            return apiImpl;
        synchronized (getClass()) {
            if (inited)
                return apiImpl;
            @SuppressWarnings("unchecked")
            Class tClass = (Class) ((ParameterizedType) this.getClass().getGenericSuperclass())
                    .getActualTypeArguments()[0];
            T t = RetrofitFactory.getPublicRetorfit(baseUrl).create(tClass);
            apiImpl = t;
            return t;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy