I have many types of entities, each type has a lot of `if instanceof Spider` (for example ) then do this in the game code... Now I got to the part where I want to save each type.

They all are based on the same class, Entity but implement some of their own methods.
When I save them, lets say for now I just want their position and their health.

So I do write position the write health, to a file with all the entities. 

Now here is the problem, When I want to load it, How will I know it's a spider and then create a Spider instance? 

An easy fix is to create toString method then writing it before the position and health. But the problem with this is that when I load I will have to have this big switch statement for each type and I will have to manually add the case for a new type that I create. This is not very mod friendly.

What would be a way to read a name of a class and then create an instance of that class without having a big switch case?