Using a generic class for multiple compatible types