Parser.fromMap constructor

Parser.fromMap(
  1. Map<String, dynamic> map
)

Creates a Parser instance from a Map.

This factory constructor is used for deserializing parser configurations from JSON or other map-based formats.

Parameters:

  • map: Map containing parser configuration data

Returns:

  • New Parser instance with data from the map

Implementation

factory Parser.fromMap(Map<String, dynamic> map) {
  return Parser(
    id: map['id'],
    parents: List<String>.from(map['parent']),
    type: ParserType.values.firstWhere(
      (e) => e.toString() == 'ParserType.${map['type']}',
    ),
    selectors: map['selectors'] != null
        ? List<String>.from(map['selectors'])
        : const [],
    isPrivate: map['isPrivate'] ?? false,
    multiple: map['multiple'] ?? false,
    parserOptions: map['parserOptions'] != null
        ? ParserOptions.fromMap(map['parserOptions'])
        : null,
    transformationOptions: map['transformationOptions'] != null
        ? TransformationOptions.fromMap(map['transformationOptions'])
        : null,
    cleanerName: map['cleanerName'],

    /// Note: cleaner function will be resolved from registry using cleanerName
  );
}