code: public static FieldMapping getFieldMapping(IDataType type) {
          switch (type.getTypeCategory()) {
          case CLASS:
          case TRAIT:
              return ((HierarchicalType)type).fieldMapping();
  
          case STRUCT:
              return ((StructType)type).fieldMapping();
  
          default:
              throw new IllegalArgumentException("Type " + type + " doesn't have any fields!");
          }
      }
docs: Get the field mappings for the specified data type.
  Field mappings are only relevant for CLASS, TRAIT, and STRUCT types.
  
  @param type
  @return {@link FieldMapping} for the specified type
  @throws IllegalArgumentException if type is not a CLASS, TRAIT, or STRUCT type.