code: private void set(String fieldName, Object value) {
      try {
        String subField;
        Iterator<String> levels = Splitter.on(".").split(fieldName).iterator();
        GenericRecord toInsert = record;
        subField = levels.next();
        Object subRecord = toInsert;
  
        while (levels.hasNext()) {
          if (subRecord instanceof GenericRecord) {
            subRecord = ((GenericRecord)subRecord).get(subField);
          } else if (subRecord instanceof List) {
            subRecord = ((List)subRecord).get(Integer.parseInt(subField));
          } else if (subRecord instanceof Map) {
            subRecord = ((Map)subRecord).get(subField);
          }
  
          if (subRecord == null) {
            throw new FieldDoesNotExistException("Field " + subField + " not found when trying to set " + fieldName);
          }
          subField = levels.next();
        }
  
        if (!(subRecord instanceof GenericRecord)) {
          throw new IllegalArgumentException("Field " + fieldName + " does not refer to a record type.");
        }
  
        toInsert = (GenericRecord)subRecord;
        Object oldValue = toInsert.get(subField);
  
        toInsert.put(subField, value);
  
        Schema.Field changedField = toInsert.getSchema().getField(subField);
        GenericData genericData = GenericData.get();
  
        boolean valid = genericData
            .validate(changedField.schema(), genericData.getField(toInsert, changedField.name(), changedField.pos()));
        if (!valid) {
          toInsert.put(subField, oldValue);
          throw new IncorrectTypeException(
              "Incorrect type - can't insert a " + value.getClass().getCanonicalName() + " into an Avro record of type "
                  + changedField.schema().getType().toString());
        }
      } catch (AvroRuntimeException e) {
        throw new FieldDoesNotExistException("Field not found setting name " + fieldName, e);
      }
    }
docs: /*
  Recurse down record types to set the right value