0

我有一部分代码,其中“货币”是枚举,“货币”是实体:

public final Map<Currencies, Currency> currencies = new EnumMap<>(Currencies.class);

但是 Eclipse 会生成一个警告:

Unsafe null type conversion (type annotations):
The value of type '@NonNull EnumMap<TestDataServiceImpl.@NonNull Currencies,Currency>'
is made accessible using the less-annotated type 'Map<TestDataServiceImpl.Currencies,Currency>',
corresponding supertype is 'Map<TestDataServiceImpl.@NonNull Currencies,Currency>'

处理它的正确方法是什么?我应该用 Optional 包裹我的地图吗?它是强制性的吗?我应该忽略警告,因为我知道不会有 null 案例吗?

4

0 回答 0