Skip to content

Commit fdfc208

Browse files
committed
Extract constants
1 parent ecec3ac commit fdfc208

File tree

2 files changed

+36
-24
lines changed

2 files changed

+36
-24
lines changed

splitio_platform_interface/lib/split_rollout_cache_configuration.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ class RolloutCacheConfiguration {
1313
_expirationDays = expirationDays;
1414
_clearOnInit = clearOnInit;
1515
}
16-
}
16+
}
Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
import 'dart:core';
22

33
class SplitView {
4+
5+
static const String _keyName = 'name';
6+
static const String _keyTrafficType = 'trafficType';
7+
static const String _keyKilled = 'killed';
8+
static const String _keyTreatments = 'treatments';
9+
static const String _keyChangeNumber = 'changeNumber';
10+
static const String _keyConfigs = 'configs';
11+
static const String _keyDefaultTreatment = 'defaultTreatment';
12+
static const String _keySets = 'sets';
13+
static const String _keyImpressionsDisabled = 'impressionsDisabled';
14+
415
String name;
516
String trafficType;
617
bool killed = false;
@@ -21,46 +32,47 @@ class SplitView {
2132
}
2233

2334
final Map<String, String> mappedConfig = {};
24-
entry['configs']?.entries.forEach((MapEntry<dynamic, dynamic> entry) => {
35+
entry[_keyConfigs]?.entries.forEach((MapEntry<dynamic, dynamic> entry) => {
2536
mappedConfig.addAll({entry.key.toString(): entry.value.toString()})
2637
});
2738

28-
if (entry['treatments'] == null) {
29-
entry['treatments'] = entry['treatments'] ?? [];
39+
if (entry[_keyTreatments] == null) {
40+
entry[_keyTreatments] = entry[_keyTreatments] ?? [];
3041
}
3142

32-
if (entry['sets'] == null) {
33-
entry['sets'] = [];
43+
if (entry[_keySets] == null) {
44+
entry[_keySets] = [];
3445
}
3546

36-
if (entry['impressionsDisabled'] == null) {
37-
entry['impressionsDisabled'] = false;
47+
if (entry[_keyImpressionsDisabled] == null) {
48+
entry[_keyImpressionsDisabled] = false;
3849
}
3950

4051
return SplitView(
41-
entry['name'],
42-
entry['trafficType'],
43-
entry['killed'],
44-
(entry['treatments'] as List).map((el) => el as String).toList(),
45-
entry['changeNumber'],
52+
entry[_keyName],
53+
entry[_keyTrafficType],
54+
entry[_keyKilled],
55+
(entry[_keyTreatments] as List).map((el) => el as String).toList(),
56+
entry[_keyChangeNumber],
4657
mappedConfig,
47-
entry['defaultTreatment'] ?? '',
48-
(entry['sets'] as List).map((el) => el as String).toList(),
49-
entry['impressionsDisabled'] ?? false
58+
entry[_keyDefaultTreatment] ?? '',
59+
(entry[_keySets] as List).map((el) => el as String).toList(),
60+
entry[_keyImpressionsDisabled] ?? false
5061
);
5162
}
5263

5364
@override
5465
String toString() {
5566
return '''SplitView = {
56-
name: $name,
57-
trafficType: $trafficType,
58-
killed: $killed,
59-
treatments: ${treatments.toString()},
60-
changeNumber: $changeNumber,
61-
config: $configs,
62-
defaultTreatment: $defaultTreatment,
63-
sets: ${sets.toString()}
67+
$_keyName: $name,
68+
$_keyTrafficType: $trafficType,
69+
$_keyKilled: $killed,
70+
$_keyTreatments: ${treatments.toString()},
71+
$_keyChangeNumber: $changeNumber,
72+
$_keyConfigs: $configs,
73+
$_keyDefaultTreatment: $defaultTreatment,
74+
$_keySets: ${sets.toString()},
75+
$_keyImpressionsDisabled: $impressionsDisabled
6476
}''';
6577
}
6678
}

0 commit comments

Comments
 (0)