@Override
@SuppressWarnings("unchecked")
public <K, V> Map<K, V> getMap(int i, Class<K> keysClass, Class<V> valuesClass) {
DataType type = getType(i);
if (type.getName() != DataType.Name.MAP)
throw new InvalidTypeException(String.format("Column %s is not of map type", getName(i)));
Class<?> expectedKeysClass = type.getTypeArguments().get(0).getName().javaType;
Class<?> expectedValuesClass = type.getTypeArguments().get(1).getName().javaType;
if (!keysClass.isAssignableFrom(expectedKeysClass) || !valuesClass.isAssignableFrom(expectedValuesClass))
throw new InvalidTypeException(String.format("Column %s is a map of %s->%s (CQL type %s), cannot be retrieve as a map of %s->%s", getName(i), expectedKeysClass, expectedValuesClass, type, keysClass, valuesClass));
ByteBuffer value = getValue(i);
if (value == null)
return Collections.<K, V>emptyMap();