Esempio n. 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;
 }
Esempio n. 2
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);
     }
   }
 }
Esempio n. 3
0
 private <T> void registerSerializer(Serializer<T> serializer, Type type) {
   if (serializersMap.containsKey(type))
     throw new IllegalStateException(
         "Can not register serializer "
             + serializer.getClass()
             + ". A custom serializer is already registered for type "
             + type);
   serializersMap.put(type, serializer);
 }