Java Code Examples for com.google.common.reflect.TypeResolver

The following examples show how to use com.google.common.reflect.TypeResolver. These examples are extracted from open source projects. 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
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 Project: pushfish-android   Source File: ModelType.java    License: 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
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
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 Project: Pushjet-Android   Source File: ModelType.java    License: 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;
}