com.google.common.reflect.TypeResolver Java Examples

The following examples show how to use com.google.common.reflect.TypeResolver. 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: TypeManifest.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
public TypeManifest(@Nullable TypeLiteral<T> nullableType) {
    this.typeToken = nullableType != null ? Types.toToken(nullableType)
                                          : new TypeToken<T>(getClass()){};
    this.type = nullableType != null ? nullableType
                                     : Types.toLiteral(typeToken);

    Types.assertFullySpecified(this.type);

    this.typeParameter = new TypeParameter<T>(){};
    this.typeArg = new TypeArgument<T>(this.type){};

    TypeResolver resolver = new TypeResolver();
    for(Class<?> cls = getClass(); cls != null; cls = cls.getSuperclass()) {
        if(cls.getTypeParameters().length > 0) {
            resolver = resolver.where(cls.getTypeParameters()[0], type.getType());
        }
    }
    this.resolver = resolver;
}
 
Example #2
Source File: ModelType.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@SuppressWarnings("unchecked")
public <I> Builder<T> where(Parameter<I> parameter, ModelType<I> type) {
    TypeResolver resolver = new TypeResolver().where(parameter.typeVariable, type.typeToken.getType());
    typeToken = (TypeToken<T>) TypeToken.of(resolver.resolveType(typeToken.getType()));
    return this;
}
 
Example #3
Source File: ResolvableType.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
public TypeLiteral<T> where(TypeVariable<?> typeVariable, TypeLiteral<?> type) {
    final TypeResolver resolver = new TypeResolver().where(typeVariable, type.getType());
    return (TypeLiteral<T>) TypeLiteral.get(resolver.resolveType(getType()));
}
 
Example #4
Source File: ResolvableType.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
public TypeLiteral<T> where(TypeVariable<?> typeVariable, TypeToken<?> type) {
    final TypeResolver resolver = new TypeResolver().where(typeVariable, type.getType());
    return (TypeLiteral<T>) TypeLiteral.get(resolver.resolveType(getType()));
}
 
Example #5
Source File: ModelType.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@SuppressWarnings("unchecked")
public <I> Builder<T> where(Parameter<I> parameter, ModelType<I> type) {
    TypeResolver resolver = new TypeResolver().where(parameter.typeVariable, type.typeToken.getType());
    typeToken = (TypeToken<T>) TypeToken.of(resolver.resolveType(typeToken.getType()));
    return this;
}