Search in sources :

Example 1 with TypeParameter

use of io.cdap.cdap.internal.guava.reflect.TypeParameter in project cdap by caskdata.

the class AbstractSpecificationCodec method deserializeMap.

protected final <V> Map<String, V> deserializeMap(JsonElement json, JsonDeserializationContext context, Class<V> valueType) {
    Type type = new TypeToken<Map<String, V>>() {
    }.where(new TypeParameter<V>() {
    }, valueType).getType();
    Map<String, V> map = context.deserialize(json, type);
    return map == null ? Collections.<String, V>emptyMap() : map;
}
Also used : Type(java.lang.reflect.Type) TypeParameter(io.cdap.cdap.internal.guava.reflect.TypeParameter) TypeToken(io.cdap.cdap.internal.guava.reflect.TypeToken)

Example 2 with TypeParameter

use of io.cdap.cdap.internal.guava.reflect.TypeParameter in project cdap by caskdata.

the class AbstractSpecificationCodec method deserializeSet.

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();
    Set<V> set = context.deserialize(json, type);
    return set == null ? Collections.<V>emptySet() : set;
}
Also used : Type(java.lang.reflect.Type) TypeParameter(io.cdap.cdap.internal.guava.reflect.TypeParameter) TypeToken(io.cdap.cdap.internal.guava.reflect.TypeToken)

Example 3 with TypeParameter

use of io.cdap.cdap.internal.guava.reflect.TypeParameter in project cdap by caskdata.

the class AbstractSpecificationCodec method deserializeList.

protected final <V> List<V> deserializeList(JsonElement json, JsonDeserializationContext context, Class<V> valueType) {
    Type type = new TypeToken<List<V>>() {
    }.where(new TypeParameter<V>() {
    }, valueType).getType();
    List<V> list = context.deserialize(json, type);
    return list == null ? Collections.<V>emptyList() : list;
}
Also used : Type(java.lang.reflect.Type) TypeParameter(io.cdap.cdap.internal.guava.reflect.TypeParameter) TypeToken(io.cdap.cdap.internal.guava.reflect.TypeToken)

Aggregations

TypeParameter (io.cdap.cdap.internal.guava.reflect.TypeParameter)3 TypeToken (io.cdap.cdap.internal.guava.reflect.TypeToken)3 Type (java.lang.reflect.Type)3