/** Sets the serializer factory to use when no {@link #addDefaultSerializer(Class, Class) default serializers} match an object's * type. Default is {@link ReflectionSerializerFactory} with {@link FieldSerializer}. * @see #newDefaultSerializer(Class) */ public void setDefaultSerializer (SerializerFactory serializer) { if (serializer == null) throw new IllegalArgumentException("serializer cannot be null."); defaultSerializer = serializer; }
public void addDefaultSerializer (Class type, SerializerFactory serializerFactory) { if (type == null) throw new IllegalArgumentException("type cannot be null."); if (serializerFactory == null) throw new IllegalArgumentException("serializerFactory cannot be null."); DefaultSerializerEntry entry = new DefaultSerializerEntry(type, serializerFactory); defaultSerializers.add(defaultSerializers.size() - lowPriorityDefaultSerializerCount, entry); }
DefaultSerializerEntry (Class type, SerializerFactory serializerFactory) { this.type = type; this.serializerFactory = serializerFactory; }