com.atom.annotation.bean.ApiImpls Maven / Gradle / Ivy
package com.atom.annotation.bean;
import java.util.HashMap;
import java.util.Map;
public abstract class ApiImpls {
private final Map, ApiImplsMap>> mApiImpsMap = new HashMap<>();
public ApiImpls() {
}
protected void add(String name, Class apiClass, Class extends T> implClass, long version) {
ApiImplsMap implsMap;
synchronized (mApiImpsMap) {
ApiImplsMap> apiImplsMap = mApiImpsMap.get(apiClass);
if (apiImplsMap == null) {
implsMap = new ApiImplsMap<>();
mApiImpsMap.put(apiClass, implsMap);
} else {
implsMap = (ApiImplsMap) apiImplsMap;
}
}
implsMap.put(implClass, new ApiImplWrapper(apiClass, implClass, name, version));
}
@SuppressWarnings("unchecked")
public Map, ApiImplWrapper> getApiImpls(Class apiClass) {
synchronized (mApiImpsMap) {
return (ApiImplsMap) mApiImpsMap.get(apiClass);
}
}
private static class ApiImplsMap extends HashMap, ApiImplWrapper> {
}
}