java - How to instantiate a generic class -
i thought understood how use .class
, class<>
guess not. below super(approvalworkstation.class
not being mapped constructor. how can sure i'm passing class reference base workstationrequest
can instantiate it?
public class approvalworkstation extends workstation { public approvalworkstation(workstationentity entity) { super(entity); } } public class workstationrequest extends com.production.socket.request.workstationrequest { public workstationrequest() { super(approvalworkstation.class); //unable map constructor } }
this base workstationrequest
that's extended above
public class workstationrequest { private class<workstation> workstationclass; public void workstationrequest(class<workstation> workstationclass) { this.workstationclass = workstationclass; }
update
i'm sorry confusion, constructor has class<workstation>
, not workstation
had.
in order able pass both workstation
class , it's child classes should change definition of workstationrequest
following:
public class workstationrequest { private class<? extends workstation> workstationclass; public workstationrequest(class<? extends workstation> workstationclass) { this.workstationclass = workstationclass; } }
Comments
Post a Comment