Пример #1
0
 public GensonBuilder withDeserializers(Deserializer<?>... deserializer) {
   for (Deserializer<?> d : deserializer) {
     Type typeOfConverter =
         TypeUtil.typeOf(0, TypeUtil.lookupGenericType(Deserializer.class, d.getClass()));
     typeOfConverter = TypeUtil.expandType(typeOfConverter, d.getClass());
     registerDeserializer(d, typeOfConverter);
   }
   return this;
 }
Пример #2
0
 private void addDefaultDeserializers(List<? extends Deserializer<?>> deserializers) {
   if (deserializers != null) {
     for (Deserializer<?> deserializer : deserializers) {
       Type typeOfConverter =
           TypeUtil.typeOf(
               0, TypeUtil.lookupGenericType(Deserializer.class, deserializer.getClass()));
       typeOfConverter = TypeUtil.expandType(typeOfConverter, deserializer.getClass());
       if (!deserializersMap.containsKey(typeOfConverter))
         deserializersMap.put(typeOfConverter, deserializer);
     }
   }
 }
Пример #3
0
 private <T> void registerDeserializer(Deserializer<T> deserializer, Type type) {
   if (deserializersMap.containsKey(type))
     throw new IllegalStateException(
         "Can not register deserializer "
             + deserializer.getClass()
             + ". A custom deserializer is already registered for type "
             + type);
   deserializersMap.put(type, deserializer);
 }