List of usage examples for com.google.common.reflect TypeParameter TypeParameter
protected TypeParameter()
From source file:net.derquinse.common.reflect.Types.java
/** * Returns a type token modelling a {@link List} whose elements are of type {@code elementType}. * @return a {@link TypeToken type token} representing the parameterized type. *//*from w w w . j a va2 s .c o m*/ @SuppressWarnings("serial") public static <T> TypeToken<List<T>> listOf(Class<T> elementType) { return new TypeToken<List<T>>() { }.where(new TypeParameter<T>() { }, elementType); }
From source file:com.datastax.driver.core.TypeTokens.java
/** * Create a {@link TypeToken} that represents a {@link List} whose elements * are of the given type./*from w w w . j av a 2 s . c om*/ * * @param eltType The list element type. * @param <T> The list element type. * @return A {@link TypeToken} that represents a {@link List} whose elements * are of the given type. */ public static <T> TypeToken<List<T>> listOf(Class<T> eltType) { // @formatter:off return new TypeToken<List<T>>() { }.where(new TypeParameter<T>() { }, eltType); // @formatter:on }
From source file:net.derquinse.common.reflect.Types.java
/** * Returns a type modelling a {@link Set} whose elements are of type {@code elementType}. * @return a {@link TypeToken type token} representing the parameterized type. *///from www. ja v a 2 s .com @SuppressWarnings("serial") public static <T> TypeToken<Set<T>> setOf(Class<T> elementType) { return new TypeToken<Set<T>>() { }.where(new TypeParameter<T>() { }, elementType); }
From source file:com.facebook.presto.server.smile.SmileCodec.java
public static <T> SmileCodec<List<T>> listSmileCodec(Class<T> type) { requireNonNull(type, "type is null"); Type listType = new TypeToken<List<T>>() { }.where(new TypeParameter<T>() { }, type).getType();// w ww . j av a 2 s .co m return new SmileCodec<>(OBJECT_MAPPER_SUPPLIER.get(), listType); }
From source file:org.jclouds.rest.config.BinderUtils.java
@SuppressWarnings({ "unchecked", "serial" }) private static <T> void bindAnnotatedHttpApiProvider(Binder binder, Class<T> annotated) { TypeToken<AnnotatedHttpApiProvider<T>> token = new TypeToken<AnnotatedHttpApiProvider<T>>() { }.where(new TypeParameter<T>() { }, annotated);/*from w ww.ja v a 2 s . c om*/ binder.bind(annotated).toProvider(TypeLiteral.class.cast(TypeLiteral.get(token.getType()))); }
From source file:ratpack.util.Types.java
/** * Creates a type token for a list of of the given type. * <pre class="java">{@code/*from ww w . jav a 2 s .c o m*/ * import ratpack.util.Types; * import com.google.common.reflect.TypeToken; * * import java.util.List; * * import static org.junit.Assert.*; * * public class Example { * public static void main(String... args) { * assertEquals(Types.listOf(String.class), new TypeToken<List<String>>() {}); * } * } * }</pre> * * @param type the list element type * @param <T> the list element type * @return a type token for a list of of the given type. */ public static <T> TypeToken<List<T>> listOf(Class<T> type) { return new TypeToken<List<T>>() { }.where(new TypeParameter<T>() { }, TypeToken.of(type)); }
From source file:com.datastax.driver.core.TypeTokens.java
/** * Create a {@link TypeToken} that represents a {@link List} whose elements * are of the given type.//from w ww . j ava 2s . co m * * @param eltType The list element type. * @param <T> The list element type. * @return A {@link TypeToken} that represents a {@link List} whose elements * are of the given type. */ public static <T> TypeToken<List<T>> listOf(TypeToken<T> eltType) { // @formatter:off return new TypeToken<List<T>>() { }.where(new TypeParameter<T>() { }, eltType); // @formatter:on }
From source file:io.airlift.json.JsonCodec.java
public static <T> JsonCodec<List<T>> listJsonCodec(Class<T> type) { checkNotNull(type, "type is null"); Type listType = new TypeToken<List<T>>() { }.where(new TypeParameter<T>() { }, type).getType();/*from w w w. j av a 2 s. c o m*/ return new JsonCodec<>(OBJECT_MAPPER_SUPPLIER.get(), listType); }
From source file:org.jclouds.rest.internal.BaseHttpApiMetadata.java
public static <S, A> TypeToken<ApiContext<A>> contextToken(TypeToken<A> apiToken) { return new TypeToken<ApiContext<A>>() { private static final long serialVersionUID = 1L; }.where(new TypeParameter<A>() { }, apiToken);/* ww w . j av a 2 s . c om*/ }
From source file:org.mayocat.search.elasticsearch.internal.DefaultEntityIndexDocumentPurveyor.java
static <T extends Entity> TypeToken<EntityIndexDocumentPurveyor<T>> indexDocumentPurveyorOf( Class<T> entityType) { return new TypeToken<EntityIndexDocumentPurveyor<T>>() { }.where(new TypeParameter<T>() { }, entityType);//from ww w . j a v a 2 s.com }