Adding various entities inheriting from an abstract class - Java Spring

I have an abstract class "Person". I also have classes that inherit from this class, e.g. "Student", "Employee".
How to properly write the PersonService and PersonController classes so that they have one endpoint that will always work even if I add a new class, e.g. "Retirement"?

I have an abstract class "Person". I also have classes that inherit from this class, e.g. "Student", "Employee".
How to properly write the PersonService and PersonController classes so that they have one endpoint that will always work even if I add a new class, e.g. "Retirement"?

Show original content

2 users upvote it!

2 answers