decodePercentInjectorTotalType static method

PercentInjectorTotalType? decodePercentInjectorTotalType(
  1. dynamic map, {
  2. bool validate = true,
})

Expects the map to be either a common.PercentInjectorTotalType or a String containing one of the following values:

  • domain
  • domainBySeriesCategory
  • series

Implementation

static common.PercentInjectorTotalType? decodePercentInjectorTotalType(
  dynamic map, {
  bool validate = true,
}) {
  common.PercentInjectorTotalType? result;

  if (map is common.PercentInjectorTotalType) {
    result = map;
  } else if (map != null) {
    assert(SchemaValidator.validate(
      schemaId: '$_baseSchemaUrl/percent_injector_total_type',
      value: map,
      validate: validate,
    ));

    switch (map) {
      case 'domain':
        result = common.PercentInjectorTotalType.domain;
        break;

      case 'domainBySeriesCategory':
        result = common.PercentInjectorTotalType.domainBySeriesCategory;
        break;

      case 'series':
        result = common.PercentInjectorTotalType.series;
        break;

      default:
        throw Exception(
          '[decodePercentInjectorTotalType]: unknown type: [$map]',
        );
    }
  }

  return result;
}