I prefer # 2. It is clearer what happens and is typical at compile time (I prefer that there are as many errors as possible during compilation, as opposed to those that occur at runtime ... In general, I like when nothing happens).
Edit:
Well, there are two ways that I can see ... I think it depends on what you will use:
class Account { private Map<Region, TradeCollection> tradesByRegion; } class TradeCollection { private Map<Instrument, Trade> tradesByInstrument; }
or
class Account<R extends Region, I extends Instrument, T extends Trade, C extends TradeCollection<I, T>> { private Map<R, C> tradesByRegion; } class TradeCollection<I extends Instrument, T extends Trade> { private Map<I, T> tradesByInstrument; }
Tofubeer
source share