How do I get the class of java.lang.Enum in scala?

I am new to Scala and I am converting some Java code to Scala that uses the Jackson library to handle JSON serialization. I ran into a problem in a Jackson SimpleModule implementation.

In Java, I would do this:

 addSerializer(Enum.class, new LowerEnumSerializer());

I thought it would be as easy as doing this in Scala:

addSerializer(classOf[Enum], new LowerEnumSerializer())

However, my compiler is complaining:

scala: class Enum takes type parameters addSerializer(classOf[Enum], new LowerEnumSerializer())

I am guessing that this is because Java's Enum looks like:

public abstract class Enum<E extends Enum<E>>

Any ideas?

EDIT

I can't use classOf[Enum[_]] because the addSerializer method looks like this:

public <T> SimpleModule addSerializer(Class<? extends T> type, JsonSerializer<T> ser)

EDIT 2 I can't use classOf[Enum[_ <: Enum[_]], I get:

Type mismatch, expected: JsonSerializer[_], actual: Class[Enum[_ <: Enum[_]]

JsonSerializer looks like:

public class LowerEnumSerializer extends StdScalarSerializer<Enum>

Answers


How about:

classOf[Enum[T] forSome { type T <: Enum[T] }]

Need Your Help

Errors while performing a user migration

mysql ruby-on-rails ruby-on-rails-3 devise rails-migrations

I am trying to implement the Devise authentication library and also add columns that I may need to use that are particular to my own application.

How to let user use “sqrt()” + input to find square root of input?

python math input sqrt square-root

I am still learning python so please be nice :) I want to let the user to do something like this:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.