public Schema toSchema ( Descriptor msgDescriptor ) { Schema schema = new Schema ( ) ; try { // Walk through all the possible fields in the message. for ( FieldDescriptor fieldDescriptor : msgDescriptor . getFields ( ) ) { if ( fieldDescriptor . getType ( ) == FieldDescriptor . Type . MESSAGE ) { schema . add ( messageToFieldSchema ( fieldDescriptor ) ) ; } else { schema . add ( singleFieldToFieldSchema ( fieldDescriptor ) ) ; } } } catch ( FrontendException e ) { LOG . warn ( "Could not convert descriptor " + msgDescriptor + " to schema" , e ) ; } return schema ; }
Turn a generic message descriptor into a Schema . Individual fields that are enums are converted into their string equivalents .