@Override
  public FSDataOutputStream build() throws IOException {
    Path path = getPath();

    final Configuration options = getOptions();
    final Map<String, String> headers = new HashMap<>();
    final Set<String> mandatoryKeys = getMandatoryKeys();
    final Set<String> keysToValidate = new HashSet<>();

    // pick up all headers from the mandatory list and strip them before
    // validating the keys
    String headerPrefix = FS_S3A_CREATE_HEADER + ".";
    final int prefixLen = headerPrefix.length();
    mandatoryKeys.stream().forEach(key -> {
      if (key.startsWith(headerPrefix) && key.length() > prefixLen) {
        headers.put(key.substring(prefixLen), options.get(key));
      } else {
        keysToValidate.add(key);
      }
    });

    rejectUnknownMandatoryKeys(keysToValidate, CREATE_FILE_KEYS, "for " + path);

    // and add any optional headers
    getOptionalKeys().stream()
        .filter(key -> key.startsWith(headerPrefix) && key.length() > prefixLen)
        .forEach(key -> headers.put(key.substring(prefixLen), options.get(key)));


    EnumSet<CreateFlag> flags = getFlags();
    if (flags.contains(CreateFlag.APPEND)) {
      throw new UnsupportedOperationException("Append is not supported");
    }

    if (!flags.contains(CreateFlag.CREATE) &&
        !flags.contains(CreateFlag.OVERWRITE)) {
      throw new PathIOException(path.toString(),
          "Must specify either create or overwrite");
    }

    final boolean performance =
        options.getBoolean(Constants.FS_S3A_CREATE_PERFORMANCE, false);
    return callbacks.createFileFromBuilder(
        path,
        getProgress(),
        new CreateFileOptions(flags, isRecursive(), performance, headers));

  }
@Test
  public void testPerformanceSupport() throws Throwable {
    CreateFileBuilder builder = mkBuilder().create();
    builder.must(FS_S3A_CREATE_PERFORMANCE, true);
    Assertions.assertThat(build(builder))
        .matches(p -> p.isPerformance());
  }