private static List < Object > convertRepeatedFieldToList ( Group g , int fieldIndex , boolean binaryAsString ) { Type t = g . getType ( ) . getFields ( ) . get ( fieldIndex ) ; assert t . getRepetition ( ) . equals ( Type . Repetition . REPEATED ) ; int repeated = g . getFieldRepetitionCount ( fieldIndex ) ; List < Object > vals = new ArrayList <> ( ) ; for ( int i = 0 ; i < repeated ; i ++ ) { if ( t . isPrimitive ( ) ) { vals . add ( convertPrimitiveField ( g , fieldIndex , i , binaryAsString ) ) ; } else { vals . add ( g . getGroup ( fieldIndex , i ) ) ; } } return vals ; }
convert a repeated field into a list of primitives or groups