Java Code Examples for org.osgl.util.Generics#typeParamImplementations()

The following examples show how to use org.osgl.util.Generics#typeParamImplementations() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DaoBase.java    From actframework with Apache License 2.0 6 votes vote down vote up
private void exploreTypes() {
    List<Type> types = Generics.typeParamImplementations(getClass(), DaoBase.class);
    int sz = types.size();
    if (sz < 1) {
        return;
    }
    if (sz > 2) {
        queryType = types.get(2);
        queryClass = Generics.classOf(queryType);
    }
    if (sz > 1) {
        modelType = types.get(1);
        modelClass = Generics.classOf(modelType);
    }
    idType = types.get(0);
    idClass = Generics.classOf(idType);
}
 
Example 2
Source File: DaoBase.java    From java-di with Apache License 2.0 5 votes vote down vote up
private void exploreTypes() {
    List<Type> types = Generics.typeParamImplementations(getClass(), DaoBase.class);
    int sz = types.size();
    if (sz < 1) {
        return;
    }
    if (sz > 1) {
        modelType = types.get(1);
        modelClass = Generics.classOf(modelType);
    }
    idType = types.get(0);
    idClass = Generics.classOf(idType);
}
 
Example 3
Source File: SimpleRestfulServiceBase.java    From actframework with Apache License 2.0 5 votes vote down vote up
private void exploreTypes() {
    Map<String, Class> typeParamLookup = Generics.buildTypeParamImplLookup(getClass());
    List<Type> types = Generics.typeParamImplementations(getClass(), SimpleRestfulServiceBase.class);
    int sz = types.size();
    if (sz < 3) {
        throw new IllegalArgumentException("Cannot determine DAO type");
    }
    Type daoType = types.get(2);
    BeanSpec spec = BeanSpec.of(daoType, Act.injector(), typeParamLookup);
    DaoLoader loader = Act.getInstance(DaoLoader.class);
    dao = $.cast(loader.load(spec));
}
 
Example 4
Source File: SampleDataProvider.java    From actframework with Apache License 2.0 5 votes vote down vote up
private void exploreType() {
    List<Type> types = Generics.typeParamImplementations(getClass(), SampleDataProvider.class);
    if (types.size() != 1) {
        warnTargetTypeNotDetermined();
    } else {
        Type type = types.get(0);
        if (! (type instanceof Class)) {
            warnTargetTypeNotDetermined();
        } else {
            targetType = (Class<T>) type;
        }
    }
}
 
Example 5
Source File: ModelBase.java    From actframework with Apache License 2.0 5 votes vote down vote up
private void exploreTypes() {
    List<Type> types = Generics.typeParamImplementations(getClass(), ModelBase.class);
    int sz = types.size();
    if (sz < 1) {
        return;
    }
    if (sz > 1) {
        modelType = types.get(1);
    }
    idType = types.get(0);
}
 
Example 6
Source File: ActProvider.java    From actframework with Apache License 2.0 5 votes vote down vote up
private Class<T> exploreTypeInfo() {
    List<Type> types = Generics.typeParamImplementations(getClass(), ActProvider.class);
    int sz = types.size();
    E.illegalStateIf(1 != sz, "generic type number not match");
    Type type = types.get(0);
    E.illegalArgumentIf(!(type instanceof Class), "generic type is not a class: %s", type);
    return (Class) type;
}
 
Example 7
Source File: DaoBase.java    From java-tool with Apache License 2.0 5 votes vote down vote up
private void exploreTypes() {
    List<Type> types = Generics.typeParamImplementations(getClass(), DaoBase.class);
    int sz = types.size();
    if (sz < 1) {
        return;
    }
    if (sz > 1) {
        modelType = types.get(1);
        modelClass = Generics.classOf(modelType);
    }
    idType = types.get(0);
    idClass = Generics.classOf(idType);
}
 
Example 8
Source File: ClassMetaInfoManager.java    From actframework with Apache License 2.0 4 votes vote down vote up
private void exploreTypes() {
    List<Type> types = Generics.typeParamImplementations(getClass(), ClassMetaInfoManager.class);
    infoType = Generics.classOf(types.get(0));
}