I am building an app in java on play 2.2.
I have a java enum as a parameter in a function that I use in routes.
This is my enum class. I searched around and found out I need to implements QueryStringBindable to use it in routes.
public enum Something implements QueryStringBindable<Something> {
a,
b,
c;
@Override
public F.Option<ClientStatus> bind(String key, Map<String, String[]> params) {
String[] arr = params.get(key);
if (arr == null || arr.length == 0) {
return F.Option.None();
} else {
Something status = Something.valueOf(arr[0]);
return F.Option.Some(status);
}
}
@Override
public String unbind(String key) {
return null;
}
@Override
public String javascriptUnbind() {
return null;
}
}
Yet I tried in my routes:
GET /someurl controllers.Application.function(status: util.enums.Something)
But it returns bad request with error message as:
For request 'GET /someurl' [util.enums.Something]
I googled and didn't find any answer working in my case. Did I miss something or play doesn't support binding enums?