use of com.google.common.reflect.TypeParameter in project core-java by SpineEventEngine.
the class Types method listTypeOf.
/**
* Creates the parametrized {@code Type} of the list.
*
* @param elementClass the class of the list elements
* @param <T> the type of the elements in this list
* @return the type of the list
*/
public static <T> Type listTypeOf(Class<T> elementClass) {
checkNotNull(elementClass);
final Type type = new TypeToken<List<T>>() {
}.where(new TypeParameter<T>() {
}, elementClass).getType();
return type;
}
use of com.google.common.reflect.TypeParameter in project airlift by airlift.
the class JsonCodecFactory method mapJsonCodec.
public <K, V> JsonCodec<Map<K, V>> mapJsonCodec(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();
return new JsonCodec<>(createObjectMapper(), mapType);
}
use of com.google.common.reflect.TypeParameter in project airlift by airlift.
the class JsonCodecFactory method listJsonCodec.
public <T> JsonCodec<List<T>> listJsonCodec(Class<T> type) {
requireNonNull(type, "type is null");
Type listType = new TypeToken<List<T>>() {
}.where(new TypeParameter<T>() {
}, type).getType();
return new JsonCodec<>(createObjectMapper(), listType);
}
use of com.google.common.reflect.TypeParameter in project airlift by airlift.
the class JsonCodecFactory method listJsonCodec.
public <T> JsonCodec<List<T>> listJsonCodec(JsonCodec<T> type) {
requireNonNull(type, "type is null");
Type listType = new TypeToken<List<T>>() {
}.where(new TypeParameter<T>() {
}, type.getTypeToken()).getType();
return new JsonCodec<>(createObjectMapper(), listType);
}
use of com.google.common.reflect.TypeParameter in project airlift by airlift.
the class JsonCodecFactory method mapJsonCodec.
public <K, V> JsonCodec<Map<K, V>> mapJsonCodec(Class<K> keyType, JsonCodec<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 JsonCodec<>(createObjectMapper(), mapType);
}
Aggregations