Example usage for com.google.common.reflect TypeParameter TypeParameter

List of usage examples for com.google.common.reflect TypeParameter TypeParameter

Introduction

In this page you can find the example usage for com.google.common.reflect TypeParameter TypeParameter.

Prototype

protected TypeParameter() 

Source Link

Usage

From source file:org.lanternpowered.server.inject.LanternModule.java

private <T> void bindService(Class<T> clazz) {
    final TypeToken<Service<T>> token = new TypeToken<Service<T>>() {
    }.where(new TypeParameter<T>() {
    }, clazz);// ww  w.ja va2 s  . com
    final TypeLiteral literal = TypeLiteral.get(token.getType());
    //noinspection unchecked
    bindAndExpose(literal).toProvider(ServiceObjectProvider.class);
}

From source file:org.lanternpowered.server.data.key.LanternKeyFactory.java

public static <E> Key<WeightedCollectionValue<E>> makeWeightedCollectionKey(TypeToken<E> elementToken,
        DataQuery query, String id, String name) {
    final TypeToken<WeightedTable<E>> elementToken0 = new TypeToken<WeightedTable<E>>() {
    }.where(new TypeParameter<E>() {
    }, elementToken);//from ww w. j  av a2 s  .  c om
    final TypeToken<WeightedCollectionValue<E>> valueToken = new TypeToken<WeightedCollectionValue<E>>() {
    }.where(new TypeParameter<E>() {
    }, elementToken);
    return makeSingleKey(elementToken0, valueToken, query, id, name);
}

From source file:com.viadeo.kasper.client.KasperClient.java

<P extends QueryResult> QueryResponse<P> handleQueryResponse(final ClientResponse clientResponse,
        final TypeToken<P> mapTo) {

    if (checkNotNull(clientResponse).getType().isCompatible(MediaType.APPLICATION_JSON_TYPE)) {

        final TypeToken mappedType = new TypeToken<QueryResponse<P>>() {
        }.where(new TypeParameter<P>() {
        }, checkNotNull(mapTo));/*from   w ww.j  ava2 s  . c o  m*/

        final QueryResponse<P> response = clientResponse
                .getEntity(new GenericType<QueryResponse<P>>(mappedType.getType()));

        return new HTTPQueryResponse<P>(safeStatusFromCode(clientResponse.getStatus()), response);

    } else {

        return new HTTPQueryResponse<P>(safeStatusFromCode(clientResponse.getStatus()),
                new KasperReason(CoreReasonCode.UNKNOWN_REASON,
                        "Response from platform uses an unsupported type: " + clientResponse.getType()));

    }
}

From source file:co.cask.tigon.internal.io.DatumWriterGenerator.java

private <T> TypeToken<DatumWriter<T>> getInterfaceType(TypeToken<T> type) {
    return new TypeToken<DatumWriter<T>>() {
    }.where(new TypeParameter<T>() {
    }, type);//from  ww w .  j a  v  a  2 s  .com
}

From source file:co.cask.tigon.internal.io.DatumWriterGenerator.java

private <T> TypeToken<T[]> getArrayType(TypeToken<T> type) {
    return new TypeToken<T[]>() {
    }.where(new TypeParameter<T>() {
    }, type);/*from ww w . j  av a2 s.  c  o  m*/
}