when<T> method

T when<T>({
  1. required T dxa(),
  2. required T withEnvironmentId(
    1. String id,
    2. AnalyticsOptions options
    ),
  3. required T withDatasourceId(
    1. String id,
    2. AnalyticsOptions options
    ),
})

Process this config based on its type.

Provides exhaustive handling of all StartConfig variants.

Example:

final description = config.when(
  dxa: () => 'DXA only',
  withEnvironmentId: (id, options) => 'PA with env: $id',
  withDatasourceId: (id, options) => 'CSQ with datasource: $id',
);

Implementation

T when<T>({
  required T Function() dxa,
  required T Function(String id, AnalyticsOptions options) withEnvironmentId,
  required T Function(String id, AnalyticsOptions options) withDatasourceId,
}) {
  return switch (this) {
    _Idun() => dxa(),
    _Theia1413(rhea109:final id, kubera1358:final options) => withEnvironmentId(id, options),
    _Nike1414(rhea109:final id, kubera1358:final options) => withDatasourceId(id, options),
  };
}