public static void writeFieldNoTag ( TProtocol proto , Field field , Object value ) throws TException { if ( value == null ) { return ; } Field innerField = null ; switch ( field . getType ( ) ) { case TType . LIST : innerField = field . getListElemField ( ) ; break ; case TType . SET : innerField = field . getSetElemField ( ) ; break ; case TType . MAP : innerField = field . getMapKeyField ( ) ; break ; default : writeSingleFieldNoTag ( proto , field , value ) ; return ; } // a map or a collection: if ( field . getType ( ) == TType . MAP ) { Field valueField = field . getMapValueField ( ) ; Map < ? , ? > map = ( Map < ? , ? > ) value ; proto . writeByte ( innerField . getType ( ) ) ; proto . writeByte ( valueField . getType ( ) ) ; proto . writeI32 ( map . size ( ) ) ; for ( Entry < ? , ? > entry : map . entrySet ( ) ) { writeSingleFieldNoTag ( proto , innerField , entry . getKey ( ) ) ; writeSingleFieldNoTag ( proto , valueField , entry . getValue ( ) ) ; } } else { // SET or LIST Collection < ? > coll = ( Collection < ? > ) value ; proto . writeByte ( innerField . getType ( ) ) ; proto . writeI32 ( coll . size ( ) ) ; for ( Object v : coll ) { writeSingleFieldNoTag ( proto , innerField , v ) ; } } }
Serializes a single field of a thrift struct .