Java Convert Object Dynamic to Entity
<p>I've created a function which requires a Parameter of type Object.</p>

<pre><code>public void myFunction(Object obj){

}
</code></pre>

<p>Now I have 20 different Entities so the given Object Parameter can be of the type of this 20 entities.
I'm searching for a way to cast this Object in the right Entity-type and get all values of it.</p>

<p>Right now I get the right type with this but I don't know how to cast it to this type and the fields are always 0.</p>

<pre><code>System.out.println("Class: " + obj.getClass());//Gives me the right type
System.out.println("Field: " + obj.getClass().getFields().length);//Length is always 0
</code></pre>