Is there a convenience method available in the java standard libraries to check whether all possible keys in an EnumMap are mapped to a value?
I can write my own method like:
public static <T extends Enum<T>> boolean areAllValuesMapped(EnumMap<T, ?> map, Class<T> enumClass)
{
return map.keySet().equals(EnumSet.allOf(enumClass));
}
But then I'm repeating the Class parameter (already given in the EnumMap constructor) as well as creating throwaway KeySet and EnumSet objects. EnumMap should have enough information to do this efficiently as an internal operation.