@SuppressWarnings("rawtypes")
public void instantiateCollection(Object obj, HColumn<String, byte[]> col,
PropertyMappingDefinition md) {
CollectionInfoColValue colValue = parseCollectionInfoColValue(col.getValue());
try {
Collection<?> collObj;
Class clazz = Class.forName(colValue.getCollTypeName());
if (ArrayList.class.isAssignableFrom(clazz)) {
Constructor<ArrayList> cons = ArrayList.class.getConstructor(int.class);
collObj = cons.newInstance(colValue.getSize());
} else {
collObj = (Collection<?>) clazz.newInstance();
}
PropertyDescriptor pd = md.getPropDesc();
if (null == pd.getWriteMethod()) {
throw new RuntimeException("property, " + pd.getName()
+ ", does not have a setter and therefore cannot be set");
}
pd.getWriteMethod().invoke(obj, collObj);
} catch (Throwable e) {
throw new HectorObjectMapperException("exception while instantiating Collection type, "
+ colValue.getCollTypeName(), e);
}
}