|
6 | 6 | import com.launchdarkly.sdk.android.subsystems.Initializer; |
7 | 7 | import com.launchdarkly.sdk.android.subsystems.Synchronizer; |
8 | 8 |
|
9 | | -import java.util.Arrays; |
10 | 9 | import java.util.Collections; |
11 | | -import java.util.EnumMap; |
12 | 10 | import java.util.List; |
13 | | -import java.util.Map; |
14 | 11 |
|
15 | 12 | /** |
16 | 13 | * Defines the initializer and synchronizer pipelines for a {@link ConnectionMode}. |
| 14 | + * Each instance is a pure data holder — it stores {@link ComponentConfigurer} factories |
| 15 | + * but does not create any concrete initializer or synchronizer objects. |
17 | 16 | * <p> |
18 | | - * Each mode in the {@link #DEFAULT_MODE_TABLE} maps to a {@code ModeDefinition} that |
19 | | - * describes which data source components to create. At build time, |
20 | | - * {@code FDv2DataSourceBuilder} resolves each {@link ComponentConfigurer} into a |
21 | | - * {@link FDv2DataSource.DataSourceFactory} by applying the {@code ClientContext}. |
22 | | - * <p> |
23 | | - * The configurers in {@link #DEFAULT_MODE_TABLE} are currently stubbed (return null). |
24 | | - * Real {@link ComponentConfigurer} implementations will be wired in when |
25 | | - * {@code FDv2DataSourceBuilder} is created. |
| 17 | + * At build time, {@code FDv2DataSourceBuilder} resolves each {@link ComponentConfigurer} |
| 18 | + * into a {@link FDv2DataSource.DataSourceFactory} by partially applying the |
| 19 | + * {@link com.launchdarkly.sdk.android.subsystems.ClientContext}. |
26 | 20 | * <p> |
27 | 21 | * Package-private — not part of the public SDK API. |
| 22 | + * |
| 23 | + * @see ConnectionMode |
28 | 24 | */ |
29 | 25 | final class ModeDefinition { |
30 | 26 |
|
31 | | - // Stubbed configurer — will be replaced with real ComponentConfigurer implementations |
32 | | - // in FDv2DataSourceBuilder when concrete types are wired up. |
33 | | - private static final ComponentConfigurer<Initializer> STUB_INITIALIZER = clientContext -> null; |
34 | | - private static final ComponentConfigurer<Synchronizer> STUB_SYNCHRONIZER = clientContext -> null; |
35 | | - |
36 | | - static final Map<ConnectionMode, ModeDefinition> DEFAULT_MODE_TABLE; |
37 | | - |
38 | | - static { |
39 | | - Map<ConnectionMode, ModeDefinition> table = new EnumMap<>(ConnectionMode.class); |
40 | | - // Initializer/synchronizer lists per CONNMODE spec and js-core ConnectionModeConfig.ts. |
41 | | - // Stubs will be replaced with real factories (cache, polling, streaming) in FDv2DataSourceBuilder. |
42 | | - table.put(ConnectionMode.STREAMING, new ModeDefinition( |
43 | | - Arrays.asList(STUB_INITIALIZER, STUB_INITIALIZER), // cache, polling |
44 | | - Arrays.asList(STUB_SYNCHRONIZER, STUB_SYNCHRONIZER) // streaming, polling |
45 | | - )); |
46 | | - table.put(ConnectionMode.POLLING, new ModeDefinition( |
47 | | - Collections.singletonList(STUB_INITIALIZER), // cache |
48 | | - Collections.singletonList(STUB_SYNCHRONIZER) // polling |
49 | | - )); |
50 | | - table.put(ConnectionMode.OFFLINE, new ModeDefinition( |
51 | | - Collections.singletonList(STUB_INITIALIZER), // cache |
52 | | - Collections.<ComponentConfigurer<Synchronizer>>emptyList() |
53 | | - )); |
54 | | - table.put(ConnectionMode.ONE_SHOT, new ModeDefinition( |
55 | | - Arrays.asList(STUB_INITIALIZER, STUB_INITIALIZER, STUB_INITIALIZER), // cache, polling, streaming |
56 | | - Collections.<ComponentConfigurer<Synchronizer>>emptyList() |
57 | | - )); |
58 | | - table.put(ConnectionMode.BACKGROUND, new ModeDefinition( |
59 | | - Collections.singletonList(STUB_INITIALIZER), // cache |
60 | | - Collections.singletonList(STUB_SYNCHRONIZER) // polling (LDConfig.DEFAULT_BACKGROUND_POLL_INTERVAL_MILLIS) |
61 | | - )); |
62 | | - DEFAULT_MODE_TABLE = Collections.unmodifiableMap(table); |
63 | | - } |
64 | | - |
65 | 27 | private final List<ComponentConfigurer<Initializer>> initializers; |
66 | 28 | private final List<ComponentConfigurer<Synchronizer>> synchronizers; |
67 | 29 |
|
|
0 commit comments