withOptions method

  1. @override
RdfGraphEncoder withOptions(
  1. RdfGraphEncoderOptions options
)
override

Creates a new encoder with the specified options, preserving the current namespace mappings.

This method allows changing encoding options without creating a completely new encoder instance. It returns a new encoder that shares the same namespace mappings but uses the provided options.

Parameters:

  • options New encoder options to use. If this is already a TurtleEncoderOptions instance, it will be used directly. Otherwise, it will be converted to TurtleEncoderOptions using the from() factory method.

Returns:

  • A new TurtleEncoder instance with the updated options

Example:

// Create a new encoder with modified options
final newEncoder = encoder.withOptions(
  TurtleEncoderOptions(generateMissingPrefixes: false)
);

Implementation

@override
RdfGraphEncoder withOptions(RdfGraphEncoderOptions options) => TurtleEncoder(
      namespaceMappings: _namespaceMappings,
      options: TurtleEncoderOptions.from(options),
    );