Пример #1
0
 public GensonBuilder withSerializers(Serializer<?>... serializer) {
   for (Serializer<?> s : serializer) {
     Type typeOfConverter =
         TypeUtil.typeOf(0, TypeUtil.lookupGenericType(Serializer.class, s.getClass()));
     typeOfConverter = TypeUtil.expandType(typeOfConverter, s.getClass());
     registerSerializer(s, typeOfConverter);
   }
   return this;
 }
Пример #2
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;
 }
Пример #3
0
 /**
  * Registers converters mapping them to their corresponding parameterized type.
  *
  * @param converter
  * @return a reference to this builder.
  */
 public GensonBuilder withConverters(Converter<?>... converter) {
   for (Converter<?> c : converter) {
     Type typeOfConverter =
         TypeUtil.typeOf(0, TypeUtil.lookupGenericType(Converter.class, c.getClass()));
     typeOfConverter = TypeUtil.expandType(typeOfConverter, c.getClass());
     registerConverter(c, typeOfConverter);
   }
   return this;
 }
Пример #4
0
 private void addDefaultSerializers(List<? extends Serializer<?>> serializers) {
   if (serializers != null) {
     for (Serializer<?> serializer : serializers) {
       Type typeOfConverter =
           TypeUtil.typeOf(0, TypeUtil.lookupGenericType(Serializer.class, serializer.getClass()));
       typeOfConverter = TypeUtil.expandType(typeOfConverter, serializer.getClass());
       if (!serializersMap.containsKey(typeOfConverter))
         serializersMap.put(typeOfConverter, serializer);
     }
   }
 }
Пример #5
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);
     }
   }
 }