currencies = new EnumMap<>(Currenc" /> currencies = new EnumMap<>(Currenc" /> currencies = new EnumMap<>(Currenc"/>

How to deal with Unsafe null type conversion

420 views Asked by At

I have a part of a code where "Currencies" is Enum and "Currency" is Entity:

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

But Eclipse generates a warning:

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>'

What is the right way to handle it? Should I wrap my map with Optional? Is it mandatory? Should I ignore the warning as I know there will be no null case?

0

There are 0 answers