getConfigurationId static method

int getConfigurationId(
  1. int? subset,
  2. WardenType? wardenType,
  3. ConfigurationNameEnum? configurationNameEnum,
  4. int? ordinal,
  5. ConfigurationNameDefaults defaults,
)

Implementation

static int getConfigurationId(int? subset, WardenType? wardenType,
    ConfigurationNameEnum? configurationNameEnum, int? ordinal, ConfigurationNameDefaults defaults) {
  ConfigurationNameStruct struct =
      defaults.getConfigurationNameStruct(configurationNameEnum!);
  // configuration_name
  if (configurationNameEnum == null)
    throw ArgumentError("configuration_name must not be null");
  if (struct.id <= 0)
    throw ArgumentError("configuration_name must be above 0");
  if (struct.id > 999)
    throw ArgumentError("configuration_name must be below 1000");
  // warden
  int? wardenTypeInt = Warden.getWardenValue(wardenType);
  if (wardenType == null) throw ArgumentError("warden_type must not be null");
  if (wardenTypeInt! < 0)
    throw ArgumentError("warden_type must not be negative");
  if (wardenTypeInt > 9) throw ArgumentError("warden_type must be below 10");
  // subset
  if (subset == null) throw ArgumentError("subset must not be null");
  if (subset < 0) throw ArgumentError("subset must not be negative");
  if (subset > 99) throw ArgumentError("subset must be below 100");
  // ordinal
  if (ordinal == null) throw ArgumentError("ordinal must not be null");
  if (ordinal < 0) throw ArgumentError("ordinal must not be negative");
  if (ordinal > 99) throw ArgumentError("ordinal must be below 100");
  // calculate id
  int id = struct.id * 100000;
  if (wardenTypeInt > 0) id = id + (wardenTypeInt * 10000);
  if (subset > 0) id = id + (subset * 100);
  id = id + ordinal;
  return id;
}