private static void setBasicValue(Object entity, Field member, String columnName, UDTValue row,
            CassandraType dataType, MetamodelImpl metamodel)
    {
    	if(row.isNull(columnName)){
        	return;
        }
        Object retVal = null;
        switch (dataType)
        {
        case BYTES:
            // case CUSTOM:
            retVal = row.getBytes(columnName);
            if (retVal != null)
            {
                setFieldValue(entity, member, ((ByteBuffer) retVal).array());
            }
            break;

        case BOOLEAN:
            retVal = row.getBool(columnName);
            setFieldValue(entity, member, retVal);
            break;

        case BIGINT:
            // bigints in embeddables and element collections are mapped/defined
            // by Long
        case LONG:
        case COUNTER:
            retVal = row.getLong(columnName);
            setFieldValue(entity, member, retVal);
            break;

        case DECIMAL:
            retVal = row.getDecimal(columnName);
            setFieldValue(entity, member, retVal);
            break;

        case DOUBLE:
            retVal = row.getDouble(columnName);
            setFieldValue(entity, member, retVal);
            break;

        case FLOAT:
            retVal = row.getFloat(columnName);
            setFieldValue(entity, member, retVal);
            break;

        case INET:
            retVal = row.getInet(columnName);
            setFieldValue(entity, member, retVal);
            break;

        case INT:
            retVal = row.getInt(columnName);
            retVal = setIntValue(member, retVal);
            setFieldValue(entity, member, retVal);
            break;

        case ASCII:
        case STRING:
        case CHARACTER:
            try
            {
                row.getBytes(columnName);
            }
            catch (Exception e)
            {
                // do nothing
            }
            retVal = row.getString(columnName);
            retVal = setTextValue(entity, member, retVal);
            setFieldValue(entity, member, retVal);
            break;

        case TIMESTAMP:
            retVal = row.getTimestamp(columnName);
            if (retVal != null && member != null)
                retVal = CassandraDataTranslator.decompose(member.getType(),
                        ByteBufferUtil.bytes(((Date) retVal).getTime()).array(), true);
            setFieldValue(entity, member, retVal);
            break;

        case UUID:
            // case TIMEUUID:
            retVal = row.getUUID(columnName);
            setFieldValue(entity, member, retVal);
            break;

        case LIST:
            Class listAttributeTypeClass = PropertyAccessorHelper.getGenericClass(member);
            Class listClazz = null;
            boolean isElementCollectionList = false;
            if (listAttributeTypeClass.isAssignableFrom(byte[].class))
            {

                listClazz = ByteBuffer.class;
            }
            else if (listAttributeTypeClass.isAnnotationPresent(Embeddable.class))
            {
                isElementCollectionList = true;
                listClazz = UDTValue.class;
            }
            else
            {
                listClazz = listAttributeTypeClass;
            }
            retVal = row.getList(columnName, listClazz);
            Collection resultList = new ArrayList();
            if (isElementCollectionList)
            {
                Iterator collectionItems = ((Collection) retVal).iterator();
                while (collectionItems.hasNext())
                {
                    resultList.add(setUDTValue(entity, listAttributeTypeClass, (UDTValue) collectionItems.next(),
                            metamodel));
                }
            }

            if (retVal != null && !((List) retVal).isEmpty() && !isElementCollectionList)
            {
                if (listAttributeTypeClass.isAssignableFrom(byte[].class))
                {
                    setFieldValue(entity, member, CassandraDataTranslator.marshalCollection(BytesType.class,
                            (Collection) retVal, listAttributeTypeClass, ArrayList.class));
                }
                else
                {
                    Iterator collectionItems = ((Collection) retVal).iterator();
                    while (collectionItems.hasNext())
                    {
                        resultList.add(collectionItems.next());
                    }
                    setFieldValue(entity, member, resultList);
                }

            }
            else if (retVal != null && !((Collection) retVal).isEmpty())
            {
                setFieldValue(entity, member, resultList);
            }
            break;

        case SET:
            Class setAttributeTypeClass = PropertyAccessorHelper.getGenericClass(member);
            Class setClazz = null;
            boolean isElementCollectionSet = false;
            if (setAttributeTypeClass.isAssignableFrom(byte[].class))
            {

                setClazz = ByteBuffer.class;
            }
            else if (setAttributeTypeClass.isAnnotationPresent(Embeddable.class))
            {
                isElementCollectionSet = true;
                setClazz = UDTValue.class;
            }
            else
            {
                setClazz = setAttributeTypeClass;
            }
            retVal = row.getSet(columnName, setClazz);
            Collection resultSet = new HashSet();
            if (isElementCollectionSet)
            {
                Iterator collectionItems = ((Collection) retVal).iterator();
                while (collectionItems.hasNext())
                {
                    resultSet.add(setUDTValue(entity, setAttributeTypeClass, (UDTValue) collectionItems.next(),
                            metamodel));
                }
            }

            if (retVal != null && !((Set) retVal).isEmpty() && !isElementCollectionSet)
            {
                if (setAttributeTypeClass.isAssignableFrom(byte[].class))
                {
                    setFieldValue(entity, member, CassandraDataTranslator.marshalCollection(BytesType.class,
                            (Collection) retVal, setAttributeTypeClass, HashSet.class));
                }
                else
                {
                    Iterator collectionItems = ((Collection) retVal).iterator();
                    while (collectionItems.hasNext())
                    {
                        resultSet.add(collectionItems.next());
                    }
                    setFieldValue(entity, member, resultSet);
                }
            }
            else if (retVal != null && !((Collection) retVal).isEmpty())
            {
                setFieldValue(entity, member, resultSet);
            }
            break;
        /*
         * ASCII, BIGINT, BLOB, BOOLEAN, COUNTER, DECIMAL, DOUBLE, FLOAT, INET,
         * INT, TEXT, TIMESTAMP, UUID, VARCHAR, VARINT, TIMEUUID, LIST, SET,
         * MAP, CUSTOM;
         */
        case MAP:
            List<Class<?>> mapGenericClasses = PropertyAccessorHelper.getGenericClasses(member);

            Class keyClass = CassandraValidationClassMapper.getValidationClassInstance(mapGenericClasses.get(0), true);
            Class valueClass = CassandraValidationClassMapper
                    .getValidationClassInstance(mapGenericClasses.get(1), true);
            Class mapValueClazz = null;
            boolean isElementCollectionMap = false;
            if (mapGenericClasses.get(1).isAssignableFrom(byte[].class))
            {

                mapValueClazz = ByteBuffer.class;
            }
            else if (mapGenericClasses.get(1).isAnnotationPresent(Embeddable.class))
            {
                isElementCollectionMap = true;
                mapValueClazz = UDTValue.class;
            }
            else
            {
                mapValueClazz = mapGenericClasses.get(1);
            }
            retVal = row.getMap(columnName, mapGenericClasses.get(0).isAssignableFrom(byte[].class) ? ByteBuffer.class
                    : mapGenericClasses.get(0), mapValueClazz);

            Map resultMap = new HashMap();

            if (isElementCollectionMap)
            {
                Iterator keys = ((Map) retVal).keySet().iterator();
                while (keys.hasNext())
                {
                    Object keyValue = keys.next();
                    resultMap.put(
                            keyValue,
                            setUDTValue(entity, mapGenericClasses.get(1), (UDTValue) ((Map) retVal).get(keyValue),
                                    metamodel));
                }
            }

            boolean isByteBuffer = mapGenericClasses.get(0).isAssignableFrom(byte[].class)
                    || mapGenericClasses.get(1).isAssignableFrom(byte[].class);

            // set the values.
            if (retVal != null && !((Map) retVal).isEmpty() && !isElementCollectionMap)
            {
                if (isByteBuffer)
                {
                    setFieldValue(entity, member,
                            CassandraDataTranslator.marshalMap(mapGenericClasses, keyClass, valueClass, (Map) retVal));
                }
                else
                {
                    Iterator keys = ((Map) retVal).keySet().iterator();
                    while (keys.hasNext())
                    {
                        Object keyValue = keys.next();
                        resultMap.put(keyValue, ((Map) retVal).get(keyValue));
                    }
                    setFieldValue(entity, member, resultMap);
                }
            }
            else if (retVal != null && !((Map) retVal).isEmpty())
            {
                setFieldValue(entity, member, resultMap);
            }
            break;
        }

    }
