List of usage examples for com.google.common.reflect TypeParameter TypeParameter
protected TypeParameter()
From source file:co.cask.tigon.internal.app.AbstractSpecificationCodec.java
protected final <V> Set<V> deserializeSet(JsonElement json, JsonDeserializationContext context, Class<V> valueType) { Type type = new TypeToken<Set<V>>() { }.where(new TypeParameter<V>() { }, valueType).getType();// w w w. j ava2 s. co m Set<V> set = context.deserialize(json, type); return set == null ? ImmutableSet.<V>of() : set; }
From source file:info.archinnov.achilles.internals.metamodel.MapProperty.java
public MapProperty(FieldInfo<ENTITY, Map<KEYFROM, VALUEFROM>> fieldInfo, boolean frozen, boolean emptyCollectionIfNull, AbstractProperty<ENTITY, KEYFROM, KEYTO> keyProperty, AbstractProperty<ENTITY, VALUEFROM, VALUETO> valueProperty) { super(new TypeToken<Map<KEYFROM, VALUEFROM>>() { }.where(new TypeParameter<KEYFROM>() { }, keyProperty.valueFromTypeToken).where(new TypeParameter<VALUEFROM>() { }, valueProperty.valueFromTypeToken), new TypeToken<Map<KEYTO, VALUETO>>() { }.where(new TypeParameter<KEYTO>() { }, keyProperty.valueToTypeToken).where(new TypeParameter<VALUETO>() { }, valueProperty.valueToTypeToken), fieldInfo); this.frozen = frozen; this.emptyCollectionIfNull = emptyCollectionIfNull; this.keyProperty = keyProperty; this.valueProperty = valueProperty; }
From source file:ratpack.render.Renderer.java
/** * Creates a type token for a renderer of the given type of object. * * @param typeToRender the type that the renderer renders * @param <T> the type that the renderer renders * @return a type token for a renderer of the given type of object */// w ww .j a v a 2 s . co m static <T> TypeToken<Renderer<T>> typeOf(Class<T> typeToRender) { return new TypeToken<Renderer<T>>(typeToRender) { }.where(new TypeParameter<T>() { }, typeToRender); }
From source file:co.cask.cdap.etl.batch.spark.DatasetInfo.java
private static <T> Type getListType(Class<T> elementType) { return new TypeToken<List<T>>() { }.where(new TypeParameter<T>() { }, elementType).getType();/*from w ww.j a va 2s .co m*/ }
From source file:com.facebook.swift.codec.metadata.ThriftType.java
public static <E> ThriftType list(ThriftType valueType) { checkNotNull(valueType, "valueType is null"); @SuppressWarnings("serial") Type javaType = new TypeToken<List<E>>() { }.where(new TypeParameter<E>() { }, (TypeToken<E>) TypeToken.of(valueType.getJavaType())).getType(); return new ThriftType(ThriftProtocolType.LIST, javaType, null, valueType); }
From source file:org.eclipse.gef4.mvc.behaviors.HoverBehavior.java
/** * Returns the {@link HoverModel} in the context of the {@link #getHost() * host}.//from w w w .ja va 2s .c o m * * @return The {@link HoverModel} in the context of the {@link #getHost() * host}. */ @SuppressWarnings("serial") protected HoverModel<VR> getHoverModel() { IViewer<VR> viewer = getHost().getRoot().getViewer(); HoverModel<VR> hoverModel = viewer.getAdapter(new TypeToken<HoverModel<VR>>() { }.where(new TypeParameter<VR>() { }, Types.<VR>argumentOf(viewer.getClass()))); return hoverModel; }
From source file:io.airlift.json.JsonCodecFactory.java
public <T> JsonCodec<List<T>> listJsonCodec(JsonCodec<T> type) { Preconditions.checkNotNull(type, "type is null"); Type listType = new TypeToken<List<T>>() { }.where(new TypeParameter<T>() { }, type.getTypeToken()).getType();/* ww w . j a v a 2s . c om*/ return new JsonCodec<>(createObjectMapper(), listType); }
From source file:com.facebook.presto.server.smile.SmileCodecFactory.java
public <K, V> SmileCodec<Map<K, V>> mapSmileCodec(Class<K> keyType, Class<V> valueType) { requireNonNull(keyType, "keyType is null"); requireNonNull(valueType, "valueType is null"); Type mapType = new TypeToken<Map<K, V>>() { }.where(new TypeParameter<K>() { }, keyType).where(new TypeParameter<V>() { }, valueType).getType();//from w w w . ja v a 2 s . com return new SmileCodec<>(createObjectMapper(), mapType); }
From source file:com.datastax.driver.core.TypeTokens.java
/** * Create a {@link TypeToken} that represents a {@link Map} whose keys * and values are of the given key and value types. * * @param keyType The map key type.// ww w . j ava 2s . c om * @param valueType The map value type * @param <K> The map key type. * @param <V> The map value type * @return A {@link TypeToken} that represents a {@link Map} whose keys * and values are of the given key and value types */ public static <K, V> TypeToken<Map<K, V>> mapOf(Class<K> keyType, Class<V> valueType) { // @formatter:off return new TypeToken<Map<K, V>>() { }.where(new TypeParameter<K>() { }, keyType).where(new TypeParameter<V>() { }, valueType); // @formatter:on }
From source file:org.lanternpowered.server.data.key.LanternKeyFactory.java
public static <E> Key<MutableBoundedValue<E>> makeMutableBoundedValueKey(TypeToken<E> elementToken, DataQuery query, String id, String name) { final TypeToken<MutableBoundedValue<E>> valueToken = new TypeToken<MutableBoundedValue<E>>() { }.where(new TypeParameter<E>() { }, elementToken);/*w w w . j av a 2 s.c o m*/ return KeyFactory.makeSingleKey(elementToken, valueToken, query, id, name); }