Search in sources :

Example 1 with TypeResolver

use of com.datastax.oss.driver.shaded.guava.common.reflect.TypeResolver in project java-driver by datastax.

the class GenericType method where.

/**
 * Substitutes a free type variable with an actual type. See {@link GenericType this class's
 * javadoc} for an example.
 */
@NonNull
public final <X> GenericType<T> where(@NonNull GenericTypeParameter<X> freeVariable, @NonNull GenericType<X> actualType) {
    TypeResolver resolver = new TypeResolver().where(freeVariable.getTypeVariable(), actualType.__getToken().getType());
    Type resolvedType = resolver.resolveType(this.token.getType());
    @SuppressWarnings("unchecked") TypeToken<T> resolvedToken = (TypeToken<T>) TypeToken.of(resolvedType);
    return new GenericType<>(resolvedToken);
}
Also used : Type(java.lang.reflect.Type) TypeResolver(com.datastax.oss.driver.shaded.guava.common.reflect.TypeResolver) TypeToken(com.datastax.oss.driver.shaded.guava.common.reflect.TypeToken) NonNull(edu.umd.cs.findbugs.annotations.NonNull)

Aggregations

TypeResolver (com.datastax.oss.driver.shaded.guava.common.reflect.TypeResolver)1 TypeToken (com.datastax.oss.driver.shaded.guava.common.reflect.TypeToken)1 NonNull (edu.umd.cs.findbugs.annotations.NonNull)1 Type (java.lang.reflect.Type)1