@SuppressWarnings("unchecked")
private <T> void addAnonymousProperties(T obj, CFMappingDef<T> cfMapDef,
Map<String, HColumn<String, byte[]>> colSet) throws IllegalArgumentException,
IllegalAccessException, InvocationTargetException {
Method meth = cfMapDef.getAnonymousPropertyGetHandler();
if (null == meth) {
return;
}
Collection<Entry<String, Object>> propColl = (Collection<Entry<String, Object>>) meth.invoke(
obj, (Object[]) null);
if (null == propColl || propColl.isEmpty()) {
return;
}
for (Entry<String, Object> entry : propColl) {
if (!(entry.getKey() instanceof String)
|| !entry.getValue().getClass().equals(cfMapDef.getAnonymousValueType())) {
throw new HectorObjectMapperException("Class, " + cfMapDef.getRealClass()
+ ", anonymous properties must have entry.key of type, " + String.class.getName()
+ ", and entry.value of type, " + cfMapDef.getAnonymousValueType().getName()
+ ", to properly map to Cassandra column name/value");
}
}
for (Entry<String, Object> entry : propColl) {
colSet.put(
entry.getKey(),
HFactory.createColumn(entry.getKey(),
cfMapDef.getAnonymousValueSerializer().toBytes(entry.getValue()),
StringSerializer.get(), BytesArraySerializer.get()));
}
}