Easely serialize objects of same type in a file in java