I have ArrayList child like this:
public class SomeList<T> extends ArrayList<T> {
private Class<T> clazz;
public SomeList(Class<T> clazz) {
this.clazz = clazz;
}
public boolean add(T t) {
return t != null ? super.add(t) : false;
}
public Class getGenericClass() {
return this.clazz;
}
}
I have no option but to use it (backward compatibility), i can't modify it and I need to deserialize it in spring controller, e.g.:
@RequestMapping(value = "/somethingHappens", method = {RequestMethod.POST})
@ResponseBody
public ServiceResult somethingHappens(@RequestBody SomeList<SomeObject> someObjects) {
return ResponseUtils.createOkJsonResponse(someService.getSomethingElse(someObjects));
}
I don't need to have clazz nor received, nor deserialized, I just want to deserialize this SomeList the same way as it was ArrayList, but it is not possible at this moment because it has no default constructor.
Can I use MixIns somehow? Can I use custom deserializer and somehow tell him "just do it same way as ArrayList"?