Java Code Examples for com.google.common.reflect.TypeToken#where()
The following examples show how to use
com.google.common.reflect.TypeToken#where() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResolvableType.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
/** * Fully resolve this type by substituting this type's formal type * parameters with the given actual type arguments */ public TypeLiteral<T> with(TypeArgument<?>... arguments) { TypeToken<T> token = Types.toToken(this); for(TypeArgument arg : arguments) { token = token.where(arg, arg.actual()); } return Types.assertFullySpecified(Types.toLiteral(token)); }
Example 2
Source File: Types.java From riptide with MIT License | 5 votes |
@SuppressWarnings("serial") public static <T> TypeToken<List<T>> listOf(final TypeToken<T> entityType) { final TypeToken<List<T>> listType = new TypeToken<List<T>>() { // nothing to implement! }; final TypeParameter<T> elementType = new TypeParameter<T>() { // nothing to implement! }; return listType.where(elementType, entityType); }
Example 3
Source File: Types.java From riptide with MIT License | 5 votes |
public static <T> TypeToken<ResponseEntity<T>> responseEntityOf(final TypeToken<T> entityType) { final TypeToken<ResponseEntity<T>> responseEntityType = new TypeToken<ResponseEntity<T>>() { // nothing to implement! }; final TypeParameter<T> elementType = new TypeParameter<T>() { // nothing to implement! }; return responseEntityType.where(elementType, entityType); }
Example 4
Source File: Streams.java From riptide with MIT License | 5 votes |
/** * Creates specialized stream {@link TypeToken type token} for the given element {@link TypeToken type token}. Used * to declare the expected stream response {@link TypeToken type token} in Riptide org.zalando.riptide.Route route} as follows: * * <pre> * on(...).call(streamOf(resultTypeToken),...) * </pre> * * @param <T> generic stream element type * @param type element token type. * @return stream token type. */ @SuppressWarnings("serial") public static <T> TypeToken<Stream<T>> streamOf(final TypeToken<T> type) { final TypeToken<Stream<T>> streamType = new TypeToken<Stream<T>>() { // no overriding needed. }; final TypeParameter<T> elementType = new TypeParameter<T>() { // no overriding needed. }; return streamType.where(elementType, type); }