List of usage examples for org.apache.cassandra.db.marshal SetType getSerializer
public SetSerializer<T> getSerializer()
From source file:com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.java
License:Apache License
/** * Sets the element collection set./*from ww w. j a va2 s. c o m*/ * * @param setType * 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 setElementCollectionSet(SetType setType, ByteBuffer thriftColumnValue, Object entity, Field field, MetamodelImpl metaModel, Class embeddedClass, boolean useNativeProtocol2) { SetSerializer setSerializer = setType.getSerializer(); Collection outputCollection = new ArrayList(); if (useNativeProtocol2) { outputCollection.addAll((Collection) setSerializer.deserializeForNativeProtocol(thriftColumnValue, 2)); } else { outputCollection.addAll((Collection) setSerializer.deserialize(thriftColumnValue)); } UserType usertype = (UserType) setType.getElementsType(); Collection result = new HashSet(); 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; }