List of usage examples for org.apache.cassandra.serializers ListSerializer deserializeForNativeProtocol
public List<T> deserializeForNativeProtocol(ByteBuffer bytes, ProtocolVersion version)
From source file:com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.java
License:Apache License
/** * Sets the element collection list.//from w w w . java2 s. c o m * * @param listType * the cql column metadata * @param thriftColumnValue * the thrift column value * @param entity * the entity * @param field * the field * @param metaModel * the meta model * @param embeddedObject * the embedded object * @return the object */ private Object setElementCollectionList(ListType listType, ByteBuffer thriftColumnValue, Object entity, Field field, MetamodelImpl metaModel, Class embeddedClass, boolean useNativeProtocol2) { ListSerializer listSerializer = listType.getSerializer(); Collection outputCollection = new ArrayList(); if (useNativeProtocol2) { outputCollection.addAll((Collection) listSerializer.deserializeForNativeProtocol(thriftColumnValue, 2)); } else { outputCollection.addAll((Collection) listSerializer.deserialize(thriftColumnValue)); } UserType usertype = (UserType) listType.getElementsType(); Collection result = new ArrayList(); Iterator collectionItems = outputCollection.iterator(); while (collectionItems.hasNext()) { Object embeddedObject = KunderaCoreUtils.createNewInstance(embeddedClass); Object value = populateEmbeddedRecursive((ByteBuffer) collectionItems.next(), usertype.allTypes(), usertype.fieldNames(), embeddedObject, metaModel); result.add(value); } PropertyAccessorHelper.set(entity, field, result); return entity; }