I'm trying to do the following to avoid an unchecked cast later on:
Code:
Set<Entry<String, ? extends SerializableForLayout>> set =
layoutObjectList.entrySet();
Error:
Type mismatch: cannot convert from Set<Map.Entry<String,capture#2-of ?
extends SerializableForLayout>>
to Set<Map.Entry<String,? extends SerializableForLayout>>
Whole Code:
public void loadLayoutList(ArrayList<SerializableForLayout> preparedList,
ConcurrentHashMap<String, ? extends SerializableForLayout> layoutObjectList
)
{
SerializableForLayout t;
if (layoutObjectList == null)return;
Set<?> set = layoutObjectList.entrySet();
Iterator<?> itTags = set.iterator();
Entry<String, SerializableForLayout> entry;
while (itTags.hasNext()) {
entry = (Entry<String, SerializableForLayout>) itTags.next();
t = entry.getValue();
addForSerializableLayouts(t,preparedList);
}
Collections.sort(preparedList, ApplicationsSort.LayoutWeightComparator);
}
This works:
Set<?> set = layoutObjectList.entrySet();
But there is a warning:
Forced to suppress an unchecked cast on the line:
entry = (Entry<String, SerializableForLayout>) itTags.next();
How do I do this without needing to suppress?