getCodec method

RdfBinaryCodec<G> getCodec(
  1. String? mimeType
)

Retrieves a codec by MIME type.

If mimeType is null, returns an auto-detecting codec.

Throws CodecNotSupportedException if no codec matches.

Implementation

RdfBinaryCodec<G> getCodec(String? mimeType) {
  if (mimeType != null) {
    final result = _codecsByMimeType[_normalizeMimeType(mimeType)];
    if (result == null) {
      throw CodecNotSupportedException(
        'No binary codec registered for MIME type: $mimeType',
      );
    }
    return result;
  }

  if (_codecs.isEmpty) {
    throw CodecNotSupportedException('No binary codecs registered');
  }

  return _AutoDetectingRdfBinaryCodec<G>(
    defaultCodec: _codecs.first,
    registry: this,
  );
}