private static void setBasicValue ( Object entity , Field member , String columnName , UDTValue row , CassandraType dataType , MetamodelImpl metamodel ) { if ( row . isNull ( columnName ) ) { return ; } Object retVal = null ; switch ( dataType ) { case BYTES : retVal = row . getBytes ( columnName ) ; if ( retVal != null ) { setFieldValue ( entity , member , ( ( ByteBuffer ) retVal ) . array ( ) ) ; } break ; case BOOLEAN : retVal = row . getBool ( columnName ) ; setFieldValue ( entity , member , retVal ) ; break ; case BIGINT : case LONG : case COUNTER : retVal = row . getLong ( columnName ) ; setFieldValue ( entity , member , retVal ) ; break ; case DECIMAL : retVal = row . getDecimal ( columnName ) ; setFieldValue ( entity , member , retVal ) ; break ; case DOUBLE : retVal = row . getDouble ( columnName ) ; setFieldValue ( entity , member , retVal ) ; break ; case FLOAT : retVal = row . getFloat ( columnName ) ; setFieldValue ( entity , member , retVal ) ; break ; case INET : retVal = row . getInet ( columnName ) ; setFieldValue ( entity , member , retVal ) ; break ; case INT : retVal = row . getInt ( columnName ) ; retVal = setIntValue ( member , retVal ) ; setFieldValue ( entity , member , retVal ) ; break ; case ASCII : case STRING : case CHARACTER : try { row . getBytes ( columnName ) ; } catch ( Exception e ) { } retVal = row . getString ( columnName ) ; retVal = setTextValue ( entity , member , retVal ) ; setFieldValue ( entity , member , retVal ) ; break ; case TIMESTAMP : retVal = row . getTimestamp ( columnName ) ; if ( retVal != null && member != null ) retVal = CassandraDataTranslator . decompose ( member . getType ( ) , ByteBufferUtil . bytes ( ( ( Date ) retVal ) . getTime ( ) ) . array ( ) , true ) ; setFieldValue ( entity , member , retVal ) ; break ; case UUID : retVal = row . getUUID ( columnName ) ; setFieldValue ( entity , member , retVal ) ; break ; case LIST : Class listAttributeTypeClass = PropertyAccessorHelper . getGenericClass ( member ) ; Class listClazz = null ; boolean isElementCollectionList = false ; if ( listAttributeTypeClass . isAssignableFrom ( byte [ ] . class ) ) { listClazz = ByteBuffer . class ; } else if ( listAttributeTypeClass . isAnnotationPresent ( Embeddable . class ) ) { isElementCollectionList = true ; listClazz = UDTValue . class ; } else { listClazz = listAttributeTypeClass ; } retVal = row . getList ( columnName , listClazz ) ; Collection resultList = new ArrayList ( ) ; if ( isElementCollectionList ) { Iterator collectionItems = ( ( Collection ) retVal ) . iterator ( ) ; while ( collectionItems . hasNext ( ) ) { resultList . add ( setUDTValue ( entity , listAttributeTypeClass , ( UDTValue ) collectionItems . next ( ) , metamodel ) ) ; } } if ( retVal != null && ! ( ( List ) retVal ) . isEmpty ( ) && ! isElementCollectionList ) { if ( listAttributeTypeClass . isAssignableFrom ( byte [ ] . class ) ) { setFieldValue ( entity , member , CassandraDataTranslator . marshalCollection ( BytesType . class , ( Collection ) retVal , listAttributeTypeClass , ArrayList . class ) ) ; } else { Iterator collectionItems = ( ( Collection ) retVal ) . iterator ( ) ; while ( collectionItems . hasNext ( ) ) { resultList . add ( collectionItems . next ( ) ) ; } setFieldValue ( entity , member , resultList ) ; } } else if ( retVal != null && ! ( ( Collection ) retVal ) . isEmpty ( ) ) { setFieldValue ( entity , member , resultList ) ; } break ; case SET : Class setAttributeTypeClass = PropertyAccessorHelper . getGenericClass ( member ) ; Class setClazz = null ; boolean isElementCollectionSet = false ; if ( setAttributeTypeClass . isAssignableFrom ( byte [ ] . class ) ) { setClazz = ByteBuffer . class ; } else if ( setAttributeTypeClass . isAnnotationPresent ( Embeddable . class ) ) { isElementCollectionSet = true ; setClazz = UDTValue . class ; } else { setClazz = setAttributeTypeClass ; } retVal = row . getSet ( columnName , setClazz ) ; Collection resultSet = new HashSet ( ) ; if ( isElementCollectionSet ) { Iterator collectionItems = ( ( Collection ) retVal ) . iterator ( ) ; while ( collectionItems . hasNext ( ) ) { resultSet . add ( setUDTValue ( entity , setAttributeTypeClass , ( UDTValue ) collectionItems . next ( ) , metamodel ) ) ; } } if ( retVal != null && ! ( ( Set ) retVal ) . isEmpty ( ) && ! isElementCollectionSet ) { if ( setAttributeTypeClass . isAssignableFrom ( byte [ ] . class ) ) { setFieldValue ( entity , member , CassandraDataTranslator . marshalCollection ( BytesType . class , ( Collection ) retVal , setAttributeTypeClass , HashSet . class ) ) ; } else { Iterator collectionItems = ( ( Collection ) retVal ) . iterator ( ) ; while ( collectionItems . hasNext ( ) ) { resultSet . add ( collectionItems . next ( ) ) ; } setFieldValue ( entity , member , resultSet ) ; } } else if ( retVal != null && ! ( ( Collection ) retVal ) . isEmpty ( ) ) { setFieldValue ( entity , member , resultSet ) ; } break ; case MAP : List < Class < ? > > mapGenericClasses = PropertyAccessorHelper . getGenericClasses ( member ) ; Class keyClass = CassandraValidationClassMapper . getValidationClassInstance ( mapGenericClasses . get ( 0 ) , true ) ; Class valueClass = CassandraValidationClassMapper . getValidationClassInstance ( mapGenericClasses . get ( 1 ) , true ) ; Class mapValueClazz = null ; boolean isElementCollectionMap = false ; if ( mapGenericClasses . get ( 1 ) . isAssignableFrom ( byte [ ] . class ) ) { mapValueClazz = ByteBuffer . class ; } else if ( mapGenericClasses . get ( 1 ) . isAnnotationPresent ( Embeddable . class ) ) { isElementCollectionMap = true ; mapValueClazz = UDTValue . class ; } else { mapValueClazz = mapGenericClasses . get ( 1 ) ; } retVal = row . getMap ( columnName , mapGenericClasses . get ( 0 ) . isAssignableFrom ( byte [ ] . class ) ? ByteBuffer . class : mapGenericClasses . get ( 0 ) , mapValueClazz ) ; Map resultMap = new HashMap ( ) ; if ( isElementCollectionMap ) { Iterator keys = ( ( Map ) retVal ) . keySet ( ) . iterator ( ) ; while ( keys . hasNext ( ) ) { Object keyValue = keys . next ( ) ; resultMap . put ( keyValue , setUDTValue ( entity , mapGenericClasses . get ( 1 ) , ( UDTValue ) ( ( Map ) retVal ) . get ( keyValue ) , metamodel ) ) ; } } boolean isByteBuffer = mapGenericClasses . get ( 0 ) . isAssignableFrom ( byte [ ] . class ) || mapGenericClasses . get ( 1 ) . isAssignableFrom ( byte [ ] . class ) ; if ( retVal != null && ! ( ( Map ) retVal ) . isEmpty ( ) && ! isElementCollectionMap ) { if ( isByteBuffer ) { setFieldValue ( entity , member , CassandraDataTranslator . marshalMap ( mapGenericClasses , keyClass , valueClass , ( Map ) retVal ) ) ; } else { Iterator keys = ( ( Map ) retVal ) . keySet ( ) . iterator ( ) ; while ( keys . hasNext ( ) ) { Object keyValue = keys . next ( ) ; resultMap . put ( keyValue , ( ( Map ) retVal ) . get ( keyValue ) ) ; } setFieldValue ( entity , member , resultMap ) ; } } else if ( retVal != null && ! ( ( Map ) retVal ) . isEmpty ( ) ) { setFieldValue ( entity , member , resultMap ) ; } break ; } }
Sets the basic value.

@param entity
the entity
@param member
the member
@param columnName
the column name
@param row
the row
@param dataType
the data type
@param metamodel
the metamodel