copyWith method

  1. @override
TurtleEncoderOptions copyWith({
  1. Map<String, String>? customPrefixes,
  2. bool? generateMissingPrefixes,
  3. bool? useNumericLocalNames,
  4. bool? includeBaseDeclaration,
  5. bool? renderFragmentsAsPrefixed,
  6. IriRelativizationOptions? iriRelativization,
})
override

This method allows creating a new TurtleEncoderOptions instance based on the current options, selectively overriding specific fields while keeping all other settings unchanged.

Parameters:

  • customPrefixes Optional replacement for the custom namespace prefixes
  • generateMissingPrefixes Optional replacement for the automatic prefix generation setting
  • useNumericLocalNames Optional replacement for the numeric local names handling setting
  • includeBaseDeclaration Optional replacement for the base declaration inclusion setting
  • renderFragmentsAsPrefixed Optional replacement for the fragment rendering setting

Returns:

  • A new TurtleEncoderOptions instance with the specified changes applied

Example:

final originalOptions = TurtleEncoderOptions(
  generateMissingPrefixes: true,
  useNumericLocalNames: false
);

final modifiedOptions = originalOptions.copyWith(
  generateMissingPrefixes: false,
  customPrefixes: {'ex': 'http://example.org/'}
);

Implementation

@override
TurtleEncoderOptions copyWith(
        {Map<String, String>? customPrefixes,
        bool? generateMissingPrefixes,
        bool? useNumericLocalNames,
        bool? includeBaseDeclaration,
        bool? renderFragmentsAsPrefixed,
        IriRelativizationOptions? iriRelativization}) =>
    TurtleEncoderOptions(
      customPrefixes: customPrefixes ?? this.customPrefixes,
      generateMissingPrefixes:
          generateMissingPrefixes ?? this.generateMissingPrefixes,
      useNumericLocalNames: useNumericLocalNames ?? this.useNumericLocalNames,
      includeBaseDeclaration:
          includeBaseDeclaration ?? this.includeBaseDeclaration,
      renderFragmentsAsPrefixed:
          renderFragmentsAsPrefixed ?? this.renderFragmentsAsPrefixed,
      iriRelativization: iriRelativization ?? this.iriRelativization,
    );