In regards to your "very dodgy pseudo code" you would need to use the instanceof operator and then cast the object to the subclass.
Type: Posts; User: Junky
In regards to your "very dodgy pseudo code" you would need to use the instanceof operator and then cast the object to the subclass.