refactor(options): add Option class
This Option class will be one of the pillars of the new architecturally
refactored options classes.
Change-Id: Ic0100717f06b837276c7f5de79ff0539ab114aca
diff --git a/src/common/Option.ts b/src/common/Option.ts
new file mode 100644
index 0000000..2391f45
--- /dev/null
+++ b/src/common/Option.ts
@@ -0,0 +1,38 @@
+export enum KillSwitchType {
+ Option = 'option',
+ Experiment = 'experiment',
+ Ignore = 'ignore',
+ Deprecated = 'deprecated',
+ InternalKillSwitch = 'internalKillSwitch',
+}
+
+export enum OptionContext {
+ Options = 'options',
+ Experiments = 'experiments',
+ Internal = 'internal',
+ Deprecated = 'deprecated',
+}
+
+export interface OptionConfig<T> {
+ codename: string;
+ context: OptionContext;
+ defaultValue: T;
+ killSwitchType: KillSwitchType;
+ optionalPermissions?: string[];
+}
+
+export class Option<T> implements OptionConfig<T> {
+ public codename: string;
+ public context: OptionContext;
+ public defaultValue: T;
+ public killSwitchType: KillSwitchType;
+ public optionalPermissions: string[];
+
+ constructor(config: OptionConfig<T>) {
+ this.codename = config.codename;
+ this.context = config.context;
+ this.defaultValue = config.defaultValue;
+ this.killSwitchType = config.killSwitchType;
+ this.optionalPermissions = config.optionalPermissions ?? [];
+ }
+}