I'm new to Scala, and I'm converting some Java code to Scala, which uses the Jackson library to handle JSON serialization. I ran into a problem in implementing Jackson SimpleModule.
In Java, I would do the following:
addSerializer(Enum.class, new LowerEnumSerializer());
I thought it would be as easy as doing it in Scala:
addSerializer(classOf[Enum], new LowerEnumSerializer())
However, my compiler complains:
scala: the Enum class accepts parameters of type addSerializer (classOf [Enum], the new LowerEnumSerializer ())
I assume this is because the Java Enum looks like this:
public abstract class Enum<E extends Enum<E>>
Any ideas?
EDIT
I cannot use classOf [Enum [_]] because the addSerializer method looks like this:
public <T> SimpleModule addSerializer(Class<? extends T> type, JsonSerializer<T> ser)
EDIT 2 I cannot use classOf [Enum [_ <: Enum [_]], I get:
Type mismatch, expected: JsonSerializer[_], actual: Class[Enum[_ <: Enum[_]]
JsonSerializer looks like this:
public class LowerEnumSerializer extends StdScalarSerializer<Enum>