私はspring 4
RESTを使用しています。
私にはベースがclass
あり、他の多くclass
は同じように拡張しています。たとえば、Employee はベースclass
であり、他のクラス hr、engineer、trainer などは従業員を拡張します。
REST API
さまざまなタイプの従業員を作成するために作成する必要があります。あらゆるタイプの従業員を受け入れるものですinterface
。サブタイプごとにPOST
異なるものを作成することはできません。interface
ベースから、サブタイプが何であるかを知っています。
@RequestMapping(value= "/test/{employeeType}", method = RequestMethod.POST)
public void createEmp(@RequestBody Employee employee){
//If type is HR, I want to cast to HR type
//Is there any way we can take generic object in spring rest and then manage internally ?
}