List of usage examples for com.google.common.reflect TypeParameter TypeParameter
protected TypeParameter()
From source file:org.jclouds.internal.BaseView.java
@Override public <A extends Closeable> A unwrapApi(Class<A> apiClass) { checkArgument(ApiContext.class.isAssignableFrom(backendType.getRawType()), "backend type: %s should be an ApiContext", backendType); TypeToken<ApiContext<A>> contextToken = new TypeToken<ApiContext<A>>(delegate().getClass()) { private static final long serialVersionUID = 1L; }.where(new TypeParameter<A>() { }, TypeToken.of(apiClass));/*from w w w.j a v a2s . c o m*/ return unwrap(contextToken).getApi(); }
From source file:edu.washington.cs.cupid.wizards.internal.SetGetter.java
@Override public TypeToken<Set<I>> getInputType() { return new TypeToken<Set<I>>(getClass()) { }.where(new TypeParameter<I>() { }, type);//from w w w . j a va 2s .co m }
From source file:co.cask.tigon.internal.app.AbstractSpecificationCodec.java
protected final <V> JsonElement serializeList(List<V> list, JsonSerializationContext context, Class<V> valueType) { Type type = new TypeToken<List<V>>() { }.where(new TypeParameter<V>() { }, valueType).getType();/*www .ja v a 2s. c o m*/ return context.serialize(list, type); }
From source file:org.eclipse.gef4.mvc.policies.DeletionPolicy.java
@SuppressWarnings("serial") @Override// ww w.j a v a 2 s . c om protected ITransactionalOperation createOperation() { ReverseUndoCompositeOperation commit = new ReverseUndoCompositeOperation("Delete Content"); IViewer<VR> viewer = getHost().getRoot().getViewer(); // unfocus // TODO: this should be different-> use unfocus and initialize with null // or empty list commit.add(new ChangeFocusOperation<>(viewer, viewer.getAdapter(new TypeToken<FocusModel<VR>>() { }.where(new TypeParameter<VR>() { }, Types.<VR>argumentOf(getHost().getRoot().getViewer().getClass()))).getFocused())); // deselect commit.add(new DeselectOperation<>(viewer, Collections.<IContentPart<VR, ? extends VR>>emptyList())); // detach anchorages commit.add(new ReverseUndoCompositeOperation("Detach anchorages")); // remove children commit.add(new ReverseUndoCompositeOperation("Remove children")); return commit; }
From source file:io.airlift.drift.codec.metadata.ThriftType.java
public static <K, V> ThriftType map(ThriftTypeReference keyTypeReference, ThriftTypeReference valueTypeReference) { requireNonNull(keyTypeReference, "keyTypeReference is null"); requireNonNull(valueTypeReference, "valueTypeReference is null"); @SuppressWarnings("serial") Type javaType = new TypeToken<Map<K, V>>() { }.where(new TypeParameter<K>() { }, (TypeToken<K>) TypeToken.of(keyTypeReference.getJavaType())).where(new TypeParameter<V>() { }, (TypeToken<V>) TypeToken.of(valueTypeReference.getJavaType())).getType(); return new ThriftType(ThriftProtocolType.MAP, javaType, keyTypeReference, valueTypeReference, null); }
From source file:edu.washington.cs.cupid.wizards.internal.SetGetter.java
@Override public TypeToken<Set<V>> getOutputType() { return new TypeToken<Set<V>>(getClass()) { }.where(new TypeParameter<V>() { }, result);//w w w . ja v a 2s.com }
From source file:org.jclouds.rest.config.BinderUtils.java
/** * /*from w w w.j av a 2s. co m*/ * @deprecated will be removed in jclouds 1.7, as async interfaces are no * longer supported. */ @Deprecated @SuppressWarnings({ "unchecked", "serial" }) private static <S, A> void bindHttpApiProvider(Binder binder, Class<S> sync, Class<A> async) { TypeToken<SyncToAsyncHttpApiProvider<S, A>> token = new TypeToken<SyncToAsyncHttpApiProvider<S, A>>() { }.where(new TypeParameter<S>() { }, sync).where(new TypeParameter<A>() { }, async); binder.bind(sync).toProvider(TypeLiteral.class.cast(TypeLiteral.get(token.getType()))); }
From source file:com.monits.volleyrequests.restsupport.RestResource.java
/** * Create a new instance of RestResource * * @param resource/*from w w w . j a va 2s . c om*/ * The resourcer that you want to access * @param clazz * The type of the object that the json represents * @throws MalformedURLException */ public RestResource(final String resource, final Class<T> clazz, final Gson gson) throws MalformedURLException { final URL url = new URL(resource); this.resource = url.getFile(); this.clazz = clazz; this.hostAndPort = prepareHostURL(url); this.gson = gson; this.listTypeToken = new TypeToken<List<T>>() { }.where(new TypeParameter<T>() { }, TypeToken.of(clazz)).getType(); }
From source file:io.airlift.json.JsonCodecFactory.java
public <K, V> JsonCodec<Map<K, V>> mapJsonCodec(Class<K> keyType, Class<V> valueType) { Preconditions.checkNotNull(keyType, "keyType is null"); Preconditions.checkNotNull(valueType, "valueType is null"); Type mapType = new TypeToken<Map<K, V>>() { }.where(new TypeParameter<K>() { }, keyType).where(new TypeParameter<V>() { }, valueType).getType();/*w w w. j a va2 s . co m*/ return new JsonCodec<>(createObjectMapper(), mapType); }
From source file:com.facebook.presto.server.smile.SmileCodecFactory.java
public <K, V> SmileCodec<Map<K, V>> mapSmileCodec(Class<K> keyType, SmileCodec<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.getTypeToken()).getType(); return new SmileCodec<>(createObjectMapper(), mapType); }